Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/2.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed Apr 3, 2023
2 parents 8b2daa2 + 1d6edba commit dab0461
Show file tree
Hide file tree
Showing 19 changed files with 596 additions and 82 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,14 @@ docker-compose exec web pip install -r requirements.txt
### Permissions

The user belonging to backoffice group can be granted specific permissions:

- `view_private_form`, "Voir les demandes restreintes": allows the user to make requests that are not visible by standard user. Typically during the setup stage of a new form configuration
- `amend_submission`,"Traiter les demandes": allow the user the process (amend) the requests (fill the backoffice fields), require validation for other departments and print the documents
- `validate_submission`,"Valider les demandes": allow the user to fill the validation form
- `classify_submission`,"Classer les demandes" allow the user to accept/reject the requests if validations services have all accepted it
- `edit_submission`, "Éditer les demandes": allow the user to edit de requests filled by another person
- `amend_submission`, "Traiter les demandes": allow the user the process (amend) the requests (fill the backoffice fields), require validation for other departments and print the documents
- `validate_submission`, "Valider les demandes": allow the user to fill the validation form
- `classify_submission`, "Classer les demandes" allow the user to accept/reject the requests if validations services have all accepted it
- `edit_submission`, "Modifier les demandes": allow the user to edit the requests filled by another person
- `read_submission`, "Consulter les demandes": allow a trusted user to only read submissions without any other permission
- `edit_submission_validations`, "Modifier les validations": allow the pilot to edit the validation to correct spelling mistakes

### Two factor authentication

Expand Down
1 change: 1 addition & 0 deletions geocity/apps/accounts/permissions_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
AVAILABLE_FOR_INTEGRATOR_PERMISSION_CODENAMES = [
"read_submission",
"amend_submission",
"edit_submission_validations",
"validate_submission",
"classify_submission",
"edit_submission",
Expand Down
9 changes: 4 additions & 5 deletions geocity/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,10 @@ def to_representation(self, value):
values = {}
for field in validation._meta.fields:
values["validation_status"] = validation.get_validation_status_display()
if field.name in [
"comment_before",
"comment_during",
"comment_after",
]:
if (
field.name == "comment"
or field.name == "comment_is_visible_by_author"
):
values[field.name] = getattr(validation, field.name)

rep[validation.department.description] = values
Expand Down
13 changes: 13 additions & 0 deletions geocity/apps/core/static/js/submission_validations_edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Create a label to replace "readonly hidden select" readonly
window.addEventListener('load', function () {
var selects = document.querySelectorAll("select[readonly][hidden]");
for (select of selects) {
let elem = document.createElement('label');
let text = select.querySelector("option[selected]").text
let div = select.closest('.col-md-9');

elem.innerHTML = text;
elem.classList.add('col-form-label', 'bold');
div.appendChild(elem);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.1.7 on 2023-03-23 12:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("reports", "0022_alter_sectionparagraph_content"),
]

operations = [
migrations.AddField(
model_name="sectionhorizontalrule",
name="padding_top",
field=models.PositiveIntegerField(
default=0,
help_text="Espace vide au dessus afin de placer le texte au bon endroit (en pixels). Augmenter la valeur fait descendre le texte",
verbose_name="Espace vide au dessus",
),
),
]
2 changes: 2 additions & 0 deletions geocity/apps/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ class Meta:


class SectionHorizontalRule(Section):
padding_top = padding_top_field()

class Meta:
verbose_name = _("Ligne horizontale")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<div class="flex_container">
<div class="flex_item-100">
{% for service, validation in request_data.properties.validations.items %}
<h3>Validation: {{service}}</h3>
<span class="bold">Statut : </span>{{validation.validation_status}}<br>
<span class="bold">Commentaire (avant) : </span>{{validation.comment_before}}<br>
<span class="bold">Commentaire (pendant) : </span>{{validation.comment_during}}<br>
<span class="bold">Commentaire (après) : </span>{{validation.comment_after}}<br>
<h3>Validation: {{service}}</h3>
<span class="bold">Statut : </span>{{validation.validation_status}}<br>
{% if validation.comment_is_visible_by_author %}
<span class="bold">Commentaire : </span>{{validation.comment}}<br>
{% endif %}
{% endfor %}
</div>
</div>
Expand Down
22 changes: 16 additions & 6 deletions geocity/apps/submissions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,15 +1406,13 @@ class Meta:
model = models.SubmissionValidation
fields = [
"validation_status",
"comment_before",
"comment_during",
"comment_after",
"comment",
"comment_is_visible_by_author",
]
widgets = {
"validation_status": forms.RadioSelect(),
"comment_before": forms.Textarea(attrs={"rows": 3}),
"comment_during": forms.Textarea(attrs={"rows": 3}),
"comment_after": forms.Textarea(attrs={"rows": 3}),
"comment": forms.Textarea(attrs={"rows": 3}),
"comment_is_visible_by_author": forms.CheckboxInput(),
}

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -1896,3 +1894,15 @@ def get_submission_forms(submission):
]

return forms_infos


class SubmissionValidationsForm(forms.ModelForm):
class Meta:
model = models.SubmissionValidation
fields = ["department", "comment", "comment_is_visible_by_author"]

def __init__(self, *args, **kwargs):
super(SubmissionValidationsForm, self).__init__(*args, **kwargs)
if self.instance.id:
self.fields["department"].widget.attrs["readonly"] = True
self.fields["department"].widget.attrs["hidden"] = True
37 changes: 10 additions & 27 deletions geocity/apps/submissions/management/commands/fixturize.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,9 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
another_department = PermitDepartment.objects.get(
group__name=f"{entity}-validator"
)
comment_before_default = (
"Ce projet n'est pas admissible, veuillez l'améliorer.",
)
comment_during_default = ("Les améliorations ont été prise en compte.",)
comment_after_default = ("Excellent projet qui bénéficiera à la communauté.",)
comment = """Avant : Ce projet n'est pas admissible, veuillez l'améliorer.
Pendant : Les améliorations ont été prise en compte.
Après : Excellent projet qui bénéficiera à la communauté."""

for user_iteration in range(user_iterations):
username = f"{entity}-user-{user_iteration}"
Expand All @@ -473,9 +471,7 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
submission,
department,
validation_status,
comment_before_default,
comment_during_default,
comment_after_default,
comment,
)

# Submission to Classify with mixed objects requiring and not requiring validation document
Expand All @@ -490,9 +486,7 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
submission,
department,
validation_status,
comment_before_default,
comment_during_default,
comment_after_default,
comment,
)

# Submission to Classify with validation document required
Expand All @@ -506,9 +500,7 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
submission,
department,
validation_status,
comment_before_default,
comment_during_default,
comment_after_default,
comment,
)

# Submission to Classify with validation document required (with another Form)
Expand All @@ -522,9 +514,7 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
submission,
department,
validation_status,
comment_before_default,
comment_during_default,
comment_after_default,
comment,
)

# Submission with pending validations
Expand All @@ -550,16 +540,12 @@ def setup_submission(self, entity, user_iterations, administrative_entity, text)
department,
validation_status,
text,
text,
text,
)
self.create_submission_validation(
submission,
another_department,
validation_status,
text,
text,
text,
)

# Amend properties
Expand Down Expand Up @@ -831,6 +817,7 @@ def get_pilot_permissions(self):
secretariat_permissions = Permission.objects.filter(
codename__in=[
"amend_submission",
"edit_submission_validations",
"classify_submission",
],
content_type=self.submission_ct,
Expand Down Expand Up @@ -1018,17 +1005,13 @@ def create_submission_validation(
submission,
department,
validation_status=SubmissionValidation.STATUS_REQUESTED,
comment_before="",
comment_during="",
comment_after="",
comment="",
):
SubmissionValidation.objects.get_or_create(
submission=submission,
department=department,
validation_status=validation_status,
comment_before=comment_before,
comment_during=comment_during,
comment_after=comment_after,
comment=comment,
)

def create_submission_amend_field(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 4.1.7 on 2023-03-22 10:49

from django.db import migrations, models


def migrate_comments(apps, schema_editor):
"""
Put comment_before, comment_during and comment_after in 1 comment
"""
SubmissionValidation = apps.get_model("submissions", "SubmissionValidation")

validations = SubmissionValidation.objects.all().exclude(
comment_before__exact="", comment_during__exact="", comment_after__exact=""
)

# For each SubmissionValidation, squash comment_before comment_during comment_after in 1 comment
for validation in validations:
comment = f"""{validation.comment_before}
{validation.comment_during}
{validation.comment_after}"""

# save it in SubmissionValidation.comment
validation.comment = comment
validation.save()


class Migration(migrations.Migration):

dependencies = [
("submissions", "0015_alter_submission_options"),
]

operations = [
migrations.AddField(
model_name="historicalsubmissionvalidation",
name="comment",
field=models.TextField(
blank=True,
help_text="Information supplémentaire facultative transmise au requérant",
verbose_name="Commentaire",
),
),
migrations.AddField(
model_name="submissionvalidation",
name="comment",
field=models.TextField(
blank=True,
help_text="Information supplémentaire facultative transmise au requérant",
verbose_name="Commentaire",
),
),
migrations.RunPython(migrate_comments),
]
Loading

0 comments on commit dab0461

Please sign in to comment.