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

Release/3.1.0 #866

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0f80608
Merge tag 'v3.0.2' into develop
AlexandreJunod Jun 30, 2023
7df2a67
Add API name in fixturize (#851)
rbovard Jun 30, 2023
375d4f0
wip
monodo Jul 4, 2023
6d815ed
sip
monodo Jul 4, 2023
59cc38a
lint
monodo Jul 4, 2023
d5c5c0c
handle file type from field value, add field to admin and toggle visi…
monodo Jul 4, 2023
9f6d544
inform intergrator if field extensions at field level are not aligned…
monodo Jul 4, 2023
ea6cc78
write test
monodo Jul 4, 2023
dc8929d
add contact type (#852)
monodo Jul 4, 2023
9921984
Merge remote-tracking branch 'origin/develop' into feature/YC-1126
monodo Jul 4, 2023
e25dfc8
fix test
monodo Jul 4, 2023
e1312b8
new tab for admin link
monodo Jul 5, 2023
f2ed485
better info for user
monodo Jul 5, 2023
8a3e196
fix test
monodo Jul 5, 2023
4ad4bac
remove comment & print
monodo Jul 5, 2023
c0accd9
Add a custom filter to format API date in jinja print output
rbovard Jul 7, 2023
a5ca0ec
Bump certifi from 2022.12.7 to 2023.7.22 in /services/pdf
dependabot[bot] Jul 25, 2023
6cf0ba3
Merge pull request #855 from yverdon/feature/yc-1135
rbovard Aug 2, 2023
477b89b
update all
monodo Aug 3, 2023
583bc68
Get submission_id instead of submission_id index
rbovard Aug 4, 2023
54d8061
Merge pull request #860 from yverdon/feature/yc-1139
rbovard Aug 8, 2023
2f04fa7
Send submission/user infos to PostFinance
rbovard Aug 15, 2023
08fe68e
Rename variable
rbovard Aug 15, 2023
fa75e1f
Add migration
rbovard Aug 15, 2023
0c59d7e
Merge pull request #862 from yverdon/feature/yc-1138
rbovard Aug 16, 2023
3cac76c
Display forms related to the current field
rbovard Aug 22, 2023
af0d1ee
Display `—` if no related forms
rbovard Aug 22, 2023
dada93c
Add link to related form
rbovard Aug 23, 2023
b2821a1
YC-1136 (#859)
AlexandreJunod Aug 24, 2023
716a693
change timezone in serializers
AlexandreJunod Aug 24, 2023
6683f6a
update and adapt for constance changes
monodo Aug 24, 2023
4d8c5b2
rename serializer
AlexandreJunod Aug 24, 2023
fbc254e
Merge pull request #853 from yverdon/feature/YC-1126
AlexandreJunod Aug 24, 2023
1dee1e4
Merge pull request #858 from yverdon/feature/update-libs-08
AlexandreJunod Aug 24, 2023
57f34ee
Merge pull request #864 from yverdon/feature/yc-1151
AlexandreJunod Aug 24, 2023
9871fc5
Merge pull request #856 from yverdon/dependabot/pip/services/pdf/cert…
AlexandreJunod Aug 24, 2023
c0d4a95
Add short URL parameter to access a form
Aug 7, 2023
7ca7caf
Add test for short URL parameter
Aug 10, 2023
740032a
Fix #861: name of quick access slug GET parameter
Aug 21, 2023
a49b6e4
Fix #861: help text for quick access slug field
Aug 21, 2023
21935a4
Fix #861: fix help text and add missing migration
Aug 23, 2023
5743ba4
change 2fa message on token step
AlexandreJunod Aug 24, 2023
9a00c90
rebase and squash migrations
AlexandreJunod Aug 24, 2023
b038327
Merge pull request #861 from yverdon/feature/yg-733-specific-form-filter
AlexandreJunod Aug 24, 2023
10c9de9
Fix 2FA message
rbovard Aug 24, 2023
ef29478
Merge pull request #865 from yverdon/feature/fix-2fa-message
rbovard Aug 24, 2023
b1d6312
make is_single_form_submissions default=true
AlexandreJunod Aug 28, 2023
276d7d5
try to change TextField to UUIDField
AlexandreJunod Aug 28, 2023
0ced1f6
Merge branch 'develop' of https://github.com/yverdon/geocity into dev…
AlexandreJunod Aug 28, 2023
b2636ad
show shortname of groups
AlexandreJunod Aug 28, 2023
0aed67f
squash migrations
AlexandreJunod Aug 28, 2023
8d0c8a5
fix Code scanning / CodeQL
AlexandreJunod Aug 28, 2023
8b8501c
change factory to fix tests that were using is_single_form_submissions
AlexandreJunod Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion geocity/admin_jazzmin_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"constance.Config": "fas fa-cogs",
"django_cron.CronJobLog": "fas fa-tasks",
"forms.AdministrativeEntityForAdminSite": "fas fa-landmark",
"forms.ContactTypeForAdminSite": "fas fa-address-card",
"forms.ContactFormForAdminSite": "fas fa-address-card",
"forms.ContactTypeForAdminSite": "fas fa-hard-hat",
"forms.PaymentSettings": "fas fa-shopping-cart",
"forms.Price": "fas fa-coins",
"forms.Field": "fas fa-list-ol",
Expand Down
1 change: 1 addition & 0 deletions geocity/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ class DepartmentAdminForm(forms.ModelForm):
class Meta:
model = models.PermitDepartment
fields = [
"shortname",
"description",
"administrative_entity",
"is_validator",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.4 on 2023-08-28 08:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("accounts", "0013_permitdepartment_generic_email_and_more"),
]

operations = [
migrations.AlterField(
model_name="administrativeentity",
name="is_single_form_submissions",
field=models.BooleanField(
default=True,
help_text="Nécessaire pour l'utilisation du système de paiement en ligne",
verbose_name="Autoriser uniquement un objet par demande",
),
),
migrations.AlterField(
model_name="permitdepartment",
name="shortname",
field=models.CharField(
blank=True,
help_text="Nom affiché par défaut dans les différentes étapes du formulaire, ne s'affiche pas dans l'admin (max. 100 caractères)",
max_length=100,
verbose_name="nom court",
),
),
]
8 changes: 4 additions & 4 deletions geocity/apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ class PermitDepartment(models.Model):
description = models.CharField(_("description"), max_length=100, default="Service")
shortname = models.CharField(
_("nom court"),
max_length=32,
max_length=100,
help_text=_(
"Nom affiché par défaut dans les différentes étapes du formulaire, ne s'affiche pas dans l'admin (max. 32 caractères)"
"Nom affiché par défaut dans les différentes étapes du formulaire, ne s'affiche pas dans l'admin (max. 100 caractères)"
),
blank=True,
)
Expand Down Expand Up @@ -202,7 +202,7 @@ class Meta:
)

def __str__(self):
return str(self.group)
return self.shortname if self.shortname else self.group.name


class AdministrativeEntityQuerySet(models.QuerySet):
Expand Down Expand Up @@ -295,7 +295,7 @@ class AdministrativeEntity(models.Model):
)
is_single_form_submissions = models.BooleanField(
_("Autoriser uniquement un objet par demande"),
default=False,
default=True,
help_text=_("Nécessaire pour l'utilisation du système de paiement en ligne"),
)

Expand Down
2 changes: 1 addition & 1 deletion geocity/apps/accounts/permissions_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"form",
"field",
"formfield",
"contacttypeforadminsite",
"contactformforadminsite",
"paymentsettings",
"price",
"formprice",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3>{% translate "Mon compte" %}</h3>
<label class="col-md-3 col-form-label" for="id_chk_accept_policy">{% translate "Conditions d'utilisation" %}</label>
<div class="col-md-9 login-policy">
<input type="checkbox" id="chk_accept_policy" name="chk_accept_policy">
<label for="chk_accept_policy">{% translate "J'ai lu et accepte les" %} <b><a href="{{config.GENERAL_CONDITIONS_URL}}" target="_blank" rel="noreferrer">{% translate "conditions d'utilisation" %}</a></b> {% translate "et la" %} <b><a href="{{config.PRIVACY_POLICY_URL}}" target="_blank" rel="noreferrer">{% translate "politique de confidentialité" %}</a></b>.</label><br>
<label for="chk_accept_policy">{% translate "J'ai lu et accepte les" %} <b><a href="{{config.GENERAL_CONDITIONS_URL}}" target="_blank" rel="noreferrer">{% translate "conditions d'utilisation de Geocity" %}</a></b> {% translate "et la" %} <b><a href="{{config.PRIVACY_POLICY_URL}}" target="_blank" rel="noreferrer">{% translate "politique de confidentialité" %}</a></b>.</label><br>
</div>
</div>
{% bootstrap_button "Confirmer" button_type="submit" id="user_profile_edit" button_class="btn-primary mr-3" value="Enregistrer" name="disabled"%}
Expand Down
2 changes: 1 addition & 1 deletion geocity/apps/accounts/templates/two_factor/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h4>{% translate "Connexion" %}</h4>
</div>
{% include "registration/_social_login.html" %}
{% elif wizard.steps.current == 'token' %}
<p>{% translate "Veuillez entrer votre jeton (code à usage unique, code SMS)" %}</p>
<p>{% translate "Veuillez entrer votre jeton (code à usage unique), qui se trouve dans votre application d'authentification (Authenticator, Duo, LastPass, etc.) ou transmis par SMS." %}</p>
<form method="post" action="">
{% csrf_token %}
{% include "two_factor/_wizard_forms.html" %}
Expand Down
41 changes: 26 additions & 15 deletions geocity/apps/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from collections import OrderedDict
from datetime import timedelta
from datetime import timedelta, timezone

from django.contrib.gis.geos import GEOSGeometry
from django.db.models import Max, Min
Expand Down Expand Up @@ -305,7 +305,7 @@ def to_representation(self, instance):
class Meta:
model = PostFinanceTransaction
fields = (
"merchant_reference",
"transaction_id",
"amount",
"currency",
"creation_date",
Expand Down Expand Up @@ -392,15 +392,23 @@ def to_representation(self, value):
rep = {}
for submission_contact in value.submission_contacts.select_related("contact"):
contact_object = {
"contact_type_display": submission_contact.get_contact_type_display()
"contact_form_display": submission_contact.contact_form.name
}
for field in submission_contact.contact._meta.fields:
contact_object[field.name] = getattr(
submission_contact.contact, field.name
)
rep[
convert_string_to_api_key(submission_contact.get_contact_type_display())
] = contact_object
if (
not convert_string_to_api_key(submission_contact.contact_form.name)
in rep
):
rep[
convert_string_to_api_key(submission_contact.contact_form.name)
] = list()

rep[convert_string_to_api_key(submission_contact.contact_form.name)].append(
contact_object
)

return rep

Expand Down Expand Up @@ -548,18 +556,21 @@ def to_representation(self, value):
GEOSGeometry(aggregated_geotime_qs["singlegeom"]).json
)

local_tz = timezone(timedelta(hours=2))
geotime_aggregated = {}
geotime_aggregated["start_date"] = (
aggregated_geotime_qs["submission_geo_time_start_date"].strftime(
"%d.%m.%Y %H:%M"
)
aggregated_geotime_qs["submission_geo_time_start_date"]
.replace(tzinfo=timezone.utc)
.astimezone(local_tz)
.strftime("%d.%m.%Y %H:%M")
if aggregated_geotime_qs["submission_geo_time_start_date"]
else ""
)
geotime_aggregated["end_date"] = (
aggregated_geotime_qs["submission_geo_time_end_date"].strftime(
"%d.%m.%Y %H:%M"
)
aggregated_geotime_qs["submission_geo_time_end_date"]
.replace(tzinfo=timezone.utc)
.astimezone(local_tz)
.strftime("%d.%m.%Y %H:%M")
if aggregated_geotime_qs["submission_geo_time_end_date"]
else ""
)
Expand All @@ -585,7 +596,7 @@ def to_representation(self, value):
# Override of real ListSerializer from django-rest-framework-gis
# If you want to add a new structure with dynamic values, just add it to OrderedDict and give him a new function like "super().prefix_to_representation(data)"
# Then in SubmissionPrintSerializer write this class like the existant "to_representation"
class SubmissionPrintListSerialier(gis_serializers.ListSerializer):
class SubmissionPrintListSerializer(gis_serializers.ListSerializer):
@property
def data(self):
return super(gis_serializers.ListSerializer, self).data
Expand Down Expand Up @@ -629,7 +640,7 @@ class SubmissionPrintSerializer(gis_serializers.GeoFeatureModelSerializer):

def get_creditor_type(self, obj):
if obj.creditor_type is not None:
creditor = obj.get_creditor_type_display()
creditor = obj.creditor_type.name
elif obj.author:
creditor = (
_("Auteur de la demande, ")
Expand Down Expand Up @@ -678,7 +689,7 @@ def many_init(cls, *args, **kwargs):
)
meta = getattr(cls, "Meta", None)
list_serializer_class = getattr(
meta, "list_serializer_class", SubmissionPrintListSerialier
meta, "list_serializer_class", SubmissionPrintListSerializer
)
return list_serializer_class(*args, **list_kwargs)

Expand Down
14 changes: 14 additions & 0 deletions geocity/apps/core/static/js/admin/form_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ document.addEventListener('DOMContentLoaded', function() {
const requiredClass = 'required';
const inputType = document.getElementById('id_input_type').value;

const allowedFileElement = document.getElementById('id_allowed_file_types');
const allowedFileRowElement = allowedFileElement.closest('.form-group');
const allowedFileLabelElement = allowedFileRowElement.querySelector('label');
const isAllowedFileVisible = inputType === 'file';

const choicesElement = document.getElementById('id_choices');
const choicesRowElement = choicesElement.closest('.form-group');
const choicesLabelElement = choicesRowElement.querySelector('label');
Expand Down Expand Up @@ -63,6 +68,10 @@ document.addEventListener('DOMContentLoaded', function() {

const isFileVisible = inputType === 'file_download';

allowedFileElement.removeAttribute('required');
allowedFileRowElement.classList.add(hiddenClass);
allowedFileLabelElement.classList.remove(requiredClass);

choicesElement.removeAttribute('required');
choicesRowElement.classList.add(hiddenClass);
choicesLabelElement.classList.remove(requiredClass);
Expand Down Expand Up @@ -97,6 +106,11 @@ document.addEventListener('DOMContentLoaded', function() {
choicesRowElement.classList.remove(hiddenClass);
choicesLabelElement.classList.add(requiredClass);
}
else if (isAllowedFileVisible) {
allowedFileElement.setAttribute('required', '');
allowedFileRowElement.classList.remove(hiddenClass);
allowedFileLabelElement.classList.add(requiredClass);
}
else if (isRegexPatternVisible) {
regexElement.setAttribute('required', '');
regexRowElement.classList.remove(hiddenClass);
Expand Down
27 changes: 22 additions & 5 deletions geocity/apps/core/static/js/submission_contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,33 @@ let update_form_value = function(item, userprofile) {
}
}

// Create a label to replace "readonly hidden select" readonly
// Create a label to replace .form-control without .extra-form in classes inside of forms-container
window.addEventListener('load', function () {
var selects = document.querySelectorAll("select[readonly][hidden]");
for (select of selects) {
var forms_control = document.querySelectorAll("[id=forms-container] select[class=form-control]");
for (form_control of forms_control) {
let elem = document.createElement('label');
let text = select.querySelector("option[selected]").text
let div = select.closest('.col-md-9');
let text = form_control.querySelector("option[selected]").text
let div = form_control.closest('.col-md-9');

elem.innerHTML = text;
elem.classList.add('col-form-label', 'bold');
div.appendChild(elem);
}

// Hide .extra-form and show first hidden .extra-form on click of .show-extra-form
var extra_forms = document.querySelectorAll("[id=forms-container] select.form-control.extra-form");
for (extra_form of extra_forms) {
let form = extra_form.closest("[class=contact-form]")
form.setAttribute("hidden", true)
}

// addEventListener for button .show-extra-form
var button = document.querySelector("button.show-extra-form");
button.addEventListener("click", (event) => {
var hidden_extra_forms = document.querySelector(".contact-form[hidden]")
if (hidden_extra_forms == null){
document.getElementById('contact-alert').style.display = "block"
}
hidden_extra_forms.removeAttribute("hidden")
});
});
6 changes: 3 additions & 3 deletions geocity/apps/core/templates/base_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{% if config.ENABLE_GEOCALENDAR %}
<li class="nav-item d-flex align-items-center">
<a href="{{ config.GEOCALENDAR_URL }}" target="_blank" rel="noreferrer" role="button">
<i class="fa fa-calendar aria-hidden="true"></i>
<i class="fa fa-calendar" aria-hidden="true"></i>
{% translate "Calendrier" %}
</a>
</li>
Expand Down Expand Up @@ -113,7 +113,7 @@
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
{% if user.is_staff %}
<a class="dropdown-item" href="{% url 'admin:index' %}">{% translate "Interface d'administration" %}</a>
<a class="dropdown-item" href="{% url 'admin:index' %}" target="_blank" rel="noreferrer">{% translate "Interface d'administration" %}</a>
<div class="dropdown-divider"></div>
{% endif %}
<a class="dropdown-item" href="{% url 'accounts:user_profile_edit' %}">{% translate "Gérer mon compte" %}</a>
Expand All @@ -138,7 +138,7 @@
<ul class="navbar-nav d-flex d-md-none">
{% if user.is_staff %}
<li class="nav-item">
<a class="nav-link" href="{% url 'admin:index' %}">{% translate "Interface d'administration" %}</a>
<a class="nav-link" href="{% url 'admin:index' %}" target="_blank" rel="noreferrer">{% translate "Interface d'administration" %}</a>
</li>
<div class="dropdown-divider"></div>
{% endif %}
Expand Down
Loading
Loading