diff --git a/apps/member/admin.py b/apps/member/admin.py
index d9075832..26695b3b 100644
--- a/apps/member/admin.py
+++ b/apps/member/admin.py
@@ -4,6 +4,9 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
+from django.utils.translation import gettext_lazy as _
+
+from note.templatetags.pretty_money import pretty_money
from note_kfet.admin import admin_site
from .forms import ProfileForm
@@ -18,6 +21,7 @@ class ProfileInline(admin.StackedInline):
can_delete = False
+@admin.register(User, site=admin_site)
class CustomUserAdmin(UserAdmin):
inlines = (ProfileInline,)
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
@@ -33,9 +37,33 @@ class CustomUserAdmin(UserAdmin):
return super().get_inline_instances(request, obj)
-# Update Django User with profile
-admin_site.register(User, CustomUserAdmin)
+@admin.register(Club, site=admin_site)
+class ClubAdmin(admin.ModelAdmin):
+ list_display = ('name', 'parent_club', 'email', 'require_memberships', 'pretty_fee_paid',
+ 'pretty_fee_unpaid', 'membership_start', 'membership_end',)
+ ordering = ('name',)
+ search_fields = ('name', 'email',)
-# Add other models
-admin_site.register(Club)
-admin_site.register(Membership)
+ def pretty_fee_paid(self, obj):
+ return pretty_money(obj.membership_fee_paid)
+
+ def pretty_fee_unpaid(self, obj):
+ return pretty_money(obj.membership_fee_unpaid)
+
+ pretty_fee_paid.short_description = _("membership fee (paid students)")
+ pretty_fee_unpaid.short_description = _("membership fee (unpaid students)")
+
+
+@admin.register(Membership, site=admin_site)
+class MembershipAdmin(admin.ModelAdmin):
+ list_display = ('user', 'club', 'date_start', 'date_end', 'view_roles', 'pretty_fee',)
+ ordering = ('-date_start', 'club')
+
+ def view_roles(self, obj):
+ return ", ".join(role.name for role in obj.roles.all())
+
+ def pretty_fee(self, obj):
+ return pretty_money(obj.fee)
+
+ view_roles.short_description = _("roles")
+ pretty_fee.short_description = _("fee")
diff --git a/apps/note/admin.py b/apps/note/admin.py
index d2750bd8..2d140daf 100644
--- a/apps/note/admin.py
+++ b/apps/note/admin.py
@@ -10,6 +10,7 @@ from note_kfet.admin import admin_site
from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser
from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \
RecurrentTransaction, MembershipTransaction, SpecialTransaction
+from .templatetags.pretty_money import pretty_money
class AliasInlines(admin.TabularInline):
@@ -37,7 +38,7 @@ class NoteAdmin(PolymorphicParentModelAdmin):
# Organize notes by registration date
date_hierarchy = 'created_at'
- ordering = ['-created_at']
+ ordering = ['name']
# Search by aliases
search_fields = ['alias__name']
@@ -74,6 +75,18 @@ class NoteSpecialAdmin(PolymorphicChildModelAdmin):
"""
readonly_fields = ('balance',)
+ def has_add_permission(self, request):
+ """
+ A club note should not be manually added
+ """
+ return False
+
+ def has_delete_permission(self, request, obj=None):
+ """
+ A club note should not be manually removed
+ """
+ return False
+
@admin.register(NoteUser, site=admin_site)
class NoteUserAdmin(PolymorphicChildModelAdmin):
@@ -103,11 +116,11 @@ class TransactionAdmin(PolymorphicParentModelAdmin):
"""
Admin customisation for Transaction
"""
- child_models = (RecurrentTransaction, MembershipTransaction, SpecialTransaction)
+ child_models = (Transaction, RecurrentTransaction, MembershipTransaction, SpecialTransaction)
list_display = ('created_at', 'poly_source', 'poly_destination',
'quantity', 'amount', 'valid')
list_filter = ('valid',)
- autocomplete_fields = (
+ readonly_fields = (
'source',
'destination',
)
@@ -146,6 +159,13 @@ class MembershipTransactionAdmin(PolymorphicChildModelAdmin):
"""
+@admin.register(RecurrentTransaction, site=admin_site)
+class RecurrentTransactionAdmin(PolymorphicChildModelAdmin):
+ """
+ Admin customisation for RecurrentTransaction
+ """
+
+
@admin.register(SpecialTransaction, site=admin_site)
class SpecialTransactionAdmin(PolymorphicChildModelAdmin):
"""
@@ -158,8 +178,9 @@ class TransactionTemplateAdmin(admin.ModelAdmin):
"""
Admin customisation for TransactionTemplate
"""
- list_display = ('name', 'poly_destination', 'amount', 'category', 'display',)
- list_filter = ('category', 'display')
+ list_display = ('name', 'poly_destination', 'pretty_amount', 'category', 'display', 'highlighted',)
+ list_filter = ('category', 'display', 'highlighted',)
+ search_fields = ('name', 'destination__club__name', 'amount',)
autocomplete_fields = ('destination',)
def poly_destination(self, obj):
@@ -170,6 +191,11 @@ class TransactionTemplateAdmin(admin.ModelAdmin):
poly_destination.short_description = _('destination')
+ def pretty_amount(self, obj):
+ return pretty_money(obj.amount)
+
+ pretty_amount.short_description = _("amount")
+
@admin.register(TemplateCategory, site=admin_site)
class TemplateCategoryAdmin(admin.ModelAdmin):
@@ -177,4 +203,3 @@ class TemplateCategoryAdmin(admin.ModelAdmin):
Admin customisation for TransactionTemplate
"""
list_display = ('name',)
- list_filter = ('name',)
diff --git a/apps/permission/admin.py b/apps/permission/admin.py
index 385cf198..bfe3dc88 100644
--- a/apps/permission/admin.py
+++ b/apps/permission/admin.py
@@ -20,7 +20,9 @@ class PermissionAdmin(admin.ModelAdmin):
"""
Admin customisation for Permission
"""
- list_display = ('type', 'model', 'field', 'mask', 'description', )
+ list_display = ('description', 'type', 'model', 'field', 'mask', )
+ list_filter = ('type', 'mask', 'model',)
+ search_fields = ('description', 'field',)
@admin.register(Role, site=admin_site)
diff --git a/apps/treasury/admin.py b/apps/treasury/admin.py
index 464816db..6e2d4304 100644
--- a/apps/treasury/admin.py
+++ b/apps/treasury/admin.py
@@ -28,4 +28,15 @@ class RemittanceAdmin(admin.ModelAdmin):
return not obj.closed and super().has_change_permission(request, obj)
-admin_site.register(SogeCredit)
+@admin.register(SogeCredit, site=admin_site)
+class SogeCreditAdmin(admin.ModelAdmin):
+ """
+ Admin customisation for Remittance
+ """
+ list_display = ('user', 'valid',)
+ readonly_fields = ('transactions', 'credit_transaction',)
+
+ def has_add_permission(self, request):
+ # Don't create a credit manually
+ return False
+
diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po
index 4a7d3056..efacdfe2 100644
--- a/locale/de/LC_MESSAGES/django.po
+++ b/locale/de/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-08-01 10:47+0200\n"
+"POT-Creation-Date: 2020-08-01 15:06+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -193,7 +193,7 @@ msgstr ""
#: apps/activity/tables.py:79 apps/member/forms.py:107
#: apps/registration/forms.py:69 apps/treasury/forms.py:122
-#: templates/note/transaction_form.html:127
+#: templates/note/transaction_form.html:129
msgid "First name"
msgstr ""
@@ -291,6 +291,24 @@ msgstr ""
msgid "changelogs"
msgstr ""
+#: apps/member/admin.py:53 apps/member/models.py:178
+#: templates/member/club_info.html:41
+msgid "membership fee (paid students)"
+msgstr ""
+
+#: apps/member/admin.py:54 apps/member/models.py:183
+#: templates/member/club_info.html:44
+msgid "membership fee (unpaid students)"
+msgstr ""
+
+#: apps/member/admin.py:68 apps/member/models.py:270
+msgid "roles"
+msgstr ""
+
+#: apps/member/admin.py:69 apps/member/models.py:284
+msgid "fee"
+msgstr ""
+
#: apps/member/apps.py:14 apps/wei/tables.py:150 apps/wei/tables.py:181
msgid "member"
msgstr ""
@@ -324,7 +342,7 @@ msgid "Credit amount"
msgstr ""
#: apps/member/forms.py:112 apps/registration/forms.py:74
-#: apps/treasury/forms.py:124 templates/note/transaction_form.html:133
+#: apps/treasury/forms.py:124 templates/note/transaction_form.html:135
msgid "Bank"
msgstr ""
@@ -478,14 +496,6 @@ msgstr ""
msgid "Uncheck if this club don't require memberships."
msgstr ""
-#: apps/member/models.py:178 templates/member/club_info.html:41
-msgid "membership fee (paid students)"
-msgstr ""
-
-#: apps/member/models.py:183 templates/member/club_info.html:44
-msgid "membership fee (unpaid students)"
-msgstr ""
-
#: apps/member/models.py:189 templates/member/club_info.html:33
msgid "membership duration"
msgstr ""
@@ -521,10 +531,6 @@ msgstr ""
msgid "clubs"
msgstr ""
-#: apps/member/models.py:270
-msgid "roles"
-msgstr ""
-
#: apps/member/models.py:275
msgid "membership starts on"
msgstr ""
@@ -533,10 +539,6 @@ msgstr ""
msgid "membership ends on"
msgstr ""
-#: apps/member/models.py:284
-msgid "fee"
-msgstr ""
-
#: apps/member/models.py:303 apps/member/views.py:535 apps/wei/views.py:797
msgid "User is not a member of the parent club"
msgstr ""
@@ -645,15 +647,20 @@ msgstr ""
msgid "Members of the club"
msgstr ""
-#: apps/note/admin.py:121 apps/note/models/transactions.py:106
+#: apps/note/admin.py:134 apps/note/models/transactions.py:106
msgid "source"
msgstr ""
-#: apps/note/admin.py:129 apps/note/admin.py:171
+#: apps/note/admin.py:142 apps/note/admin.py:192
#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:119
msgid "destination"
msgstr ""
+#: apps/note/admin.py:197 apps/note/models/transactions.py:59
+#: apps/note/models/transactions.py:137
+msgid "amount"
+msgstr ""
+
#: apps/note/forms.py:14
msgid "select an image"
msgstr ""
@@ -775,10 +782,6 @@ msgstr ""
msgid "A template with this name already exist"
msgstr ""
-#: apps/note/models/transactions.py:59 apps/note/models/transactions.py:137
-msgid "amount"
-msgstr ""
-
#: apps/note/models/transactions.py:60
msgid "in centimes"
msgstr ""
@@ -834,7 +837,7 @@ msgstr ""
#: apps/note/models/transactions.py:230
#: templates/activity/activity_entry.html:13 templates/base.html:99
#: templates/note/transaction_form.html:15
-#: templates/note/transaction_form.html:141
+#: templates/note/transaction_form.html:143
msgid "Transfer"
msgstr ""
@@ -1128,7 +1131,7 @@ msgid "You can't change the type of the remittance."
msgstr ""
#: apps/treasury/forms.py:126 apps/treasury/tables.py:47
-#: apps/treasury/tables.py:113 templates/note/transaction_form.html:95
+#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97
#: templates/treasury/remittance_form.html:18
msgid "Amount"
msgstr ""
@@ -1149,7 +1152,7 @@ msgstr ""
msgid "Description"
msgstr ""
-#: apps/treasury/models.py:48 templates/note/transaction_form.html:121
+#: apps/treasury/models.py:48 templates/note/transaction_form.html:123
msgid "Name"
msgstr ""
@@ -1942,7 +1945,7 @@ msgid "Consum"
msgstr ""
#: templates/note/conso_form.html:39 templates/note/transaction_form.html:57
-#: templates/note/transaction_form.html:76
+#: templates/note/transaction_form.html:78
msgid "Name or alias..."
msgstr ""
@@ -1966,7 +1969,7 @@ msgstr ""
msgid "Double consumptions"
msgstr ""
-#: templates/note/conso_form.html:150 templates/note/transaction_form.html:152
+#: templates/note/conso_form.html:150 templates/note/transaction_form.html:154
msgid "Recent transactions history"
msgstr ""
@@ -1974,23 +1977,23 @@ msgstr ""
msgid "Select emitters"
msgstr ""
-#: templates/note/transaction_form.html:60
+#: templates/note/transaction_form.html:61
msgid "I am the emitter"
msgstr ""
-#: templates/note/transaction_form.html:70
+#: templates/note/transaction_form.html:72
msgid "Select receivers"
msgstr ""
-#: templates/note/transaction_form.html:87
+#: templates/note/transaction_form.html:89
msgid "Action"
msgstr ""
-#: templates/note/transaction_form.html:102
+#: templates/note/transaction_form.html:104
msgid "Reason"
msgstr ""
-#: templates/note/transaction_form.html:111
+#: templates/note/transaction_form.html:113
msgid "Transfer type"
msgstr ""
@@ -2102,7 +2105,7 @@ msgid "Log in again"
msgstr ""
#: templates/registration/login.html:7 templates/registration/login.html:8
-#: templates/registration/login.html:22
+#: templates/registration/login.html:31
#: templates/registration/password_reset_complete.html:10
msgid "Log in"
msgstr ""
@@ -2116,6 +2119,12 @@ msgid ""
msgstr ""
#: templates/registration/login.html:23
+msgid ""
+"You must be logged with a staff account with the higher mask to access "
+"Django Admin."
+msgstr ""
+
+#: templates/registration/login.html:32
msgid "Forgotten your password or username?"
msgstr ""
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index d4b464a0..25e68a4b 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-08-01 10:47+0200\n"
+"POT-Creation-Date: 2020-08-01 15:06+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -194,7 +194,7 @@ msgstr "Nom de famille"
#: apps/activity/tables.py:79 apps/member/forms.py:107
#: apps/registration/forms.py:69 apps/treasury/forms.py:122
-#: templates/note/transaction_form.html:127
+#: templates/note/transaction_form.html:129
msgid "First name"
msgstr "Prénom"
@@ -292,6 +292,24 @@ msgstr "journal de modification"
msgid "changelogs"
msgstr "journaux de modifications"
+#: apps/member/admin.py:53 apps/member/models.py:178
+#: templates/member/club_info.html:41
+msgid "membership fee (paid students)"
+msgstr "cotisation pour adhérer (normalien élève)"
+
+#: apps/member/admin.py:54 apps/member/models.py:183
+#: templates/member/club_info.html:44
+msgid "membership fee (unpaid students)"
+msgstr "cotisation pour adhérer (normalien étudiant)"
+
+#: apps/member/admin.py:68 apps/member/models.py:270
+msgid "roles"
+msgstr "rôles"
+
+#: apps/member/admin.py:69 apps/member/models.py:284
+msgid "fee"
+msgstr "cotisation"
+
#: apps/member/apps.py:14 apps/wei/tables.py:150 apps/wei/tables.py:181
msgid "member"
msgstr "adhérent"
@@ -325,7 +343,7 @@ msgid "Credit amount"
msgstr "Montant à créditer"
#: apps/member/forms.py:112 apps/registration/forms.py:74
-#: apps/treasury/forms.py:124 templates/note/transaction_form.html:133
+#: apps/treasury/forms.py:124 templates/note/transaction_form.html:135
msgid "Bank"
msgstr "Banque"
@@ -479,14 +497,6 @@ msgstr "nécessite des adhésions"
msgid "Uncheck if this club don't require memberships."
msgstr "Décochez si ce club n'utilise pas d'adhésions."
-#: apps/member/models.py:178 templates/member/club_info.html:41
-msgid "membership fee (paid students)"
-msgstr "cotisation pour adhérer (normalien élève)"
-
-#: apps/member/models.py:183 templates/member/club_info.html:44
-msgid "membership fee (unpaid students)"
-msgstr "cotisation pour adhérer (normalien étudiant)"
-
#: apps/member/models.py:189 templates/member/club_info.html:33
msgid "membership duration"
msgstr "durée de l'adhésion"
@@ -526,10 +536,6 @@ msgstr "club"
msgid "clubs"
msgstr "clubs"
-#: apps/member/models.py:270
-msgid "roles"
-msgstr "rôles"
-
#: apps/member/models.py:275
msgid "membership starts on"
msgstr "l'adhésion commence le"
@@ -538,10 +544,6 @@ msgstr "l'adhésion commence le"
msgid "membership ends on"
msgstr "l'adhésion finit le"
-#: apps/member/models.py:284
-msgid "fee"
-msgstr "cotisation"
-
#: apps/member/models.py:303 apps/member/views.py:535 apps/wei/views.py:797
msgid "User is not a member of the parent club"
msgstr "L'utilisateur n'est pas membre du club parent"
@@ -652,15 +654,20 @@ msgstr "Gérer les rôles d'un utilisateur dans le club"
msgid "Members of the club"
msgstr "Membres du club"
-#: apps/note/admin.py:121 apps/note/models/transactions.py:106
+#: apps/note/admin.py:134 apps/note/models/transactions.py:106
msgid "source"
msgstr "source"
-#: apps/note/admin.py:129 apps/note/admin.py:171
+#: apps/note/admin.py:142 apps/note/admin.py:192
#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:119
msgid "destination"
msgstr "destination"
+#: apps/note/admin.py:197 apps/note/models/transactions.py:59
+#: apps/note/models/transactions.py:137
+msgid "amount"
+msgstr "montant"
+
#: apps/note/forms.py:14
msgid "select an image"
msgstr "Choisissez une image"
@@ -783,10 +790,6 @@ msgstr "catégories de transaction"
msgid "A template with this name already exist"
msgstr "Un modèle de transaction avec un nom similaire existe déjà."
-#: apps/note/models/transactions.py:59 apps/note/models/transactions.py:137
-msgid "amount"
-msgstr "montant"
-
#: apps/note/models/transactions.py:60
msgid "in centimes"
msgstr "en centimes"
@@ -844,7 +847,7 @@ msgstr ""
#: apps/note/models/transactions.py:230
#: templates/activity/activity_entry.html:13 templates/base.html:99
#: templates/note/transaction_form.html:15
-#: templates/note/transaction_form.html:141
+#: templates/note/transaction_form.html:143
msgid "Transfer"
msgstr "Virement"
@@ -1155,7 +1158,7 @@ msgid "You can't change the type of the remittance."
msgstr "Vous ne pouvez pas changer le type de la remise."
#: apps/treasury/forms.py:126 apps/treasury/tables.py:47
-#: apps/treasury/tables.py:113 templates/note/transaction_form.html:95
+#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97
#: templates/treasury/remittance_form.html:18
msgid "Amount"
msgstr "Montant"
@@ -1176,7 +1179,7 @@ msgstr "Objet"
msgid "Description"
msgstr "Description"
-#: apps/treasury/models.py:48 templates/note/transaction_form.html:121
+#: apps/treasury/models.py:48 templates/note/transaction_form.html:123
msgid "Name"
msgstr "Nom"
@@ -2002,7 +2005,7 @@ msgid "Consum"
msgstr "Consommer"
#: templates/note/conso_form.html:39 templates/note/transaction_form.html:57
-#: templates/note/transaction_form.html:76
+#: templates/note/transaction_form.html:78
msgid "Name or alias..."
msgstr "Pseudo ou alias ..."
@@ -2026,7 +2029,7 @@ msgstr "Consommations simples"
msgid "Double consumptions"
msgstr "Consommations doubles"
-#: templates/note/conso_form.html:150 templates/note/transaction_form.html:152
+#: templates/note/conso_form.html:150 templates/note/transaction_form.html:154
msgid "Recent transactions history"
msgstr "Historique des transactions récentes"
@@ -2034,23 +2037,23 @@ msgstr "Historique des transactions récentes"
msgid "Select emitters"
msgstr "Sélection des émetteurs"
-#: templates/note/transaction_form.html:60
+#: templates/note/transaction_form.html:61
msgid "I am the emitter"
msgstr "Je suis l'émetteur"
-#: templates/note/transaction_form.html:70
+#: templates/note/transaction_form.html:72
msgid "Select receivers"
msgstr "Sélection des destinataires"
-#: templates/note/transaction_form.html:87
+#: templates/note/transaction_form.html:89
msgid "Action"
msgstr "Action"
-#: templates/note/transaction_form.html:102
+#: templates/note/transaction_form.html:104
msgid "Reason"
msgstr "Raison"
-#: templates/note/transaction_form.html:111
+#: templates/note/transaction_form.html:113
msgid "Transfer type"
msgstr "Type de transfert"
@@ -2166,7 +2169,7 @@ msgid "Log in again"
msgstr "Se connecter à nouveau"
#: templates/registration/login.html:7 templates/registration/login.html:8
-#: templates/registration/login.html:22
+#: templates/registration/login.html:31
#: templates/registration/password_reset_complete.html:10
msgid "Log in"
msgstr "Se connecter"
@@ -2183,6 +2186,14 @@ msgstr ""
"masque de permissions plus fort ?"
#: templates/registration/login.html:23
+msgid ""
+"You must be logged with a staff account with the higher mask to access "
+"Django Admin."
+msgstr ""
+"Vous devez être connecté avec un compte staff avec le masque le plus haut "
+"pour accéder à Django Admin."
+
+#: templates/registration/login.html:32
msgid "Forgotten your password or username?"
msgstr "Mot de passe ou pseudo oublié ?"
diff --git a/templates/registration/login.html b/templates/registration/login.html
index 87354721..e624631f 100644
--- a/templates/registration/login.html
+++ b/templates/registration/login.html
@@ -17,6 +17,15 @@ SPDX-License-Identifier: GPL-2.0-or-later
{% endblocktrans %}
{% endif %}
+
+ {% if request.resolver_match.view_name == 'admin:login' %}
+
+ {% blocktrans trimmed %}
+ You must be logged with a staff account with the higher mask to access Django Admin.
+ {% endblocktrans %}
+
+ {% endif %}
+