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.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed Apr 20, 2023
2 parents ce8c9de + 6a90cbe commit 16af9ef
Show file tree
Hide file tree
Showing 40 changed files with 23,762 additions and 5,684 deletions.
101 changes: 79 additions & 22 deletions geocity/apps/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.db.models import Q
from django.shortcuts import get_object_or_404, redirect
from django.urls import path, reverse
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from knox.models import AuthToken

Expand All @@ -25,6 +26,43 @@
"Un utilisateur ne peut être membre que d'un seul groupe 'Intégrateur'"
)

LEGAL_TEXT_EXAMPLE = """
<h5>Exemple de texte relatif à la protection des données</h5>
<hr>
<p><b>Les informations à fournir selon l'art. 13 LPrD sont:</b></p>
<ul>
<li>
<b>Identité du responsable du traitement :</b><br>
<i>ex: <Service communal> ([email protected], +41 00 000 00 00)</i>
</li>
<li>
<b>Finalités du traitement pour lesquels les données sont collectées :</b><br>
<i>
ex: La date de naissance est collectée dans le but de distinguer les éventuels homonymes.<br>
ex: Les données financières sont collectées dans le but de procéder à un éventuel remboursement.
</i>
</li>
<li>
<b>Catégories des destinataires des données :</b><br>
<i>
ex: Les données ne sont pas communiquées en dehors du <Service communal>, sauf accord de la personne concernée par le biais du présent formulaire.
</i>
</li>
<li>
<b>Droit d'accès :</b><br>
<i>
ex: Vous avez en tout temps le droit de demander l'accès à vos données personnelles auprès du responsable du traitement en application des art. 25 et suivants LPrD.
</i>
</li>
<li>
<b>Possibilité de refuser de fournir les données et les conséquences :</b><br>
<i>
ex: En cas de refus de fournir les données financières, aucun remoursement ne pourra être effectué.
</i>
</li>
</ul>
"""

# Allow a user belonging to integrator group to see only objects created by this group
def filter_for_user(user, qs):
if not user.is_superuser:
Expand Down Expand Up @@ -436,20 +474,28 @@ class GroupAdmin(admin.ModelAdmin):
list_display = [
"__str__",
"get__integrator",
"get__is_integrator",
"get__is_validator",
"get__is_default_validator",
"get__is_backoffice",
"get__mandatory_2fa",
# FIXME: Causes a crash on prod
# "get__forms_number",
# "get__sites_number",
"get__administrative_entity",
"get__forms_number",
"get__sites_number",
]

filter_horizontal = ("permissions",)
search_fields = [
"name",
]

@admin.display(boolean=True)
def get__is_integrator(self, obj):
return obj.permit_department.is_integrator_admin

get__is_integrator.admin_order_field = "permit_department__is_integrator_admin"
get__is_integrator.short_description = _("Intégrateur")

@admin.display(boolean=True)
def get__is_validator(self, obj):
return obj.permit_department.is_validator
Expand Down Expand Up @@ -486,18 +532,29 @@ def get__mandatory_2fa(self, obj):
get__mandatory_2fa.admin_order_field = "permit_department__mandatory_2fa"
get__mandatory_2fa.short_description = _("2FA obligatoire")

# FIXME: Causes a crash on prod
# def get__forms_number(self, obj):
# if obj.permit_department.is_integrator_admin:
# return obj.permit_department.administrative_entity.forms.count()
def get__administrative_entity(self, obj):
if (
obj.permit_department.is_integrator_admin
and obj.permit_department.administrative_entity
):
return obj.permit_department.administrative_entity

get__administrative_entity.short_description = _("Entité administrative")

# get__forms_number.short_description = _("Nombre de formulaires")
def get__forms_number(self, obj):
if (
obj.permit_department.is_integrator_admin
and obj.permit_department.administrative_entity
):
return obj.permit_department.administrative_entity.forms.count()

# def get__sites_number(self, obj):
# if obj.permit_department.is_integrator_admin:
# return obj.site_profiles.count()
get__forms_number.short_description = _("Nombre de formulaires")

# get__sites_number.short_description = _("Nombre de sites")
def get__sites_number(self, obj):
if obj.permit_department.is_integrator_admin and obj.site_profiles:
return obj.site_profiles.count()

get__sites_number.short_description = _("Nombre de sites")

def get_queryset(self, request):

Expand Down Expand Up @@ -629,13 +686,7 @@ class Meta:
}

class Media:
js = ("https://code.jquery.com/jquery-3.5.1.slim.min.js",)
css = {
"all": (
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
"css/admin/admin.css",
)
}
css = {"all": ("css/admin/admin.css",)}

def clean(self):
signature_sheet = self.cleaned_data["signature_sheet"]
Expand Down Expand Up @@ -696,9 +747,15 @@ class AdministrativeEntityAdmin(IntegratorFilterMixin, admin.ModelAdmin):
"directive_description",
"additional_information",
),
"description": _(
"""Saisir ici les directives et informations obligatoires concernant la protection des données personnelles
ayant une portée globale pour toute l'entité administrative. Pour une gestion plus fine, ces informations peuvent être saisies à l'étape 1.4 Formulaires"""
"description": format_html(
f"""
<p>
Saisir ici les directives et informations obligatoires concernant la protection des données personnelles
ayant une portée globale pour toute l'entité administrative. Pour une gestion plus fine, ces informations peuvent être saisies à l'étape 1.4 Formulaires
</p>
<hr>
{LEGAL_TEXT_EXAMPLE}
"""
),
},
),
Expand Down
18 changes: 15 additions & 3 deletions geocity/apps/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ def clean_email(self):
def clean(self):
cleaned_data = super().clean()

if not "username" in cleaned_data:
raise forms.ValidationError({"username": ""})

if not "first_name" in cleaned_data:
raise forms.ValidationError({"first_name": ""})

if not "last_name" in cleaned_data:
raise forms.ValidationError({"last_name": ""})

if not "email" in cleaned_data:
raise forms.ValidationError({"email": ""})

for reserved_usernames in (
settings.TEMPORARY_USER_PREFIX,
settings.ANONYMOUS_USER_PREFIX,
Expand Down Expand Up @@ -147,6 +159,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if create:
self.fields["notify_per_email"].disabled = True
else:
self.fields.pop("captcha")

required_css_class = "required"
address = forms.CharField(
Expand Down Expand Up @@ -185,9 +199,7 @@ class Meta:

help_texts = {
"vat_number": 'Trouvez votre numéro <a href="https://www.uid.admin.ch/Search.aspx?lang=fr" target="_blank">TVA</a>',
"notify_per_email": """Permet d'activer la réception des notifications
automatiques de suivi dans votre boîte mail, par exemple lorsqu'une
demande a été soumise ou est en attente de validation.""",
"notify_per_email": "Permet d'activer la réception des notifications automatiques de suivi dans votre boîte mail, par exemple lorsqu'une demande a été soumise ou est en attente de validation.",
}
widgets = {
"phone_first": forms.TextInput(attrs={"placeholder": "ex: 024 111 22 22"}),
Expand Down
6 changes: 0 additions & 6 deletions geocity/apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.db.models import BooleanField, Count, ExpressionWrapper, Q, UniqueConstraint
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from simple_history.models import HistoricalRecords
Expand Down Expand Up @@ -563,11 +562,6 @@ class Meta:
verbose_name = _("3.2 Consultation de l'auteur")
verbose_name_plural = _("3.2 Consultation des auteurs")

def get_absolute_url(self):
# FIXME this URL name doesn’t exist, but that was already the case before the
# phoenix migration. Should we remove this?
return reverse("accounts:genericauthorview", args=[str(self.id)])

def __str__(self):

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/contactform.css' %}">
{% endblock %}
{% block scripts %}
<script src="{% static 'libs/js/jquery-ui-custom/jquery-ui.js' %}"></script>
<script src="{% static 'libs/js/jquery-ui-custom/jquery-ui.min.js' %}"></script>
<script src="{% static 'customWidgets/RemoteAutocomplete/remoteautocomplete.js' %}"></script>
<script src="{% static 'js/user_profile_edit.js' %}"></script>
{% endblock %}
Expand Down
41 changes: 40 additions & 1 deletion geocity/apps/core/static/libs/js/jquery-ui-custom/AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Mani Mishra <[email protected]>
Hannah Methvin <[email protected]>
Leonardo Balter <[email protected]>
Benjamin Albert <[email protected]>
Michał Gołębiowski <[email protected]>
Michał Gołębiowski-Owczarek <[email protected]>
Alyosha Pushak <[email protected]>
Fahad Ahmad <[email protected]>
Matt Brundage <[email protected]>
Expand All @@ -331,3 +331,42 @@ Peter Dave Hello <[email protected]>
Johannes Schäfer <[email protected]>
Ville Skyttä <[email protected]>
Ryan Oriecuia <[email protected]>
Sergei Ratnikov <[email protected]>
milk54 <[email protected]>
Evelyn Masso <[email protected]>
Robin <[email protected]>
Simon Asika <[email protected]>
Kevin Cupp <[email protected]>
Jeremy Mickelson <[email protected]>
Kyle Rosenberg <[email protected]>
Petri Partio <[email protected]>
pallxk <[email protected]>
Luke Brookhart <[email protected]>
claudi <[email protected]>
Eirik Sletteberg <[email protected]>
Albert Johansson <[email protected]>
A. Wells <[email protected]>
Robert Brignull <[email protected]>
Horus68 <[email protected]>
Maksymenkov Eugene <[email protected]>
OskarNS <[email protected]>
Gez Quinn <[email protected]>
jigar gala <[email protected]>
Florian Wegscheider <[email protected]>
Fatér Zsolt <[email protected]>
Szabolcs Szabolcsi-Toth <[email protected]>
Jérémy Munsch <[email protected]>
Hrvoje Novosel <[email protected]>
Paul Capron <[email protected]>
Micah Miller <[email protected]>
sakshi87 <[email protected]>
Mikolaj Wolicki <[email protected]>
Patrick McKay <[email protected]>
c-lambert <[email protected]>
Josep Sanz <[email protected]>
Ben Mullins <[email protected]>
Christian Oliff <[email protected]>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Adam Lidén Hällgren <[email protected]>
James Hinderks <[email protected]>
Denny Septian Panggabean <[email protected]>
Loading

0 comments on commit 16af9ef

Please sign in to comment.