From a27a393748191a28331728303b3b301501a3bd26 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:49:41 +0200 Subject: [PATCH 1/9] rm unused templatetags --- .../execution/templates/execution/participation_detail.html | 2 +- castellum/execution/templates/execution/study_base.html | 2 +- castellum/recruitment/templates/recruitment/contact.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/castellum/execution/templates/execution/participation_detail.html b/castellum/execution/templates/execution/participation_detail.html index dc58bb5e5..851debbbf 100644 --- a/castellum/execution/templates/execution/participation_detail.html +++ b/castellum/execution/templates/execution/participation_detail.html @@ -1,5 +1,5 @@ {% extends "execution/participation_base.html" %} -{% load i18n utils auth appointments %} +{% load i18n utils auth %} {% block content %} {% if pseudonyms|length > 1 %} diff --git a/castellum/execution/templates/execution/study_base.html b/castellum/execution/templates/execution/study_base.html index 27e5c7f5a..dfa7ff631 100644 --- a/castellum/execution/templates/execution/study_base.html +++ b/castellum/execution/templates/execution/study_base.html @@ -1,5 +1,5 @@ {% extends "execution/base.html" %} -{% load i18n appointments %} +{% load i18n %} {% block title %}{{ study }} · {{ block.super }}{% endblock %} diff --git a/castellum/recruitment/templates/recruitment/contact.html b/castellum/recruitment/templates/recruitment/contact.html index 8a1c2f008..093fd88c7 100644 --- a/castellum/recruitment/templates/recruitment/contact.html +++ b/castellum/recruitment/templates/recruitment/contact.html @@ -1,5 +1,5 @@ {% extends "recruitment/base.html" %} -{% load i18n static bootstrap4 utils auth appointments %} +{% load i18n static bootstrap4 utils auth %} {% block title %}{% translate "Recruitment" %} · {{ study }} · {{ block.super }}{% endblock %} -- GitLab From 7d13ad91aabf00382c97d7ba03f49d058fcc263d Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:45:16 +0200 Subject: [PATCH 2/9] rm showup form --- .../execution/participation_appointments.html | 11 +---- castellum/execution/urls.py | 6 --- castellum/execution/views.py | 40 ------------------- castellum/subjects/urls.py | 2 - 4 files changed, 2 insertions(+), 57 deletions(-) diff --git a/castellum/execution/templates/execution/participation_appointments.html b/castellum/execution/templates/execution/participation_appointments.html index 12b7eddcf..5394332da 100644 --- a/castellum/execution/templates/execution/participation_appointments.html +++ b/castellum/execution/templates/execution/participation_appointments.html @@ -3,18 +3,11 @@ {% block content %}
- {% for session, appointment, form in appointments %} + {% for session, appointment in object.get_appointments %}
{{ session.name }}
{% if appointment %} -
- -
- {% csrf_token %} - {% bootstrap_field form.show_up show_label=False %} - -
-
+ {% else %} — {% endif %} diff --git a/castellum/execution/urls.py b/castellum/execution/urls.py index 1461643d5..9bda872c7 100644 --- a/castellum/execution/urls.py +++ b/castellum/execution/urls.py @@ -39,7 +39,6 @@ from .views import ParticipationPseudonymsView from .views import ParticipationRemoveView from .views import ProgressView from .views import ResolveView -from .views import ShowUpUpdateView from .views import StudyDetailView app_name = 'execution' @@ -103,9 +102,4 @@ urlpatterns = [ AdditionalInfoUpdateView.as_view(), name='additional-info-update', ), - path( - '//update-show-up/', - ShowUpUpdateView.as_view(), - name='show-up', - ), ] diff --git a/castellum/execution/views.py b/castellum/execution/views.py index 8dd524a5f..36bfeb54a 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -224,18 +224,6 @@ class ParticipationAppointmentsView(ParticipationDetailMixin, DetailView): template_name = 'execution/participation_appointments.html' tab = 'appointments' - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - - # The forms post to ShowUpUpdateView - context['appointments'] = [] - form_cls = forms.modelform_factory(Appointment, fields=['show_up']) - for session, appointment in self.object.get_appointments(): - form = form_cls(instance=appointment) - context['appointments'].append((session, appointment, form)) - - return context - class ParticipationAppointmentsUpdateView(ParticipationDetailMixin, UpdateView): template_name = 'execution/participation_appointments_form.html' @@ -254,34 +242,6 @@ class ParticipationAppointmentsUpdateView(ParticipationDetailMixin, UpdateView): return response -class ShowUpUpdateView(ParticipationMixin, UpdateView): - # Used by ParticipationAppointmentsView - - model = Appointment - fields = ['show_up'] - http_method_names = ['post'] - permission_required = 'recruitment.conduct_study' - study_status = [Study.EXECUTION] - participation_status = [Participation.INVITED] - - def get_object(self): - return get_object_or_404( - Appointment, - pk=self.kwargs['appointment_pk'], - participation=self.participation, - ) - - def get_success_url(self): - return reverse( - 'execution:participation-appointments', - args=[self.kwargs['study_pk'], self.kwargs['pk']], - ) - - def form_valid(self, form): - messages.success(self.request, _('Data has been saved.')) - return super().form_valid(form) - - class ResolveView(StudyMixin, PermissionRequiredMixin, FormView): template_name = 'execution/study_resolve.html' permission_required = 'recruitment.conduct_study' diff --git a/castellum/subjects/urls.py b/castellum/subjects/urls.py index bef050a53..5ad462950 100644 --- a/castellum/subjects/urls.py +++ b/castellum/subjects/urls.py @@ -32,7 +32,6 @@ from .views import MaintenanceConsentView from .views import MaintenanceContactView from .views import MaintenanceDuplicatesView from .views import MaintenanceNotesView -from .views import MaintenanceShowupView from .views import MaintenanceWaitingView from .views import ParticipationAddView from .views import ParticipationDeleteView @@ -60,7 +59,6 @@ urlpatterns = [ name='maintenance-duplicates', ), path('maintenance/waiting/', MaintenanceWaitingView.as_view(), name='maintenance-waiting'), - path('maintenance/showup/', MaintenanceShowupView.as_view(), name='maintenance-showup'), path('maintenance/notes/', MaintenanceNotesView.as_view(), name='maintenance-notes'), path('/', SubjectDetailView.as_view(), name='detail'), path('/delete/', SubjectDeleteView.as_view(), name='delete'), -- GitLab From 47039d230cc8910cdd18ecd32ae2913cb7da54dd Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:46:05 +0200 Subject: [PATCH 3/9] rm showup from calendar --- castellum/execution/views.py | 11 +---------- castellum/static/style.css | 4 ---- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/castellum/execution/views.py b/castellum/execution/views.py index 36bfeb54a..ce170a769 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -441,22 +441,13 @@ class CalendarView(StudyMixin, PermissionRequiredMixin, BaseCalendarView): tab = 'calendar' def render_appointment(self, appointment): - title = appointment.session.name - if appointment.show_up != Appointment.SHOWUP: - title = '{} ({})'.format(title, appointment.get_show_up_display()) - - class_names = [] - if appointment.show_up not in Appointment.SHOWUP_OK: - class_names.append('fullcalendar-muted') - return { - 'title': title, + 'title': appointment.session.name, 'start': appointment.start, 'end': appointment.end, 'url': reverse('execution:participation-detail', args=[ self.object.pk, appointment.participation.pk ]), - 'classNames': class_names, } def get_appointments(self): diff --git a/castellum/static/style.css b/castellum/static/style.css index 091a17d5a..a4579ca12 100644 --- a/castellum/static/style.css +++ b/castellum/static/style.css @@ -139,10 +139,6 @@ opacity: 1; } -.fullcalendar-muted { - opacity: 60%; -} - @media print { .alert { display: none !important; -- GitLab From 6bd36f2df0d8eab1a96f81a7a6e5c45805f19351 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:49:13 +0200 Subject: [PATCH 4/9] rm showup maintenance view --- .../templates/subjects/maintenance_base.html | 3 -- .../subjects/maintenance_showup.html | 36 ------------------- castellum/subjects/views.py | 16 --------- .../subjects/views/test_maintenance_views.py | 29 --------------- 4 files changed, 84 deletions(-) delete mode 100644 castellum/subjects/templates/subjects/maintenance_showup.html diff --git a/castellum/subjects/templates/subjects/maintenance_base.html b/castellum/subjects/templates/subjects/maintenance_base.html index 871581268..ea5ef3ad3 100644 --- a/castellum/subjects/templates/subjects/maintenance_base.html +++ b/castellum/subjects/templates/subjects/maintenance_base.html @@ -25,9 +25,6 @@ - diff --git a/castellum/subjects/templates/subjects/maintenance_showup.html b/castellum/subjects/templates/subjects/maintenance_showup.html deleted file mode 100644 index 394659307..000000000 --- a/castellum/subjects/templates/subjects/maintenance_showup.html +++ /dev/null @@ -1,36 +0,0 @@ -{% extends "subjects/maintenance_base.html" %} -{% load i18n bootstrap4 auth %} - -{% block title %}{% translate "Show up" %} · {{ block.super }}{% endblock %} - -{% block content %} -

{% translate 'The following subjects have a record of coming late or not at all:' %}

- -
    - {% for subject in object_list %} - {% has_privacy_level subject.privacy_level user as can_access %} -
  • -
    -
    - {% translate 'Last updated on' %}: {{ subject.updated_at|date }} -
    -
    -
    - {% if can_access %} - {% translate 'Details' %} - {% else %} - - {% endif %} -
    -
  • - {% empty %} - - {% endfor %} -
- - {% if is_paginated %} - - {% endif %} -{% endblock %} diff --git a/castellum/subjects/views.py b/castellum/subjects/views.py index 823930805..59e12c071 100644 --- a/castellum/subjects/views.py +++ b/castellum/subjects/views.py @@ -643,22 +643,6 @@ class MaintenanceWaitingView(BaseMaintenanceView): ) -class MaintenanceShowupView(BaseMaintenanceView): - template_name = 'subjects/maintenance_showup.html' - tab = 'showup' - - def get_queryset(self): - return ( - Subject.objects - .annotate_showup() - .filter( - to_be_deleted__isnull=True, - showup_score__gte=6, - ) - .order_by('-showup_score') - ) - - class MaintenanceNotesView(BaseMaintenanceView): template_name = 'subjects/maintenance_notes.html' tab = 'notes' diff --git a/tests/subjects/views/test_maintenance_views.py b/tests/subjects/views/test_maintenance_views.py index dbf1d334a..876265eb4 100644 --- a/tests/subjects/views/test_maintenance_views.py +++ b/tests/subjects/views/test_maintenance_views.py @@ -6,7 +6,6 @@ import pytest from freezegun import freeze_time from model_bakery import baker -from castellum.appointments.models import Appointment from castellum.contacts.models import Contact from castellum.subjects.models import Consent @@ -151,31 +150,3 @@ def test_maintenance_waiting_200(request, client, user_fixture): url = '/subjects/maintenance/waiting/' response = client.get(url) assert response.status_code == 200 - - -@pytest.mark.smoketest -@pytest.mark.parametrize('user_fixture', [ - pytest.param('study_coordinator', marks=pytest.mark.xfail(strict=True)), - pytest.param('recruiter', marks=pytest.mark.xfail(strict=True)), - 'subject_manager', - pytest.param('data_protection_coordinator', marks=pytest.mark.xfail(strict=True)), -]) -def test_maintenance_showup_200(request, client, user_fixture): - user = request.getfixturevalue(user_fixture) - client.force_login(user) - url = '/subjects/maintenance/showup/' - response = client.get(url) - assert response.status_code == 200 - - -def test_maintenance_showup(client, user, participation): - past = timezone.now() - baker.make(Appointment, show_up=Appointment.NOSHOW, participation=participation, start=past) - baker.make(Appointment, show_up=Appointment.NOSHOW, participation=participation, start=past) - baker.make(Appointment, show_up=Appointment.NOSHOW, participation=participation, start=past) - - client.force_login(user) - url = '/subjects/maintenance/showup/' - response = client.get(url) - assert response.status_code == 200 - assert response.content.count(b'"table-list-item"') == 1 -- GitLab From b699917617d187ea64f41071cc56ea48f0d2a0eb Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:51:04 +0200 Subject: [PATCH 5/9] rm showup from templates --- .../appointments/templatetags/appointments.py | 53 ------------------- .../templates/contacts/__contact.html | 12 +---- .../templates/execution/study_detail.html | 5 +- .../templates/subjects/subject_detail.html | 10 +--- .../templates/subjects/subject_export.html | 3 -- 5 files changed, 3 insertions(+), 80 deletions(-) delete mode 100644 castellum/appointments/templatetags/appointments.py diff --git a/castellum/appointments/templatetags/appointments.py b/castellum/appointments/templatetags/appointments.py deleted file mode 100644 index ed24a42e3..000000000 --- a/castellum/appointments/templatetags/appointments.py +++ /dev/null @@ -1,53 +0,0 @@ -# (c) 2018-2021 -# MPIB , -# MPI-CBS , -# MPIP -# -# This file is part of Castellum. -# -# Castellum is free software; you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Castellum is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with Castellum. If not, see -# . - -from django import template -from django.utils.translation import gettext_lazy as _ - -from castellum.appointments.models import Appointment - -register = template.Library() - - -@register.filter -def showup_level(subject): - subject.annotate_showup_stats() - - if subject.showup_score > 6: - return 'danger' - elif subject.showup_score > 2: - return 'warning' - else: - return 'success' - - -@register.filter -def showup_summary(subject): - subject.annotate_showup_stats() - - labelled = [] - for status, label in Appointment.SHOWUP_CHOICES: - count = getattr(subject, 'showup_{}'.format(status)) - if count: - labelled.append((label, count)) - - formatted = ', '.join('{}: {}'.format(label, count) for label, count in labelled) - return formatted or _('no appointments so far') diff --git a/castellum/contacts/templates/contacts/__contact.html b/castellum/contacts/templates/contacts/__contact.html index 0fc344e96..f42950614 100644 --- a/castellum/contacts/templates/contacts/__contact.html +++ b/castellum/contacts/templates/contacts/__contact.html @@ -1,4 +1,4 @@ -{% load i18n auth utils appointments %} +{% load i18n auth utils %} {% for guardian in subject.contact.guardians.all %} {% has_privacy_level guardian.subject.privacy_level user as can_access %} @@ -23,13 +23,3 @@ {% empty %} {% include 'contacts/__contact_detail.html' with contact=subject.contact %} {% endfor %} - -
-
{% translate "Show up rate" %}
-
- - {% with summary=subject|showup_summary %} - {% if summary %}({{ summary }}){% endif %} - {% endwith %} -
-
diff --git a/castellum/execution/templates/execution/study_detail.html b/castellum/execution/templates/execution/study_detail.html index fdd3840c1..3b6ea3254 100644 --- a/castellum/execution/templates/execution/study_detail.html +++ b/castellum/execution/templates/execution/study_detail.html @@ -1,5 +1,5 @@ {% extends "execution/study_base.html" %} -{% load i18n appointments utils %} +{% load i18n utils %} {% block content %}
    @@ -8,9 +8,6 @@ {% if can_access %}
    {{ participation.subject.contact.full_name }} - {% with summary=participation.subject|showup_summary %} - - {% endwith %} {% if session_count > 0 %} {% icon 'calendar' label=_('Appointments') %} diff --git a/castellum/subjects/templates/subjects/subject_detail.html b/castellum/subjects/templates/subjects/subject_detail.html index 41a7faf88..a1d9275f5 100644 --- a/castellum/subjects/templates/subjects/subject_detail.html +++ b/castellum/subjects/templates/subjects/subject_detail.html @@ -1,5 +1,5 @@ {% extends "subjects/subject_base.html" %} -{% load i18n bootstrap4 utils auth appointments %} +{% load i18n bootstrap4 utils auth %} {% block title %}{% translate "Subject details" %} · {{ block.super }}{% endblock %} @@ -47,14 +47,6 @@
    {% translate 'Attribute completeness' %}
    {{ attribute_completeness|default:'—' }}
    - -
    {% translate "Show up rate" %}
    -
    - - {% with summary=subject|showup_summary %} - {% if summary %}({{ summary }}){% endif %} - {% endwith %} -

{% translate 'Legal basis for data processing' %}

diff --git a/castellum/subjects/templates/subjects/subject_export.html b/castellum/subjects/templates/subjects/subject_export.html index 8ec32a618..df99e4257 100644 --- a/castellum/subjects/templates/subjects/subject_export.html +++ b/castellum/subjects/templates/subjects/subject_export.html @@ -208,9 +208,6 @@
{{ appointment|verbose_name:'reminded' }}
{{ appointment|display:'reminded' }}
- -
{{ appointment|verbose_name:'show_up' }}
-
{{ appointment|display:'show_up' }}
{% endfor %} {% endif %} -- GitLab From 568726823cc1410a22000ad2b739eaf3499226d7 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:58:21 +0200 Subject: [PATCH 6/9] rm rest of showup --- castellum/appointments/forms.py | 1 - castellum/execution/views.py | 9 +--- .../recruitment/models/participations.py | 8 +--- castellum/recruitment/views.py | 1 - castellum/subjects/models.py | 42 ------------------- tests/execution/views/test_views.py | 10 ++--- 6 files changed, 5 insertions(+), 66 deletions(-) diff --git a/castellum/appointments/forms.py b/castellum/appointments/forms.py index 5b8e473f7..371b9c29a 100644 --- a/castellum/appointments/forms.py +++ b/castellum/appointments/forms.py @@ -119,7 +119,6 @@ class AppointmentsForm(forms.ModelForm): self.appointment_changes.append((appointment.start, start)) appointment.start = start appointment.reminded = False - appointment.show_up = Appointment.SHOWUP # reset to default appointment.save() elif start: self.appointment_changes.append((None, start)) diff --git a/castellum/execution/views.py b/castellum/execution/views.py index ce170a769..7b83362f6 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -22,7 +22,6 @@ import logging import zipfile -from django import forms from django.contrib import messages from django.core.exceptions import ObjectDoesNotExist from django.db import models @@ -40,7 +39,6 @@ from django.views.generic import UpdateView from castellum.appointments.forms import AppointmentsForm from castellum.appointments.mixins import BaseCalendarView from castellum.appointments.mixins import send_appointment_notifications -from castellum.appointments.models import Appointment from castellum.castellum_auth.mixins import PermissionRequiredMixin from castellum.contacts.mixins import BaseContactUpdateView from castellum.pseudonyms.forms import DomainForm @@ -56,7 +54,6 @@ from castellum.studies.mixins import StudyMixin from castellum.studies.models import Study from castellum.subjects.mixins import BaseAdditionalInfoUpdateView from castellum.subjects.mixins import BaseDataProtectionUpdateView -from castellum.subjects.models import Subject from castellum.utils.mail import MailContext from .forms import NewsMailForm @@ -81,9 +78,7 @@ class StudyDetailView(StudyMixin, PermissionRequiredMixin, DetailView): participations = self.study.participation_set\ .with_appointment_count()\ .filter(status=Participation.INVITED)\ - .prefetch_related( - models.Prefetch('subject', queryset=Subject.objects.annotate_showup()) - ) + .prefetch_related('subject') for participation in participations: has_access = self.request.user.has_privacy_level(participation.subject.privacy_level) context['list'].append((participation, has_access)) @@ -475,7 +470,6 @@ class ProgressView(StudyMixin, PermissionRequiredMixin, ListView): 'appointment', filter=models.Q( appointment__participation__status=Participation.INVITED, - appointment__show_up__in=Appointment.SHOWUP_OK, ), distinct=True, ), @@ -483,7 +477,6 @@ class ProgressView(StudyMixin, PermissionRequiredMixin, ListView): 'appointment', filter=models.Q( appointment__participation__status=Participation.INVITED, - appointment__show_up__in=Appointment.SHOWUP_OK, appointment__start__lte=timezone.now(), ), distinct=True, diff --git a/castellum/recruitment/models/participations.py b/castellum/recruitment/models/participations.py index 1004fd2ab..19d703116 100644 --- a/castellum/recruitment/models/participations.py +++ b/castellum/recruitment/models/participations.py @@ -82,14 +82,8 @@ class ParticipationManager(models.Manager): ) def with_appointment_count(self): - from castellum.appointments.models import Appointment - return self.get_queryset().annotate( - appointment_count=models.Count( - 'appointment', - filter=models.Q(appointment__show_up__in=Appointment.SHOWUP_OK), - distinct=True, - ) + appointment_count=models.Count('appointment', distinct=True) ) diff --git a/castellum/recruitment/views.py b/castellum/recruitment/views.py index a732d1b53..87c7024bd 100644 --- a/castellum/recruitment/views.py +++ b/castellum/recruitment/views.py @@ -566,7 +566,6 @@ class SchedulerPingView(View): appointment_changes.append((appointment.start, start)) appointment.start = start appointment.reminded = False - appointment.show_up = Appointment.SHOWUP # reset to default appointment.save() elif start: appointment_changes.append((None, start)) diff --git a/castellum/subjects/models.py b/castellum/subjects/models.py index 75b20b5ca..866c2d68d 100644 --- a/castellum/subjects/models.py +++ b/castellum/subjects/models.py @@ -46,34 +46,6 @@ class TimeSlot(models.Model): return str(self.hour) -class SubjectQuerySet(models.QuerySet): - def annotate_showup(self): - from castellum.appointments.models import Appointment - - now = timezone.now() - weights = { - Appointment.SHOWUP: -1, - Appointment.LATE: 1, - Appointment.EXCUSED: 2, - Appointment.NOSHOW: 3, - } - - counts = {} - score = [] - for status, label in Appointment.SHOWUP_CHOICES: - key = 'showup_{}'.format(status) - counts[key] = models.Count( - 'participation__appointment', - filter=models.Q( - participation__appointment__show_up=status, - participation__appointment__start__lt=now, - ), - ) - score.append(models.F(key) * weights[status]) - - return self.annotate(**counts, showup_score=sum(score)) - - class Subject(TimeStampedModel): slug = models.CharField(_('Slug'), max_length=64, default=uuid_str, unique=True) @@ -156,8 +128,6 @@ class Subject(TimeStampedModel): not_available_until = DateTimeField(_("not available until"), blank=True, null=True) - objects = SubjectQuerySet.as_manager() - class Meta: verbose_name = _('Subject') permissions = [ @@ -263,18 +233,6 @@ class Subject(TimeStampedModel): else: return self.get_next_available_datetime(now) - def annotate_showup_stats(self): - from castellum.appointments.models import Appointment - - if hasattr(self, 'showup_score'): - return - - annotated = Subject.objects.annotate_showup().get(pk=self.pk) - self.showup_score = annotated.showup_score - for status, label in Appointment.SHOWUP_CHOICES: - key = 'showup_{}'.format(status) - setattr(self, key, getattr(annotated, key)) - def get_data(self): from castellum.recruitment.models import AttributeDescription diff --git a/tests/execution/views/test_views.py b/tests/execution/views/test_views.py index 5092f03e5..8b832c140 100644 --- a/tests/execution/views/test_views.py +++ b/tests/execution/views/test_views.py @@ -26,24 +26,20 @@ def test_study_detail_view(request, client, user_fixture, study_in_execution_sta def test_study_detail_view_appointment_count(client, member, study_in_execution_status): - session1 = baker.make(StudySession, study=study_in_execution_status) - session2 = baker.make(StudySession, study=study_in_execution_status) + session = baker.make(StudySession, study=study_in_execution_status) baker.make(StudySession, study=study_in_execution_status) participation = baker.make( Participation, status=Participation.INVITED, study=study_in_execution_status ) baker.make( - Appointment, participation=participation, session=session1, show_up=Appointment.SHOWUP - ) - baker.make( - Appointment, participation=participation, session=session2, show_up=Appointment.NOSHOW + Appointment, participation=participation, session=session ) client.force_login(member) url = '/execution/{}/'.format(study_in_execution_status.pk) response = client.get(url) print(response.content) - assert b'1/3' in response.content + assert b'1/2' in response.content @pytest.mark.smoketest -- GitLab From 50c2d9f08c88d4f6bb7f48aed8bb344b3eb6b081 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:58:36 +0200 Subject: [PATCH 7/9] rm showup model --- .../0003_remove_appointment_show_up.py | 17 +++++++++++++++++ castellum/appointments/models.py | 15 --------------- 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 castellum/appointments/migrations/0003_remove_appointment_show_up.py diff --git a/castellum/appointments/migrations/0003_remove_appointment_show_up.py b/castellum/appointments/migrations/0003_remove_appointment_show_up.py new file mode 100644 index 000000000..1d92588a8 --- /dev/null +++ b/castellum/appointments/migrations/0003_remove_appointment_show_up.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2 on 2021-05-04 07:31 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('appointments', '0002_status_wording'), + ] + + operations = [ + migrations.RemoveField( + model_name='appointment', + name='show_up', + ), + ] diff --git a/castellum/appointments/models.py b/castellum/appointments/models.py index 7bcc61ab4..e957cb78d 100644 --- a/castellum/appointments/models.py +++ b/castellum/appointments/models.py @@ -35,20 +35,6 @@ MINUTE = datetime.timedelta(seconds=60) class Appointment(models.Model): - SHOWUP = 1 - LATE = 2 - EXCUSED = 3 - NOSHOW = 4 - - SHOWUP_CHOICES = [ - (SHOWUP, _('no issues')), - (LATE, _('late')), - (EXCUSED, _('excused')), - (NOSHOW, _('no show')), - ] - - SHOWUP_OK = [SHOWUP, LATE] - session = models.ForeignKey(StudySession, verbose_name=_('Session'), on_delete=models.CASCADE) start = DateTimeField(_('Start')) reminded = models.BooleanField(_('Reminded'), default=False) @@ -57,7 +43,6 @@ class Appointment(models.Model): on_delete=models.CASCADE, verbose_name=_('Participation'), ) - show_up = models.SmallIntegerField(_('Show up'), default=SHOWUP, choices=SHOWUP_CHOICES) class Meta: verbose_name = _('Appointment') -- GitLab From 133d0e2a6b3fff785dfeeec815b06564af2007e6 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 09:41:26 +0200 Subject: [PATCH 8/9] rm ParticipationAppointmentsView --- .../execution/participation_appointments.html | 27 ------------------- castellum/execution/urls.py | 8 +----- castellum/execution/views.py | 5 ---- 3 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 castellum/execution/templates/execution/participation_appointments.html diff --git a/castellum/execution/templates/execution/participation_appointments.html b/castellum/execution/templates/execution/participation_appointments.html deleted file mode 100644 index 5394332da..000000000 --- a/castellum/execution/templates/execution/participation_appointments.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "execution/participation_base.html" %} -{% load i18n auth bootstrap4 utils %} - -{% block content %} -
- {% for session, appointment in object.get_appointments %} -
{{ session.name }}
-
- {% if appointment %} - - {% else %} - — - {% endif %} -
- {% empty %} -
-
{% translate 'No sessions' %}
- {% endfor %} -
- - {% has_perm 'appointments.change_appointment' user study as can_change_appointment %} - {% if can_change_appointment %} - - {% endif %} -{% endblock %} diff --git a/castellum/execution/urls.py b/castellum/execution/urls.py index 9bda872c7..c9c73d15a 100644 --- a/castellum/execution/urls.py +++ b/castellum/execution/urls.py @@ -32,7 +32,6 @@ from .views import ExclusionCriteriaView from .views import ExportView from .views import NewsMailView from .views import ParticipationAppointmentsUpdateView -from .views import ParticipationAppointmentsView from .views import ParticipationDetailView from .views import ParticipationNewsView from .views import ParticipationPseudonymsView @@ -74,13 +73,8 @@ urlpatterns = [ ), path( '//appointments/', - ParticipationAppointmentsView.as_view(), - name='participation-appointments', - ), - path( - '//appointments/update/', ParticipationAppointmentsUpdateView.as_view(), - name='participation-appointments-update', + name='participation-appointments', ), path( '//update-contact/', diff --git a/castellum/execution/views.py b/castellum/execution/views.py index 7b83362f6..c27cbe359 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -215,11 +215,6 @@ class ParticipationNewsView(ParticipationDetailMixin, UpdateView): return super().form_valid(form) -class ParticipationAppointmentsView(ParticipationDetailMixin, DetailView): - template_name = 'execution/participation_appointments.html' - tab = 'appointments' - - class ParticipationAppointmentsUpdateView(ParticipationDetailMixin, UpdateView): template_name = 'execution/participation_appointments_form.html' permission_required = ['recruitment.conduct_study', 'appointments.change_appointment'] -- GitLab From 412420c045328562812bd40596724311c0ecb9b9 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Tue, 4 May 2021 10:30:53 +0200 Subject: [PATCH 9/9] show success message after appointment save --- castellum/execution/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/castellum/execution/views.py b/castellum/execution/views.py index c27cbe359..f3d0ddb3b 100644 --- a/castellum/execution/views.py +++ b/castellum/execution/views.py @@ -229,6 +229,7 @@ class ParticipationAppointmentsUpdateView(ParticipationDetailMixin, UpdateView): def form_valid(self, form): response = super().form_valid(form) send_appointment_notifications(self.request, self.object, form.appointment_changes) + messages.success(self.request, _('Data has been saved.')) return response -- GitLab