Skip to content

Commit

Permalink
Merge pull request #452 from ox-it/deal-with-paging-grouping
Browse files Browse the repository at this point in the history
Deal with paging grouping
  • Loading branch information
ahaith committed May 5, 2016
2 parents 554d039 + 4aa21d8 commit d319001
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
22 changes: 22 additions & 0 deletions static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ span.filter-active {
float: left;
width: 90%;
}

.list-group-item.date-continued-previous {
border-top: 0px;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
}
.list-group-item.date-continued-next {
border-bottom: 0px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.continued-next-page{
color: grey;
font-size: 12px;
text-align: center;
}
.continued-previous-page {
color: grey;
font-size: 12px;
white-space: nowrap;
}

.formatting-link {
margin-left: 15px;
color: inherit;
Expand Down
16 changes: 15 additions & 1 deletion talks/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,19 @@ def browse_events(request):
for tab in tab_dates:
if tab['href'] == 'browse?' + old_query:
tab['active'] = True


date_continued_previous = False
if int(page) != 1:
# if the date of the first talk of the current page is the same with that of the last talk of the previous page
if list(events)[0].start.date()==list(paginator.page(int(page)-1))[-1].start.date():
date_continued_previous = True

date_continued_next = False
if paginator.num_pages != int(page):
# if the date of the last talk of the current page is the same with that of the first talk of the next page
if list(events)[-1].start.date()==list(paginator.page(int(page)+1))[0].start.date():
date_continued_next = True

context = {
'events': events,
'grouped_events': grouped_events,
Expand All @@ -148,6 +160,8 @@ def browse_events(request):
'start_date': modified_request_parameters.get('start_date'),
'end_date': modified_request_parameters.get('to'),
'tab_dates': tab_dates,
'date_continued_previous': date_continued_previous,
'date_continued_next': date_continued_next,
}
return render(request, 'events/browse.html', context)

Expand Down
14 changes: 12 additions & 2 deletions talks/templates/events/_event_list.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{% for grouped_event in grouped_events %}
<h4 class="group-date">{{grouped_event.start_date}}</h4>
<h4 class="group-date">{{grouped_event.start_date}}
{% if forloop.first and date_continued_previous %}
<span class="continued-previous-page">, continued from previous page</span>
{% endif %}
</h4>
<ul class="list-group">
{% for event in grouped_event.gr_events %}
<li class="list-group-item">
<li class="list-group-item {% if forloop.first and forloop.parentloop.first and date_continued_previous %} date-continued-previous{% endif %}
{% if forloop.last and forloop.parentloop.last and date_continued_next %} date-continued-next{% endif %}">
{% include 'events/event_teaser.html' %}
</li>
{% if forloop.last and forloop.parentloop.last and date_continued_next %}
<div class="continued-next-page">
{{grouped_event.start_date}} continued on next page
</div>
{% endif %}
{% endfor %}
</ul>
{% endfor %}

0 comments on commit d319001

Please sign in to comment.