From 340c90f5d361a37eb6f42d0330699e428a7a53de Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 5 Oct 2021 15:10:20 +0200 Subject: [PATCH 01/17] Relax requirements Relax requirements to allow the use of newer versions of dependencies found in NixPkgs and ArchLinux. Do not limit upper version of django-extensions as it is not mission critical. --- requirements.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0071bc83..f4ece220 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,14 +4,14 @@ django-bootstrap-datepicker-plus~=3.0.5 django-cas-server~=1.2.0 django-colorfield~=0.3.2 django-crispy-forms~=1.7.2 -django-extensions~=2.1.4 -django-filter~=2.1.0 +django-extensions>=2.1.4 +django-filter~=2.1 django-htcpcp-tea~=0.3.1 django-mailer~=2.0.1 django-oauth-toolkit~=1.3.3 django-phonenumber-field~=5.0.0 -django-polymorphic~=2.0.3 -djangorestframework~=3.9.0 +django-polymorphic>=2.0.3,<3.0.0 +djangorestframework>=3.9.0,<3.13.0 django-rest-polymorphic~=0.1.9 django-tables2~=2.3.1 python-memcached~=1.59 From 3f3c93d928c97911b02f0f5a22a0a74c489ade5d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 5 Oct 2021 15:14:56 +0200 Subject: [PATCH 02/17] Ignore shell.nix in Git tree shell.nix is used in Nix to create a specific shell with custom packages. The name is standardised and need to be in project folder to ease development tools integrations. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index affc851f..91e55e22 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ backups/ env/ venv/ db.sqlite3 +shell.nix # ansibles customs host ansible/host_vars/*.yaml From 9d386d1ecf3682aaf5915a1d94cdf40c8b022f98 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Oct 2021 10:41:42 +0200 Subject: [PATCH 03/17] Unauthenticated users can't display activity entry view Signed-off-by: Yohann D'ANELLO --- apps/activity/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/activity/views.py b/apps/activity/views.py index 366cadb3..1f966c65 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -168,6 +168,9 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView): Don't display the entry interface if the user has no right to see it (no right to add an entry for itself), it is closed or doesn't manage entries. """ + if not self.request.user.is_authenticated: + return self.handle_no_permission() + activity = Activity.objects.get(pk=self.kwargs["pk"]) sample_entry = Entry(activity=activity, note=self.request.user.note) From fd811053c73fb480be56e9edfe796b0056ded255 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Oct 2021 10:41:58 +0200 Subject: [PATCH 04/17] Commit missing migrations Signed-off-by: Yohann D'ANELLO --- .../migrations/0008_auto_20211005_1544.py | 18 ++++++++++++++++++ .../migrations/0004_auto_20211005_1544.py | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 apps/member/migrations/0008_auto_20211005_1544.py create mode 100644 apps/treasury/migrations/0004_auto_20211005_1544.py diff --git a/apps/member/migrations/0008_auto_20211005_1544.py b/apps/member/migrations/0008_auto_20211005_1544.py new file mode 100644 index 00000000..a0572999 --- /dev/null +++ b/apps/member/migrations/0008_auto_20211005_1544.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2021-10-05 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('member', '0007_auto_20210313_1235'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='department', + field=models.CharField(choices=[('A0', 'Informatics (A0)'), ('A1', 'Mathematics (A1)'), ('A2', 'Physics (A2)'), ("A'2", "Applied physics (A'2)"), ("A''2", "Chemistry (A''2)"), ('A3', 'Biology (A3)'), ('B1234', 'SAPHIRE (B1234)'), ('B1', 'Mechanics (B1)'), ('B2', 'Civil engineering (B2)'), ('B3', 'Mechanical engineering (B3)'), ('B4', 'EEA (B4)'), ('C', 'Design (C)'), ('D2', 'Economy-management (D2)'), ('D3', 'Social sciences (D3)'), ('E', 'English (E)'), ('EXT', 'External (EXT)')], max_length=8, verbose_name='department'), + ), + ] diff --git a/apps/treasury/migrations/0004_auto_20211005_1544.py b/apps/treasury/migrations/0004_auto_20211005_1544.py new file mode 100644 index 00000000..6016a47f --- /dev/null +++ b/apps/treasury/migrations/0004_auto_20211005_1544.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2021-10-05 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('treasury', '0003_auto_20210321_1034'), + ] + + operations = [ + migrations.AlterField( + model_name='sogecredit', + name='transactions', + field=models.ManyToManyField(blank=True, related_name='_sogecredit_transactions_+', to='note.MembershipTransaction', verbose_name='membership transactions'), + ), + ] From 38ca414ef6f618557930d2b91cef7df5e698f9dc Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Oct 2021 10:44:24 +0200 Subject: [PATCH 05/17] Res[pot] can display user information in order to get first/last name in credits Signed-off-by: Yohann D'ANELLO --- apps/permission/fixtures/initial.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index fe4f90e8..42fe3b57 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -3338,7 +3338,8 @@ 45, 46, 148, - 149 + 149, + 182 ] } }, From 82b0c83b1fbedd8822d19a22f0b27220689455ef Mon Sep 17 00:00:00 2001 From: Nicolas Margulies Date: Thu, 7 Oct 2021 22:54:01 +0200 Subject: [PATCH 06/17] Added a Hide/Show button for transaction templates, fixes #91 --- apps/note/tables.py | 22 +++++++- .../note/transactiontemplate_list.html | 55 +++++++++++++------ 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/apps/note/tables.py b/apps/note/tables.py index 518173c6..188683dd 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -4,7 +4,7 @@ import html import django_tables2 as tables -from django.utils.html import format_html +from django.utils.html import format_html, mark_safe from django_tables2.utils import A from django.utils.translation import gettext_lazy as _ from note_kfet.middlewares import get_current_request @@ -197,6 +197,16 @@ class ButtonTable(tables.Table): verbose_name=_("Edit"), ) + hideshow = tables.Column( + verbose_name= _("Hide/Show"), + accessor="pk", + attrs= { + 'td': { + 'class': 'col-sm-1', + 'id': lambda record: "hideshow_" + str(record.pk), + } + }) + delete_col = tables.TemplateColumn(template_code=DELETE_TEMPLATE, extra_context={"delete_trans": _('delete')}, attrs={'td': {'class': 'col-sm-1'}}, @@ -204,3 +214,13 @@ class ButtonTable(tables.Table): def render_amount(self, value): return pretty_money(value) + + def render_hideshow(self, record): + val = '' + return mark_safe(val) diff --git a/apps/note/templates/note/transactiontemplate_list.html b/apps/note/templates/note/transactiontemplate_list.html index 2a19922e..b6c95758 100644 --- a/apps/note/templates/note/transactiontemplate_list.html +++ b/apps/note/templates/note/transactiontemplate_list.html @@ -31,29 +31,29 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block extrajavascript %} {% endblock %} From e479e1e3a42dacfec8e378e73183be9dcb86d690 Mon Sep 17 00:00:00 2001 From: Nicolas Margulies Date: Thu, 7 Oct 2021 23:06:40 +0200 Subject: [PATCH 07/17] Added messages for Hide/Show --- .../note/transactiontemplate_list.html | 6 +- locale/fr/LC_MESSAGES/django.po | 63 +++++++++++-------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/apps/note/templates/note/transactiontemplate_list.html b/apps/note/templates/note/transactiontemplate_list.html index b6c95758..3536f9f8 100644 --- a/apps/note/templates/note/transactiontemplate_list.html +++ b/apps/note/templates/note/transactiontemplate_list.html @@ -92,12 +92,12 @@ SPDX-License-Identifier: GPL-3.0-or-later }, success: function() { if(displayed) - addMsg('{% trans "Button hidden"%}', 'success') - else addMsg('{% trans "Button displayed"%}', 'success') + addMsg("{% trans "Button hidden"%}", 'success', 1000) + else addMsg("{% trans "Button displayed"%}", 'success', 1000) reloadTable() }, error: function (err) { - addMsg('{% trans "An error occured"%}', 'danger') + addMsg("{% trans "An error occured"%}", 'danger') }}) } diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index d7f05ff3..4ee77566 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-09-28 17:02+0200\n" +"POT-Creation-Date: 2021-10-07 22:55+0200\n" "PO-Revision-Date: 2020-11-16 20:02+0000\n" "Last-Translator: Yohann D'ANELLO \n" "Language-Team: French \n" @@ -279,7 +279,7 @@ msgstr "Prénom" msgid "Note" msgstr "Note" -#: apps/activity/tables.py:90 apps/member/tables.py:49 +#: apps/activity/tables.py:90 apps/member/tables.py:50 msgid "Balance" msgstr "Solde du compte" @@ -320,13 +320,13 @@ msgstr "Entrées" msgid "Return to activity page" msgstr "Retour à la page de l'activité" -#: apps/activity/templates/activity/activity_entry.html:89 -#: apps/activity/templates/activity/activity_entry.html:124 +#: apps/activity/templates/activity/activity_entry.html:94 +#: apps/activity/templates/activity/activity_entry.html:129 msgid "Entry done, but caution: the user is not a Kfet member." msgstr "" "Entrée effectuée, mais attention : la personne n'est pas un adhérent Kfet." -#: apps/activity/templates/activity/activity_entry.html:127 +#: apps/activity/templates/activity/activity_entry.html:132 msgid "Entry done!" msgstr "Entrée effectuée !" @@ -404,33 +404,33 @@ msgstr "Créer une nouvelle activité" msgid "Activities" msgstr "Activités" -#: apps/activity/views.py:95 +#: apps/activity/views.py:93 msgid "Activity detail" msgstr "Détails de l'activité" -#: apps/activity/views.py:115 +#: apps/activity/views.py:113 msgid "Update activity" msgstr "Modifier l'activité" -#: apps/activity/views.py:142 +#: apps/activity/views.py:140 msgid "Invite guest to the activity \"{}\"" msgstr "Invitation pour l'activité « {} »" -#: apps/activity/views.py:177 +#: apps/activity/views.py:178 msgid "You are not allowed to display the entry interface for this activity." msgstr "" "Vous n'êtes pas autorisé à afficher l'interface des entrées pour cette " "activité." -#: apps/activity/views.py:180 +#: apps/activity/views.py:181 msgid "This activity does not support activity entries." msgstr "Cette activité ne requiert pas d'entrées." -#: apps/activity/views.py:183 +#: apps/activity/views.py:184 msgid "This activity is closed." msgstr "Cette activité est fermée." -#: apps/activity/views.py:279 +#: apps/activity/views.py:280 msgid "Entry for activity \"{}\"" msgstr "Entrées pour l'activité « {} »" @@ -466,7 +466,7 @@ msgstr "nouvelles données" msgid "create" msgstr "créer" -#: apps/logs/models.py:65 apps/note/tables.py:165 apps/note/tables.py:201 +#: apps/logs/models.py:65 apps/note/tables.py:165 apps/note/tables.py:211 #: apps/permission/models.py:127 apps/treasury/tables.py:38 #: apps/wei/tables.py:74 msgid "delete" @@ -850,33 +850,33 @@ msgstr "l'adhésion commence le" msgid "membership ends on" msgstr "l'adhésion finit le" -#: apps/member/models.py:422 +#: apps/member/models.py:428 #, python-brace-format msgid "The role {role} does not apply to the club {club}." msgstr "Le rôle {role} ne s'applique pas au club {club}." -#: apps/member/models.py:431 apps/member/views.py:651 +#: apps/member/models.py:437 apps/member/views.py:651 msgid "User is already a member of the club" msgstr "L'utilisateur est déjà membre du club" -#: apps/member/models.py:443 apps/member/views.py:660 +#: apps/member/models.py:449 apps/member/views.py:660 msgid "User is not a member of the parent club" msgstr "L'utilisateur n'est pas membre du club parent" -#: apps/member/models.py:496 +#: apps/member/models.py:502 #, python-brace-format msgid "Membership of {user} for the club {club}" msgstr "Adhésion de {user} pour le club {club}" -#: apps/member/models.py:499 apps/note/models/transactions.py:389 +#: apps/member/models.py:505 apps/note/models/transactions.py:389 msgid "membership" msgstr "adhésion" -#: apps/member/models.py:500 +#: apps/member/models.py:506 msgid "memberships" msgstr "adhésions" -#: apps/member/tables.py:137 +#: apps/member/tables.py:139 msgid "Renew" msgstr "Renouveler" @@ -1535,7 +1535,7 @@ msgstr "Cliquez pour valider" msgid "No reason specified" msgstr "Pas de motif spécifié" -#: apps/note/tables.py:169 apps/note/tables.py:203 apps/treasury/tables.py:39 +#: apps/note/tables.py:169 apps/note/tables.py:213 apps/treasury/tables.py:39 #: apps/treasury/templates/treasury/invoice_confirm_delete.html:30 #: apps/treasury/templates/treasury/sogecredit_detail.html:65 #: apps/wei/tables.py:75 apps/wei/tables.py:118 @@ -1556,6 +1556,10 @@ msgstr "Supprimer" msgid "Edit" msgstr "Éditer" +#: apps/note/tables.py:201 apps/note/tables.py:224 +msgid "Hide/Show" +msgstr "Afficher/Masquer" + #: apps/note/templates/note/conso_form.html:22 #: apps/note/templates/note/transaction_form.html:48 msgid "Please select a note" @@ -1685,6 +1689,18 @@ msgstr "le bouton a bien été supprimé " msgid "Unable to delete button " msgstr "Impossible de supprimer le bouton " +#: apps/note/templates/note/transactiontemplate_list.html:95 +msgid "Button hidden" +msgstr "Bouton masqué" + +#: apps/note/templates/note/transactiontemplate_list.html:96 +msgid "Button displayed" +msgstr "Bouton affiché" + +#: apps/note/templates/note/transactiontemplate_list.html:100 +msgid "An error occured" +msgstr "Une erreur s'est produite" + #: apps/note/views.py:36 msgid "Transfer money" msgstr "Transférer de l'argent" @@ -3501,8 +3517,3 @@ msgstr "" "vous connecter. Vous devez vous rendre à la Kfet et payer les frais " "d'adhésion. Vous devez également valider votre adresse email en suivant le " "lien que vous avez reçu." - -#~ msgid "You are not a Kfet member, so you can't use your note account." -#~ msgstr "" -#~ "Vous n'êtes pas adhérent Kfet, vous ne pouvez par conséquent pas utiliser " -#~ "votre compte note." From d18ccfac2326be4e9c17e9d670cb0b84a2cce91d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:13:11 +0200 Subject: [PATCH 08/17] Sort aliases by normalized name in profile alias view Signed-off-by: Yohann D'ANELLO --- apps/member/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/member/views.py b/apps/member/views.py index 39edcc0b..fac8bfc6 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -256,7 +256,8 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): context = super().get_context_data(**kwargs) note = context['object'].note context["aliases"] = AliasTable( - note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct().all()) + note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct() + .order_by('normalized_name').all()) context["can_create"] = PermissionBackend.check_perm(self.request, "note.add_alias", Alias( note=context["object"].note, name="", From 7848cd9cc2704d9257bc41fdb0b143918e009c19 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:15:52 +0200 Subject: [PATCH 09/17] Don't search buttons by prefix Signed-off-by: Yohann D'ANELLO --- apps/note/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/note/views.py b/apps/note/views.py index 074da01d..1224f2f8 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -90,9 +90,9 @@ class TransactionTemplateListView(ProtectQuerysetMixin, LoginRequiredMixin, Sing if "search" in self.request.GET: pattern = self.request.GET["search"] qs = qs.filter( - Q(name__iregex="^" + pattern) - | Q(destination__club__name__iregex="^" + pattern) - | Q(category__name__iregex="^" + pattern) + Q(name__iregex=pattern) + | Q(destination__club__name__iregex=pattern) + | Q(category__name__iregex=pattern) | Q(description__iregex=pattern) ) From 58cafad032df0831ed37c88d04f7fc4dc4a1d3b2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:36:26 +0200 Subject: [PATCH 10/17] Sort buttons by category name instead of id in button list Signed-off-by: Yohann D'ANELLO --- apps/note/tables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/note/tables.py b/apps/note/tables.py index 188683dd..1efd5c38 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -215,6 +215,9 @@ class ButtonTable(tables.Table): def render_amount(self, value): return pretty_money(value) + def order_category(self, queryset, is_descending): + return queryset.order_by(f"{'-' if is_descending else ''}category__name"), True + def render_hideshow(self, record): val = '