Skip to content

Commit

Permalink
Merge pull request #6415 from escattone/paginate-moderation-tool
Browse files Browse the repository at this point in the history
paginate the moderation tool
  • Loading branch information
akatsoulas authored Dec 17, 2024
2 parents 71386f6 + 9c61ef2 commit e626f80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kitsune/flagit/jinja2/flagit/content_moderation.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
<option value="1">{{ _('Content categorization is updated.') }}</option>
<option value="2">{{ _('Content is appropriately categorized.') }}</option>
</select>
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
<input id="update-status-button-{{ object.content_object.id }}" type="submit"
class="sumo-button primary-button button-lg btn" value={{ _('Update') }} />
</form>
</div>
Expand All @@ -38,6 +38,7 @@ <h3 class="sumo-card-heading"><br>{{ _('Update Status:') }}</h3>
{% else %}
<p>{{ _('There is no content pending moderation.') }}</p>
{% endfor %}
{{ objects|paginator }}
{% endblock %}

{% block filter_dropdown %}
Expand Down
7 changes: 7 additions & 0 deletions kitsune/flagit/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from kitsune.questions.models import Answer, Question
from kitsune.sumo.templatetags.jinja_helpers import urlparams
from kitsune.sumo.urlresolvers import reverse
from kitsune.sumo.utils import paginate
from kitsune.tags.models import SumoTag


Expand Down Expand Up @@ -176,6 +177,11 @@ def moderate_content(request):
.select_related("content_type", "creator")
.prefetch_related("content_object__product")
)

# It's essential that the objects are ordered for pagination. The
# default ordering for flagged objects is by ascending created date.
objects = paginate(request, objects)

objects = set_form_action_for_objects(
objects, reason=FlaggedObject.REASON_CONTENT_MODERATION, product_slug=product_slug
)
Expand All @@ -186,6 +192,7 @@ def moderate_content(request):
obj.available_topics = get_hierarchical_topics(question.product)
obj.available_tags = available_tags
obj.saved_tags = question.tags.values_list("id", flat=True)

return render(
request,
"flagit/content_moderation.html",
Expand Down

0 comments on commit e626f80

Please sign in to comment.