Commit db804a47 authored by Bengfort's avatar Bengfort
Browse files

rename participant to participation

parent 14ed1695
Pipeline #6423 passed with stages
in 7 minutes and 35 seconds
......@@ -38,14 +38,14 @@ class AppointmentFeed(BaseAppointmentFeed):
def items(self, study):
return super().items(study)\
.filter(session__study=study)\
.select_related('participant__subject', 'session__study')
.select_related('participation__subject', 'session__study')
def item_title(self, item):
return '{} - {}'.format(item.participant.subject.contact.full_name, item.session.name)
return '{} - {}'.format(item.participation.subject.contact.full_name, item.session.name)
def item_link(self, item):
return reverse('execution:participation-detail', args=[
item.session.study.pk, item.participant.pk
item.session.study.pk, item.participation.pk
])
def item_description(self, item):
......
......@@ -14,9 +14,9 @@
{% for appointment in object_list %}
<li class="table-list-item">
{{ appointment.start|time }}
<span class="h4 d-inline-block mx-1">{{ appointment.participant.subject.contact.full_name }}</span>
{{ appointment.participant.study }}
{{ appointment.participant.study.contact_person }}
<span class="h4 d-inline-block mx-1">{{ appointment.participation.subject.contact.full_name }}</span>
{{ appointment.participation.study }}
{{ appointment.participation.study.contact_person }}
</li>
{% empty %}
<li class="alert alert-info">{% trans 'No appointments today' %}</li>
......
......@@ -159,7 +159,7 @@ class CalendarView(StudyMixin, PermissionRequiredMixin, BaseCalendarView):
'start': appointment.start,
'end': appointment.end,
'url': reverse('execution:participation-detail', args=[
self.object.pk, appointment.participant.pk
self.object.pk, appointment.participation.pk
]),
}
......@@ -174,6 +174,6 @@ class ReceptionView(PermissionRequiredMixin, ListView):
def get_queryset(self):
return super().get_queryset().filter(
participant__status=Participation.INVITED,
participation__status=Participation.INVITED,
start__date=datetime.date.today(),
).order_by('start')
......@@ -229,8 +229,8 @@ class ContactForm(forms.ModelForm):
break
qs = Appointment.objects\
.exclude(participant=self.instance)\
.filter(participant__status=Participation.INVITED)\
.exclude(participation=self.instance)\
.filter(participation__status=Participation.INVITED)\
.annotate(end=models.ExpressionWrapper(
models.F('start') + models.F('session__duration') * MINUTE,
output_field=models.DateTimeField(),
......
# Generated by Django 3.0.8 on 2020-07-06 14:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('studies', '0013_geojson_validator'),
('recruitment', '0009_rename_participation_request'),
]
operations = [
migrations.RenameField(
model_name='appointment',
old_name='participant',
new_name='participation',
),
]
......@@ -112,7 +112,7 @@ class BaseCalendarView(DetailView):
template_name = 'recruitment/calendar.html'
def get_appointments(self):
return Appointment.objects.filter(participant__status=Participation.INVITED)
return Appointment.objects.filter(participation__status=Participation.INVITED)
def render_appointment(self, appointment):
return {
......@@ -151,7 +151,7 @@ class BaseFollowUpFeed(BaseICalFeed):
class BaseAppointmentFeed(BaseICalFeed):
def items(self, obj):
return Appointment.objects.filter(participant__status=Participation.INVITED)
return Appointment.objects.filter(participation__status=Participation.INVITED)
def item_start_datetime(self, item):
return item.start
......
......@@ -38,23 +38,23 @@ MINUTE = datetime.timedelta(seconds=60)
class Appointment(models.Model):
session = models.ForeignKey(StudySession, verbose_name=_('Session'), on_delete=models.CASCADE)
start = DateTimeField(_('Start'))
participant = models.ForeignKey(
participation = models.ForeignKey(
Participation,
on_delete=models.CASCADE,
verbose_name=_('Participant'),
verbose_name=_('Participation'),
)
class Meta:
ordering = ('start',)
unique_together = ['session', 'participant']
unique_together = ['session', 'participation']
def __str__(self):
return '%s %s' % (date_format(self.start), time_format(self.start))
def clean(self):
if self.session.study != self.participant.study:
if self.session.study != self.participation.study:
raise ValidationError(
_('Session and participant do not belong to the same study'), code='study'
_('Session and participation do not belong to the same study'), code='study'
)
@property
......
......@@ -2,7 +2,7 @@
<ul class="table-list mt-3">
{% has_perm 'recruitment.change_participation' user study as can_change_participation %}
{% for participation, buckets, can_access in participants %}
{% for participation, buckets, can_access in participations %}
<li class="table-list-item">
{% if can_access %}
{% if participation.status == participation.FOLLOWUP_APPOINTED %}
......
......@@ -161,7 +161,7 @@ class RecruitmentView(StudyMixin, PermissionRequiredMixin, ListView):
buckets1 = dict(AttributeDescription.get_statistics_buckets('primary'))
buckets2 = dict(AttributeDescription.get_statistics_buckets('secondary'))
participants = []
participations = []
for participation in self.get_queryset():
try:
attributeset = participation.subject.attributeset
......@@ -175,8 +175,8 @@ class RecruitmentView(StudyMixin, PermissionRequiredMixin, ListView):
participation.subject.privacy_level
)
participants.append((participation, buckets, can_access))
context['participants'] = participants
participations.append((participation, buckets, can_access))
context['participations'] = participations
context['sort_options'] = [
('relevance', _('Relevance')),
......
......@@ -128,7 +128,7 @@ def test_calendar_view_events(client, member, study_in_execution_status, contact
)
baker.make(
Appointment,
participant=participation,
participation=participation,
session__study=study_in_execution_status,
)
......
......@@ -97,7 +97,7 @@ def test_appointment(client, member, participation):
appointment = participation.appointment_set.first()
assert appointment.session == session
assert appointment.participant == participation
assert appointment.participation == participation
def test_appointment_delete(client, member, participation):
......@@ -105,7 +105,7 @@ def test_appointment_delete(client, member, participation):
baker.make(
Appointment,
session=session,
participant=participation,
participation=participation,
)
client.force_login(member)
......@@ -164,8 +164,8 @@ def test_appointment_resource_overlap(client, member, participation, time):
Appointment,
session=session,
start=timezone.make_aware(timezone.datetime(2020, 1, 1, 12)),
participant__study=participation.study,
participant__status=Participation.INVITED,
participation__study=participation.study,
participation__status=Participation.INVITED,
)
client.force_login(member)
......@@ -189,8 +189,8 @@ def test_appointment_resource_overlap_ignore_not_invited(client, member, partici
Appointment,
session=session,
start=timezone.make_aware(timezone.datetime(2020, 1, 1, 12)),
participant__study=participation.study,
participant__status=Participation.UNSUITABLE,
participation__study=participation.study,
participation__status=Participation.UNSUITABLE,
)
client.force_login(member)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment