Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# (c) 2018-2020
2# MPIB <https://www.mpib-berlin.mpg.de/>,
3# MPI-CBS <https://www.cbs.mpg.de/>,
4# MPIP <http://www.psych.mpg.de/>
5#
6# This file is part of Castellum.
7#
8# Castellum is free software; you can redistribute it and/or modify it
9# under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# Castellum is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public
19# License along with Castellum. If not, see
20# <http://www.gnu.org/licenses/>.
22from django.core.exceptions import PermissionDenied
23from django.shortcuts import get_object_or_404
24from django.urls import reverse
26from castellum.recruitment.mixins import BaseAppointmentFeed
27from castellum.studies.models import Study
30class AppointmentFeed(BaseAppointmentFeed):
31 def get_object(self, request, *args, **kwargs):
32 study = get_object_or_404(Study, pk=kwargs['pk'], status=Study.EXECUTION)
33 perms = ('recruitment.view_participation_pseudonyms', 'studies.access_study')
34 if not self.request.user.has_perms(perms, obj=study):
35 raise PermissionDenied
36 return study
38 def items(self, study):
39 return super().items(study)\
40 .filter(session__study=study)\
41 .select_related('participant__subject', 'session__study')
43 def item_title(self, item):
44 return '{} - {}'.format(item.participant.subject.contact.full_name, item.session.name)
46 def item_link(self, item):
47 return reverse('execution:participationrequest-detail', args=[
48 item.session.study.pk, item.participant.pk
49 ])
51 def item_description(self, item):
52 return self.request.build_absolute_uri(self.item_link(item))