Skip to content

Commit

Permalink
Merge pull request #92 from TuringTux/feature/show-unsubscribe-link
Browse files Browse the repository at this point in the history
Show "austreten" instead of "wechseln" link when already subscribed to a tutorial
  • Loading branch information
tynsh authored Nov 25, 2019
2 parents bbd2588 + 67cf08c commit 0362504
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions muesli/web/templates/lecture/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@
<a tal:attributes="href request.route_path('tutorial_view', tutorial_ids=tutorial.id)">Details</a>
</td>
<td>
<a tal:condition='tutorial.student_count &lt; tutorial.max_students '
<a tal:condition="(tutorial.student_count &lt; tutorial.max_students) and tutorial != subscribed_tutorial"
tal:attributes="href request.route_path('tutorial_subscribe', tutorial_id=tutorial.id)">
${'Wechseln' if subscribed else 'Beitreten'}
${'Beitreten' if not subscribed_tutorial else 'Wechseln'}
</a>
<a tal:condition="tutorial == subscribed_tutorial"
tal:attributes="href request.route_path('tutorial_unsubscribe', tutorial_id=tutorial.id)">
Austreten
</a>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions muesli/web/viewsLecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def __init__(self, request):
def __call__(self):
lecture = self.db.query(models.Lecture).options(undefer('tutorials.student_count')).get(self.lecture_id)
times = lecture.prepareTimePreferences(user=self.request.user)
subscribed = self.request.user.id in [s.id for s in lecture.students]
subscribed_tutorial = self.request.user.tutorials.filter(LectureStudent.lecture_id == self.lecture_id).first()
return {'lecture': lecture,
'subscribed': subscribed,
'subscribed_tutorial': subscribed_tutorial,
'times': times,
'prefs': utils.preferences}

Expand Down

0 comments on commit 0362504

Please sign in to comment.