Skip to content

Commit

Permalink
Merge pull request #591 from CTPUG/talk-state-publication-consistency
Browse files Browse the repository at this point in the history
Talk state publication consistency
  • Loading branch information
drnlm committed Jun 3, 2021
2 parents ae17f6a + e8e536e commit 0fa5b07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions wafer/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def pending_talks(self):
def cancelled_talks(self):
return self.user.talks.filter(status=CANCELLED)

def published_talks(self):
return self.user.talks.filter(status__in=(ACCEPTED, CANCELLED))

def avatar_url(self, size=96, https=True, default='mm'):
if not self.user.email:
return None
Expand Down
30 changes: 15 additions & 15 deletions wafer/users/templates/wafer.users/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,23 @@ <h3 class="card-title">
</div>
{% endfor %}
{% endif %}
{% if profile.provisional_talks.exists %}
<h2>{% trans 'Provisionally Accepted Talks:' %}</h2>
{% for talk in profile.provisional_talks %}
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract.rendered|safe }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{# Submitted talk proposals are only visible to the owner #}
{% if can_edit %}
{% if profile.provisional_talks.exists %}
<h2>{% trans 'Provisionally Accepted Talks:' %}</h2>
{% for talk in profile.provisional_talks %}
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ talk.get_absolute_url }}">
{{ talk.title }}
</a>
</h3>
<p>{{ talk.abstract.rendered|safe }}</p>
</div>
</div>
{% endfor %}
{% endif %}
{% if profile.pending_talks.exists %}
<h2>{% trans 'Submitted or Under Consideration Talks:' %}</h2>
{% for talk in profile.pending_talks %}
Expand Down
6 changes: 3 additions & 3 deletions wafer/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rest_framework import viewsets
from rest_framework.permissions import IsAdminUser

from wafer.talks.models import ACCEPTED
from wafer.talks.models import ACCEPTED, CANCELLED
from wafer.users.forms import UserForm, UserProfileForm
from wafer.users.serializers import UserSerializer
from wafer.users.models import UserProfile
Expand All @@ -30,7 +30,7 @@ class UsersView(PaginatedBuildableListView):
def get_queryset(self, *args, **kwargs):
qs = super(UsersView, self).get_queryset(*args, **kwargs)
if not settings.WAFER_PUBLIC_ATTENDEE_LIST:
qs = qs.filter(talks__status=ACCEPTED).distinct()
qs = qs.filter(talks__status__in=(ACCEPTED, CANCELLED)).distinct()
qs = qs.order_by('first_name', 'last_name', 'username')
return qs

Expand Down Expand Up @@ -84,7 +84,7 @@ def get_object(self, *args, **kwargs):
object_ = super(ProfileView, self).get_object(*args, **kwargs)
if not settings.WAFER_PUBLIC_ATTENDEE_LIST:
if (not self.can_edit(object_) and
not object_.userprofile.accepted_talks().exists()):
not object_.userprofile.published_talks().exists()):
raise PermissionDenied()
return object_

Expand Down

0 comments on commit 0fa5b07

Please sign in to comment.