Skip to content

Commit

Permalink
Merge pull request #63 from UCL-ARC/fix/film-list-table-TC
Browse files Browse the repository at this point in the history
Film pagination tweaks
  • Loading branch information
acholyn authored Mar 8, 2024
2 parents 1776e2f + e337554 commit 701c18b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion mod_app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<button id="drawer__button--close">x</button>
<ul class="drawer__list-nav">
<li>
<a href="{% url 'film_list' %}">
<a href="{% url 'film_list' %}?page=1">
Films</a></li>
<li><a href="{% url 'analysis_list' %}">
Analyses: Critical Essays and Discussions</a></li>
Expand Down
4 changes: 2 additions & 2 deletions mod_app/templates/film_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
List of films on this site
</div>
{% if is_paginated %}
<a href="?list=all" class="button--toggle-pagination"><button>View All</button></a>
<a href="{% url 'film_list' %}" class="button--toggle-pagination"><button>View All</button></a>
{% else %}
<a href="{% url 'film_list' %}" class="button--toggle-pagination"><button>View by page</button></a>
<a href="{% url 'film_list' %}?page=1" class="button--toggle-pagination"><button>View by page</button></a>
{% endif %}
</div>

Expand Down
22 changes: 6 additions & 16 deletions mod_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,12 @@ class FilmListView(ListView):
template_name = "film_list.html"
paginate_by = 20

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
page = self.request.GET.get("list")

if page == "all":
context["object_list"] = context["film_list"] = self.model.objects.all()
context["is_paginated"] = False
return context

# for film in context["object_list"]:
# # themes = list(film.themes.all())
# # film.themes = themes
# # starring = list(film.cast)
# # film.starring = ", ".join(str(actor) for actor in starring)
# # print(starring, "film.actors", film.actors.all())
# return context
def get_paginate_by(self, queryset):
page = self.request.GET.get(self.page_kwarg)
if page:
return self.paginate_by
else:
return None


class FilmDetailView(DetailView):
Expand Down

0 comments on commit 701c18b

Please sign in to comment.