Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paginate the moderation tool #6415

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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