Commit c77a986f authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Fix line lengths

parent dc00b8c9
......@@ -11,34 +11,48 @@ from sendfile import sendfile
def index(request):
query_filter = '' if request.GET.get('filter') is None else request.GET.get('filter')
keywords = '' if request.GET.get('keywords') is None else request.GET.get('keywords')
query_filter = '' if request.GET.get(
'filter') is None else request.GET.get('filter')
keywords = '' if request.GET.get('keywords') is None else request.GET.get(
'keywords')
page = request.GET.get('page')
page = 1 if page is None or not page.isdigit() else int(page)
start_year = date.today().year - 4
# If language is English show one year less, since the width is smaller than needed for the translations to fit
# If language is English show one year less
# since the width is smaller than needed for the translations to fit
if request.LANGUAGE_CODE == 'en':
start_year += 1
year_range = reversed(range(start_year, date.today().year + 1))
members = Member.objects.all()
if query_filter and query_filter.isdigit() and not (
query_filter == 'ex' or query_filter == 'honor' or query_filter == 'old'):
query_filter == 'ex' or
query_filter == 'honor' or
query_filter == 'old'):
members = [obj for obj in members if
obj.current_membership and obj.current_membership.since.year == int(query_filter)]
obj.current_membership and
obj.current_membership.since.year == int(query_filter)]
elif query_filter == 'old':
members = [obj for obj in members if obj.current_membership and obj.current_membership.since.year < start_year]
members = [obj for obj in members if
obj.current_membership and
obj.current_membership.since.year < start_year]
elif query_filter == 'ex':
members = [obj for obj in members if not obj.current_membership]
elif query_filter == 'honor':
members = [obj for obj in members if obj.current_membership and obj.current_membership.type == 'honorary']
members = [obj for obj in members if
obj.current_membership and
obj.current_membership.type == 'honorary']
else:
members = [obj for obj in members if obj.current_membership]
if keywords:
members = [obj for obj in members if keywords in obj.nickname.lower() or keywords in obj.user.first_name.lower() or keywords in obj.user.last_name.lower() or keywords in obj.user.username.lower()]
members = [obj for obj in members if
keywords in obj.nickname.lower() or
keywords in obj.user.first_name.lower() or
keywords in obj.user.last_name.lower() or
keywords in obj.user.username.lower()]
paginator = Paginator(members, 24)
......@@ -54,13 +68,19 @@ def index(request):
page_range = range(1, paginator.num_pages + 1)
if paginator.num_pages > 7:
if page > 3:
page_range = range(page - 2, paginator.num_pages if page + 3 > paginator.num_pages else page + 3)
page_range_end = paginator.num_pages if page + 3 > \
paginator.num_pages else\
page + 3
page_range = range(page - 2, page_range_end)
while page_range.stop - page_range.start < 5:
page_range = range(page_range.start - 1, page_range.stop)
else:
page_range = range(1, 6)
return render(request, 'members/index.html', {'members': members, 'filter': query_filter, 'year_range': year_range, 'page_range': page_range, 'keywords': keywords})
return render(request, 'members/index.html',
{'members': members, 'filter': query_filter,
'year_range': year_range, 'page_range': page_range,
'keywords': keywords})
def profile(request, pk):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment