Skip to content

Commit

Permalink
Merge pull request #579 from DH-IT-Portal-Development/feature/3_small…
Browse files Browse the repository at this point in the history
…_issues

Feature/4 small issues
  • Loading branch information
EdoStorm96 authored Nov 20, 2023
2 parents 26991b0 + 75ab28a commit b46a24c
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 496 deletions.
Binary file modified locale/en/LC_MESSAGES/django.mo
Binary file not shown.
740 changes: 270 additions & 470 deletions locale/en/LC_MESSAGES/django.po

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,19 @@ def clean(self):
class ProposalDataManagementForm(SoftValidationMixin, forms.ModelForm):
class Meta:
model = Proposal
fields = ['avg_understood', 'dmp_file']
fields = ['privacy_officer', 'dmp_file']
widgets = {
'privacy_officer': forms.RadioSelect(choices=YES_NO),
}

def clean(self):
cleaned_data = super(ProposalDataManagementForm, self).clean()

_soft_validation_fields = ['avg_understood']
if cleaned_data['privacy_officer'] is None:
self.add_error(
'privacy_officer',
_('Dit veld is verplicht om verder te gaan.')
)

class ProposalUpdateDataManagementForm(forms.ModelForm):
class Meta:
Expand Down
8 changes: 6 additions & 2 deletions proposals/migrations/0034_auto_20211213_1503.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import django.db.models.deletion
import main.validators
import proposals.utils.proposal_utils
import proposals.validators

def AVGUnderstoodValidator():
'''This was formerly a validator, imported from proposals.validators,
but it is currently no longer required, so it has been removed.
To prevent an error, it has been replaced with this stub.'''
pass

class Migration(migrations.Migration):

Expand All @@ -18,7 +22,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='proposal',
name='avg_understood',
field=models.BooleanField(default=False, validators=[proposals.validators.AVGUnderstoodValidator], verbose_name='Ik heb kennis genomen van het bovenstaande en begrijp mijn verantwoordelijkheden ten opzichte van de AVG.'),
field=models.BooleanField(default=False, validators=[AVGUnderstoodValidator], verbose_name='Ik heb kennis genomen van het bovenstaande en begrijp mijn verantwoordelijkheden ten opzichte van de AVG.'),
),
migrations.AlterField(
model_name='proposal',
Expand Down
22 changes: 22 additions & 0 deletions proposals/migrations/0050_auto_20231116_1413.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.20 on 2023-11-16 13:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('proposals', '0049_alter_proposal_supervisor'),
]

operations = [
migrations.RemoveField(
model_name='proposal',
name='avg_understood',
),
migrations.AddField(
model_name='proposal',
name='privacy_officer',
field=models.BooleanField(blank=True, default=None, null=True, verbose_name='Ik heb mijn aanvraag en de documenten voor deelnemers besproken met de privacy officer.'),
),
]
11 changes: 5 additions & 6 deletions proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from main.models import YES, YES_NO_DOUBT
from main.validators import MaxWordsValidator, validate_pdf_or_doc
from .validators import AVGUnderstoodValidator
from .utils import available_urls, FilenameFactory, OverwriteStorage
from datetime import date, timedelta

Expand Down Expand Up @@ -399,11 +398,11 @@ class Proposal(models.Model):
blank=True,
)

avg_understood = models.BooleanField(
_('Ik heb kennis genomen van het bovenstaande en begrijp mijn verantwoordelijkheden ten opzichte van de AVG.'),
default=False,
null=False,
validators=[AVGUnderstoodValidator],
privacy_officer = models.BooleanField(
_('Ik heb mijn aanvraag en de documenten voor deelnemers besproken met de privacy officer.'),
default=None,
null=True,
blank=True,
)

dmp_file = models.FileField(
Expand Down
4 changes: 2 additions & 2 deletions proposals/templates/proposals/proposal_pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@

{% block page_header %}
<div id="page-header">
{% blocktrans with title=proposal.title reference_number=proposal.reference_number submitter=proposal.created_by.get_full_name trimmed %}
FETC-GW - <em>{{ title }}</em> (referentienummer {{ reference_number }}, ingediend door {{ submitter }})
{% blocktrans with title=proposal.title reference_number=proposal.reference_number submitter=proposal.created_by.get_full_name reviewing_committee=proposal.reviewing_committee.name trimmed %}
FETC-GW - <em>{{ title }}</em> (referentienummer {{reviewing_committee}}-{{ reference_number }}, ingediend door {{ submitter }})
{% endblocktrans %}
{% if proposal.is_revision %}
<br>
Expand Down
2 changes: 1 addition & 1 deletion proposals/utils/pdf_diff_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ class DMPFileSection(PageBreakMixin, BaseSection):

section_title = _("Data Management Plan")

row_fields = ["dmp_file"]
row_fields = ["dmp_file", "privacy_officer"]


class EmbargoSection(BaseSection):
Expand Down
9 changes: 0 additions & 9 deletions proposals/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,3 @@ def __call__(self, value):
if qs.exists():
raise forms.ValidationError(_('Er bestaat al een aanvraag met deze '
'titel.'), code='unique')


def AVGUnderstoodValidator(value):

if value != True:
raise forms.ValidationError(
_('Je dient kennis genomen te hebben van de AVG om jouw aanvraag in '
'te dienen'), code='avg'
)
32 changes: 32 additions & 0 deletions reviews/migrations/0013_add_is_committee_review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.2.20 on 2023-11-16 13:01

from django.db import migrations, models

def update_is_committee_review(apps, schema_editor):

Review = apps.get_model('reviews', 'Review')

for review in Review.objects.all():
#Hardcoded these to account for possible future changes to stages
SUPERVISOR_STAGE = 0
CLOSED_STAGE = 4
if review.stage == SUPERVISOR_STAGE:
review.is_committee_review = False
if review.go:
review.stage = CLOSED_STAGE
review.save()

class Migration(migrations.Migration):

dependencies = [
('reviews', '0012_auto_20211213_1503'),
]

operations = [
migrations.AddField(
model_name='review',
name='is_committee_review',
field=models.BooleanField(default=True),
),
migrations.RunPython(update_is_committee_review),
]
7 changes: 6 additions & 1 deletion reviews/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Review(models.Model):
date_end = models.DateTimeField(blank=True, null=True)
date_should_end = models.DateField(blank=True, null=True)

is_committee_review = models.BooleanField(
default=True
)

proposal = models.ForeignKey(Proposal, on_delete=models.CASCADE)

def update_go(self, last_decision=None):
Expand All @@ -89,7 +93,7 @@ def update_go(self, last_decision=None):
self.save()

# For a supervisor review:
if self.stage == self.SUPERVISOR:
if self.is_committee_review == False:
# Update the status of the Proposal with the end date
self.proposal.date_reviewed_supervisor = self.date_end
self.proposal.save()
Expand All @@ -99,6 +103,7 @@ def update_go(self, last_decision=None):
# in an uWSGI environment, in which it errors.
from reviews.utils import start_assignment_phase
start_assignment_phase(self.proposal)
self.stage = self.CLOSED
# On NO-GO, reset the Proposal status
else:
# See comment above
Expand Down
4 changes: 2 additions & 2 deletions reviews/templates/reviews/review_detail_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h3>
</li>
{% if review.proposal.supervisor %}
<li>
{% trans "Supervisor" %}: {{ review.proposal.supervisor }}
{% trans "Supervisor" %}: {{ review.proposal.supervisor.get_full_name }}
</li>
{% endif %}
<li>
Expand Down Expand Up @@ -90,7 +90,7 @@ <h3>
</em>
</li>
{% endif %}
{% if review.stage == review.SUPERVISOR %}
{% if not review.is_committee_review %}
<li>
<strong>
{% blocktrans trimmed %}
Expand Down
3 changes: 3 additions & 0 deletions reviews/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def test_start_supervisor_review(self):
# If the Relation on a Proposal requires a supervisor, a Review for the supervisor should be started.
review = start_review(self.proposal)
self.assertEqual(review.stage, Review.SUPERVISOR)
self.assertEqual(review.is_committee_review, False)
self.assertEqual(Decision.objects.filter(reviewer=self.supervisor).count(), 1)
self.assertEqual(Decision.objects.filter(review=review).count(), 1)
self.assertEqual(review.decision_set.count(), 1)
Expand All @@ -170,6 +171,7 @@ def test_start_review(self):

review = start_review(self.proposal)
self.assertEqual(review.stage, Review.ASSIGNMENT)
self.assertEqual(review.is_committee_review, True)
self.assertEqual(Decision.objects.filter(reviewer=self.secretary).count(), 1)
self.assertEqual(Decision.objects.filter(review=review).count(), 1)
self.assertEqual(review.decision_set.count(), 1)
Expand All @@ -196,6 +198,7 @@ def test_decision_supervisor(self):
decision.save()
review.refresh_from_db()
self.assertEqual(review.go, True)
self.assertEqual(review.is_committee_review, False)

self.assertEqual(len(mail.outbox), 2)
self.check_subject_lines(mail.outbox)
Expand Down
1 change: 1 addition & 0 deletions reviews/utils/review_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def start_supervisor_phase(proposal):
"""
review = Review.objects.create(proposal=proposal, date_start=timezone.now())
review.stage = Review.SUPERVISOR
review.is_committee_review = False
review.save()

proposal.date_submitted_supervisor = timezone.now()
Expand Down
2 changes: 1 addition & 1 deletion reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def form_valid(self, form):

# Don't notify the secretary if this is a supervisor decision.
# If it was a GO they the secretary will be notified anyway
if not review.stage == review.SUPERVISOR:
if review.is_committee_review:
notify_secretary(form.instance)

return super(DecisionUpdateView, self).form_valid(form)

0 comments on commit b46a24c

Please sign in to comment.