Skip to content

Commit

Permalink
Merge pull request #605 from terceiro/improve-talk-listing
Browse files Browse the repository at this point in the history
Improve talk listing
  • Loading branch information
stefanor committed Jun 22, 2021
2 parents 650f3c5 + dbe3b85 commit 63f40f3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 42 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ jobs:
continue-on-error: ${{ matrix.django-version == '3.1.0' || matrix.django-version == 'main' }}
run: |
python -m pip install --upgrade pip
pip install psycopg2
pip install -r requirements.txt -r requirements-dev.txt
- name: 'Install psycopg2 for Django < 3.1'
# Django < 3.1 is incompatible with psycopg2 2.9
# See https://github.com/psycopg/psycopg2/issues/1293
if: "matrix.django-version == '2.2.0' || matrix.django-version == '3.0.0'"
run: |
pip install 'psycopg2<2.9'
- name: 'Install psycopg2'
if: "matrix.django-version != '2.2.0' && matrix.django-version != '3.0.0'"
run: |
pip install psycopg2
- name: Install Django Release
run: |
pip install django~=${{ matrix.django-version }}
Expand Down
93 changes: 57 additions & 36 deletions wafer/talks/templates/wafer.talks/talks.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,65 @@
{% block content %}
<section class="wafer wafer-talks">
{% regroup talk_list by talk_type.name as grouped_talks %}
{% for type, talks in grouped_talks %}
{% if type %}
<h1>{{ type }}</h1>
{% else %}
<h1>{% trans 'Talks' %}</h1>
{% endif %}
<div class="wafer list">
{% for talk in talks %}
<div>
{% if not talk.cancelled and not talk.accepted and talk.is_late_submission %}
<span class="badge badge-warning" title="{% trans 'Late submission' %}">L</span>
{% endif %}
{% if talk.submitted %}
<span class="badge badge-info" title="{% trans 'Submitted' %}">{{ talk.status }}</span>
{% elif talk.under_consideration %}
<span class="badge badge-info" title="{% trans 'Under consideration' %}">{{ talk.status }}</span>
{% elif talk.reject %}
<span class="badge badge-danger" title="{% trans 'Not accepted' %}">{{ talk.status }}</span>
{% elif talk.cancelled %}
<span class="badge badge-warning" title="{% trans 'Talk Cancelled' %}">{{ talk.status }}</span>
{% elif talk.provisional %}
<span class="badge badge-success" title="{% trans 'Provisionally Accepted' %}">{{ talk.status }}</span>
{% endif %}
{% reviewed_badge user talk %}
{% if talk.withdrawn %}
<del><a href="{{ talk.get_absolute_url }}">{{ talk.title }}</a></del>
{% else %}
<a href="{{ talk.get_absolute_url }}">{{ talk.title }}</a>
{% endif %}
{% blocktrans trimmed with authors=talk.get_authors_display_name %}
by <span class="author">{{ authors }}</span>
{% endblocktrans %}
</div>
<div class="table-responsive">
<table class='table table-striped'>
{% for type, talks in grouped_talks %}
<thead class='thead-dark'>
<tr>
<th>
{% if type %}
{{ type }}
{% else %}
{% trans "Talk" %}
{% endif %}
</th>
{% if languages %}<th>{% trans "Language" %}</th>{% endif %}
<th>{% trans "Speakers" %}</th>
</tr>
</thead>
{% for talk in talks %}
<tr>
<td>
{% if not talk.cancelled and not talk.accepted and talk.is_late_submission %}
<span class="badge badge-warning" title="{% trans 'Late submission' %}">L</span>
{% endif %}
{% if talk.submitted %}
<span class="badge badge-info" title="{% trans 'Submitted' %}">{{ talk.status }}</span>
{% elif talk.under_consideration %}
<span class="badge badge-info" title="{% trans 'Under consideration' %}">{{ talk.status }}</span>
{% elif talk.reject %}
<span class="badge badge-danger" title="{% trans 'Not accepted' %}">{{ talk.status }}</span>
{% elif talk.cancelled %}
<span class="badge badge-warning" title="{% trans 'Talk Cancelled' %}">{{ talk.status }}</span>
{% elif talk.provisional %}
<span class="badge badge-success" title="{% trans 'Provisionally Accepted' %}">{{ talk.status }}</span>
{% endif %}
{% reviewed_badge user talk %}
{% if talk.withdrawn %}
<del><a href="{{ talk.get_absolute_url }}">{{ talk.title }}</a></del>
{% else %}
<a href="{{ talk.get_absolute_url }}">{{ talk.title }}</a>
{% endif %}
</td>
{% if languages %}
<td>{{ talk.get_language_display }}</td>
{% endif %}
<td>
{% with authors=talk.get_authors_display_name %}
<span class="author">{{ authors }}</span>
{% endwith %}
</td>
</tr>
{% endfor %}
{% empty %}
<p>{% trans 'No talks accepted yet.' %}</p>
<tr>
<th colspan="{% if languages %}3{% else %}2{% endif %}">
{% trans 'No talks accepted yet.' %}
</th>
</tr>
{% endfor %}
</div>
{% endfor %}
</table>
</div>
</section>
{% if is_paginated %}
<section class="wafer wafer-pagination">
Expand Down
18 changes: 13 additions & 5 deletions wafer/talks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,24 @@ def get_object(self, *args, **kwargs):
class UsersTalks(PaginatedBuildableListView):
template_name = 'wafer.talks/talks.html'
build_prefix = 'talks'
paginate_by = 25
paginate_by = 100

@order_results_by('talk_type', 'talk_id')
def get_queryset(self):
# self.request will be None when we come here via the static site
# renderer
if (self.request and Talk.can_view_all(self.request.user)):
return Talk.objects.all()
return Talk.objects.filter(Q(status=ACCEPTED) |
Q(status=CANCELLED))
if self.request and Talk.can_view_all(self.request.user):
talks = Talk.objects.all()
else:
talks = Talk.objects.filter(Q(status=ACCEPTED) | Q(status=CANCELLED))
return talks.prefetch_related(
"talk_type", "corresponding_author", "authors", "authors__userprofile"
)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["languages"] = Talk.LANGUAGES
return context


class TalkView(BuildableDetailView):
Expand Down

0 comments on commit 63f40f3

Please sign in to comment.