From 8744455cbe3f3a33fafad199a9ab96e9832d392f Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO <yohann.danello@gmail.com>
Date: Mon, 31 Aug 2020 00:13:38 +0200
Subject: [PATCH] Add placeholders in activity form

---
 apps/activity/forms.py                        | 13 +++
 apps/activity/models.py                       |  3 +
 .../activity/includes/activity_info.html      |  2 +-
 locale/de/LC_MESSAGES/django.po               | 96 +++++++++++--------
 locale/fr/LC_MESSAGES/django.po               | 96 +++++++++++--------
 5 files changed, 125 insertions(+), 85 deletions(-)

diff --git a/apps/activity/forms.py b/apps/activity/forms.py
index 70ff57f3..cf9bc3fc 100644
--- a/apps/activity/forms.py
+++ b/apps/activity/forms.py
@@ -2,6 +2,7 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 from datetime import timedelta
+from random import shuffle
 
 from django import forms
 from django.contrib.contenttypes.models import ContentType
@@ -10,11 +11,23 @@ from django.utils.translation import gettext_lazy as _
 from member.models import Club
 from note.models import Note, NoteUser
 from note_kfet.inputs import Autocomplete, DateTimePickerInput
+from note_kfet.middlewares import get_current_authenticated_user
+from permission.backends import PermissionBackend
 
 from .models import Activity, Guest
 
 
 class ActivityForm(forms.ModelForm):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        # By default, the Kfet club is attended
+        self.fields["attendees_club"].initial = Club.objects.get(name="Kfet")
+        self.fields["attendees_club"].widget.attrs["placeholder"] = "Kfet"
+        clubs = list(Club.objects.filter(PermissionBackend
+                                         .filter_queryset(get_current_authenticated_user(), Club, "view")).all())
+        shuffle(clubs)
+        self.fields["organizer"].widget.attrs["placeholder"] = ", ".join(club.name for club in clubs[:4]) + ", ..."
+
     def clean_date_end(self):
         date_end = self.cleaned_data["date_end"]
         date_start = self.cleaned_data["date_start"]
diff --git a/apps/activity/models.py b/apps/activity/models.py
index 19197559..131cd725 100644
--- a/apps/activity/models.py
+++ b/apps/activity/models.py
@@ -72,6 +72,7 @@ class Activity(models.Model):
         max_length=255,
         blank=True,
         default="",
+        help_text=_("Place where the activity is organized, eg. Kfet."),
     )
 
     activity_type = models.ForeignKey(
@@ -92,6 +93,7 @@ class Activity(models.Model):
         on_delete=models.PROTECT,
         related_name='+',
         verbose_name=_('organizer'),
+        help_text=_("Club that organizes the activity. The entry fees will go to this club."),
     )
 
     attendees_club = models.ForeignKey(
@@ -99,6 +101,7 @@ class Activity(models.Model):
         on_delete=models.PROTECT,
         related_name='+',
         verbose_name=_('attendees club'),
+        help_text=_("Club that is authorized to join the activity. Mostly the Kfet club."),
     )
 
     date_start = models.DateTimeField(
diff --git a/apps/activity/templates/activity/includes/activity_info.html b/apps/activity/templates/activity/includes/activity_info.html
index f4723159..a16ad33b 100644
--- a/apps/activity/templates/activity/includes/activity_info.html
+++ b/apps/activity/templates/activity/includes/activity_info.html
@@ -17,7 +17,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
     <div class="card-body" id="profile_infos">
         <dl class="row">
             <dt class="col-xl-6">{% trans 'description'|capfirst %}</dt>
-            <dd class="col-xl-6"> {{ activity.description }}</dd>
+            <dd class="col-xl-6"> {{ activity.description|linebreaks }}</dd>
 
             <dt class="col-xl-6">{% trans 'type'|capfirst %}</dt>
             <dd class="col-xl-6"> {{ activity.activity_type }}</dd>
diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po
index 1151bb86..783db5fd 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-30 23:24+0200\n"
+"POT-Creation-Date: 2020-08-31 00:13+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,32 +18,32 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: apps/activity/apps.py:10 apps/activity/models.py:142
-#: apps/activity/models.py:158
+#: apps/activity/apps.py:10 apps/activity/models.py:145
+#: apps/activity/models.py:161
 msgid "activity"
 msgstr ""
 
-#: apps/activity/forms.py:22 apps/activity/models.py:127
+#: apps/activity/forms.py:35 apps/activity/models.py:130
 msgid "The end date must be after the start date."
 msgstr ""
 
-#: apps/activity/forms.py:63 apps/activity/models.py:254
+#: apps/activity/forms.py:76 apps/activity/models.py:257
 msgid "You can't invite someone once the activity is started."
 msgstr ""
 
-#: apps/activity/forms.py:66 apps/activity/models.py:257
+#: apps/activity/forms.py:79 apps/activity/models.py:260
 msgid "This activity is not validated yet."
 msgstr ""
 
-#: apps/activity/forms.py:76 apps/activity/models.py:265
+#: apps/activity/forms.py:89 apps/activity/models.py:268
 msgid "This person has been already invited 5 times this year."
 msgstr ""
 
-#: apps/activity/forms.py:80 apps/activity/models.py:269
+#: apps/activity/forms.py:93 apps/activity/models.py:272
 msgid "This person is already invited."
 msgstr ""
 
-#: apps/activity/forms.py:84 apps/activity/models.py:273
+#: apps/activity/forms.py:97 apps/activity/models.py:276
 msgid "You can't invite more than 3 people to this activity."
 msgstr ""
 
@@ -98,110 +98,122 @@ msgstr ""
 msgid "location"
 msgstr ""
 
-#: apps/activity/models.py:81
+#: apps/activity/models.py:75
+msgid "Place where the activity is organized, eg. Kfet."
+msgstr ""
+
+#: apps/activity/models.py:82
 #: apps/activity/templates/activity/includes/activity_info.html:22
 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:66
 #: apps/permission/models.py:164
 msgid "type"
 msgstr ""
 
-#: apps/activity/models.py:87 apps/logs/models.py:22 apps/member/models.py:303
+#: apps/activity/models.py:88 apps/logs/models.py:22 apps/member/models.py:303
 #: apps/note/models/notes.py:126 apps/treasury/models.py:267
 #: apps/treasury/templates/treasury/sogecredit_detail.html:15
 #: apps/wei/models.py:160 apps/wei/templates/wei/survey.html:12
 msgid "user"
 msgstr ""
 
-#: apps/activity/models.py:94
+#: apps/activity/models.py:95
 #: apps/activity/templates/activity/includes/activity_info.html:36
 msgid "organizer"
 msgstr ""
 
-#: apps/activity/models.py:101
+#: apps/activity/models.py:96
+msgid "Club that organizes the activity. The entry fees will go to this club."
+msgstr ""
+
+#: apps/activity/models.py:103
 #: apps/activity/templates/activity/includes/activity_info.html:39
 msgid "attendees club"
 msgstr ""
 
-#: apps/activity/models.py:105
+#: apps/activity/models.py:104
+msgid "Club that is authorized to join the activity. Mostly the Kfet club."
+msgstr ""
+
+#: apps/activity/models.py:108
 #: apps/activity/templates/activity/includes/activity_info.html:25
 msgid "start date"
 msgstr ""
 
-#: apps/activity/models.py:109
+#: apps/activity/models.py:112
 #: apps/activity/templates/activity/includes/activity_info.html:28
 msgid "end date"
 msgstr ""
 
-#: apps/activity/models.py:114
+#: apps/activity/models.py:117
 #: apps/activity/templates/activity/includes/activity_info.html:50
 #: apps/note/models/transactions.py:146
 msgid "valid"
 msgstr ""
 
-#: apps/activity/models.py:119
+#: apps/activity/models.py:122
 #: apps/activity/templates/activity/includes/activity_info.html:65
 msgid "open"
 msgstr ""
 
-#: apps/activity/models.py:143
+#: apps/activity/models.py:146
 msgid "activities"
 msgstr ""
 
-#: apps/activity/models.py:163
+#: apps/activity/models.py:166
 msgid "entry time"
 msgstr ""
 
-#: apps/activity/models.py:169 apps/note/apps.py:14
+#: apps/activity/models.py:172 apps/note/apps.py:14
 #: apps/note/models/notes.py:60
 msgid "note"
 msgstr ""
 
-#: apps/activity/models.py:180
+#: apps/activity/models.py:183
 #: apps/activity/templates/activity/activity_entry.html:42
 msgid "entry"
 msgstr ""
 
-#: apps/activity/models.py:181
+#: apps/activity/models.py:184
 #: apps/activity/templates/activity/activity_entry.html:42
 msgid "entries"
 msgstr ""
 
-#: apps/activity/models.py:187
+#: apps/activity/models.py:190
 msgid "Already entered on "
 msgstr ""
 
-#: apps/activity/models.py:187 apps/activity/tables.py:59
+#: apps/activity/models.py:190 apps/activity/tables.py:54
 msgid "{:%Y-%m-%d %H:%M:%S}"
 msgstr ""
 
-#: apps/activity/models.py:195
+#: apps/activity/models.py:198
 msgid "The balance is negative."
 msgstr ""
 
-#: apps/activity/models.py:225
+#: apps/activity/models.py:228
 msgid "last name"
 msgstr ""
 
-#: apps/activity/models.py:230
+#: apps/activity/models.py:233
 #: apps/member/templates/member/includes/profile_info.html:4
 #: apps/registration/templates/registration/future_profile_detail.html:16
 #: apps/wei/templates/wei/weimembership_form.html:14
 msgid "first name"
 msgstr ""
 
-#: apps/activity/models.py:237
+#: apps/activity/models.py:240
 msgid "inviter"
 msgstr ""
 
-#: apps/activity/models.py:281
+#: apps/activity/models.py:284
 msgid "guest"
 msgstr ""
 
-#: apps/activity/models.py:282
+#: apps/activity/models.py:285
 msgid "guests"
 msgstr ""
 
-#: apps/activity/models.py:294
+#: apps/activity/models.py:297
 msgid "Invitation"
 msgstr ""
 
@@ -213,36 +225,40 @@ msgstr ""
 msgid "The validation of the activity is pending."
 msgstr ""
 
-#: apps/activity/tables.py:59
+#: apps/activity/tables.py:41 apps/treasury/tables.py:107
+msgid "Remove"
+msgstr ""
+
+#: apps/activity/tables.py:54
 msgid "Entered on "
 msgstr ""
 
-#: apps/activity/tables.py:60
+#: apps/activity/tables.py:56
 msgid "remove"
 msgstr ""
 
-#: apps/activity/tables.py:84 apps/note/forms.py:66 apps/treasury/models.py:186
+#: apps/activity/tables.py:80 apps/note/forms.py:66 apps/treasury/models.py:186
 msgid "Type"
 msgstr ""
 
-#: apps/activity/tables.py:86 apps/member/forms.py:131
+#: apps/activity/tables.py:82 apps/member/forms.py:131
 #: apps/registration/forms.py:81 apps/treasury/forms.py:135
 #: apps/wei/forms/registration.py:96
 msgid "Last name"
 msgstr ""
 
-#: apps/activity/tables.py:88 apps/member/forms.py:136
+#: apps/activity/tables.py:84 apps/member/forms.py:136
 #: apps/note/templates/note/transaction_form.html:135
 #: apps/registration/forms.py:86 apps/treasury/forms.py:137
 #: apps/wei/forms/registration.py:101
 msgid "First name"
 msgstr ""
 
-#: apps/activity/tables.py:90 apps/note/models/notes.py:69
+#: apps/activity/tables.py:86 apps/note/models/notes.py:69
 msgid "Note"
 msgstr ""
 
-#: apps/activity/tables.py:92 apps/member/tables.py:46
+#: apps/activity/tables.py:88 apps/member/tables.py:46
 msgid "Balance"
 msgstr ""
 
@@ -1945,10 +1961,6 @@ msgstr ""
 msgid "View"
 msgstr ""
 
-#: apps/treasury/tables.py:107
-msgid "Remove"
-msgstr ""
-
 #: apps/treasury/tables.py:146
 msgid "Yes"
 msgstr ""
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index d27485a3..c031e1d1 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-30 23:24+0200\n"
+"POT-Creation-Date: 2020-08-31 00:13+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,33 +18,33 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-#: apps/activity/apps.py:10 apps/activity/models.py:142
-#: apps/activity/models.py:158
+#: apps/activity/apps.py:10 apps/activity/models.py:145
+#: apps/activity/models.py:161
 msgid "activity"
 msgstr "activité"
 
-#: apps/activity/forms.py:22 apps/activity/models.py:127
+#: apps/activity/forms.py:35 apps/activity/models.py:130
 msgid "The end date must be after the start date."
 msgstr "La date de fin doit être après celle de début."
 
-#: apps/activity/forms.py:63 apps/activity/models.py:254
+#: apps/activity/forms.py:76 apps/activity/models.py:257
 msgid "You can't invite someone once the activity is started."
 msgstr ""
 "Vous ne pouvez pas inviter quelqu'un une fois que l'activité a démarré."
 
-#: apps/activity/forms.py:66 apps/activity/models.py:257
+#: apps/activity/forms.py:79 apps/activity/models.py:260
 msgid "This activity is not validated yet."
 msgstr "Cette activité n'est pas encore validée."
 
-#: apps/activity/forms.py:76 apps/activity/models.py:265
+#: apps/activity/forms.py:89 apps/activity/models.py:268
 msgid "This person has been already invited 5 times this year."
 msgstr "Cette personne a déjà été invitée 5 fois cette année."
 
-#: apps/activity/forms.py:80 apps/activity/models.py:269
+#: apps/activity/forms.py:93 apps/activity/models.py:272
 msgid "This person is already invited."
 msgstr "Cette personne est déjà invitée."
 
-#: apps/activity/forms.py:84 apps/activity/models.py:273
+#: apps/activity/forms.py:97 apps/activity/models.py:276
 msgid "You can't invite more than 3 people to this activity."
 msgstr "Vous ne pouvez pas inviter plus de 3 personnes à cette activité."
 
@@ -99,110 +99,122 @@ msgstr "description"
 msgid "location"
 msgstr "lieu"
 
-#: apps/activity/models.py:81
+#: apps/activity/models.py:75
+msgid "Place where the activity is organized, eg. Kfet."
+msgstr "Lieu où l'activité est organisée, par exemple la Kfet."
+
+#: apps/activity/models.py:82
 #: apps/activity/templates/activity/includes/activity_info.html:22
 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:66
 #: apps/permission/models.py:164
 msgid "type"
 msgstr "type"
 
-#: apps/activity/models.py:87 apps/logs/models.py:22 apps/member/models.py:303
+#: apps/activity/models.py:88 apps/logs/models.py:22 apps/member/models.py:303
 #: apps/note/models/notes.py:126 apps/treasury/models.py:267
 #: apps/treasury/templates/treasury/sogecredit_detail.html:15
 #: apps/wei/models.py:160 apps/wei/templates/wei/survey.html:12
 msgid "user"
 msgstr "utilisateur"
 
-#: apps/activity/models.py:94
+#: apps/activity/models.py:95
 #: apps/activity/templates/activity/includes/activity_info.html:36
 msgid "organizer"
 msgstr "organisateur"
 
-#: apps/activity/models.py:101
+#: apps/activity/models.py:96
+msgid "Club that organizes the activity. The entry fees will go to this club."
+msgstr "Le club qui organise l'activité. Les coûts d'invitation iront pour ce club."
+
+#: apps/activity/models.py:103
 #: apps/activity/templates/activity/includes/activity_info.html:39
 msgid "attendees club"
 msgstr "club attendu"
 
-#: apps/activity/models.py:105
+#: apps/activity/models.py:104
+msgid "Club that is authorized to join the activity. Mostly the Kfet club."
+msgstr "Club qui est autorisé à rejoindre l'activité. Très souvent le club Kfet."
+
+#: apps/activity/models.py:108
 #: apps/activity/templates/activity/includes/activity_info.html:25
 msgid "start date"
 msgstr "date de début"
 
-#: apps/activity/models.py:109
+#: apps/activity/models.py:112
 #: apps/activity/templates/activity/includes/activity_info.html:28
 msgid "end date"
 msgstr "date de fin"
 
-#: apps/activity/models.py:114
+#: apps/activity/models.py:117
 #: apps/activity/templates/activity/includes/activity_info.html:50
 #: apps/note/models/transactions.py:146
 msgid "valid"
 msgstr "valide"
 
-#: apps/activity/models.py:119
+#: apps/activity/models.py:122
 #: apps/activity/templates/activity/includes/activity_info.html:65
 msgid "open"
 msgstr "ouvrir"
 
-#: apps/activity/models.py:143
+#: apps/activity/models.py:146
 msgid "activities"
 msgstr "activités"
 
-#: apps/activity/models.py:163
+#: apps/activity/models.py:166
 msgid "entry time"
 msgstr "heure d'entrée"
 
-#: apps/activity/models.py:169 apps/note/apps.py:14
+#: apps/activity/models.py:172 apps/note/apps.py:14
 #: apps/note/models/notes.py:60
 msgid "note"
 msgstr "note"
 
-#: apps/activity/models.py:180
+#: apps/activity/models.py:183
 #: apps/activity/templates/activity/activity_entry.html:42
 msgid "entry"
 msgstr "entrée"
 
-#: apps/activity/models.py:181
+#: apps/activity/models.py:184
 #: apps/activity/templates/activity/activity_entry.html:42
 msgid "entries"
 msgstr "entrées"
 
-#: apps/activity/models.py:187
+#: apps/activity/models.py:190
 msgid "Already entered on "
 msgstr "Déjà rentré le "
 
-#: apps/activity/models.py:187 apps/activity/tables.py:59
+#: apps/activity/models.py:190 apps/activity/tables.py:54
 msgid "{:%Y-%m-%d %H:%M:%S}"
 msgstr "{:%d/%m/%Y %H:%M:%S}"
 
-#: apps/activity/models.py:195
+#: apps/activity/models.py:198
 msgid "The balance is negative."
 msgstr "La note est en négatif."
 
-#: apps/activity/models.py:225
+#: apps/activity/models.py:228
 msgid "last name"
 msgstr "nom de famille"
 
-#: apps/activity/models.py:230
+#: apps/activity/models.py:233
 #: apps/member/templates/member/includes/profile_info.html:4
 #: apps/registration/templates/registration/future_profile_detail.html:16
 #: apps/wei/templates/wei/weimembership_form.html:14
 msgid "first name"
 msgstr "prénom"
 
-#: apps/activity/models.py:237
+#: apps/activity/models.py:240
 msgid "inviter"
 msgstr "hôte"
 
-#: apps/activity/models.py:281
+#: apps/activity/models.py:284
 msgid "guest"
 msgstr "invité"
 
-#: apps/activity/models.py:282
+#: apps/activity/models.py:285
 msgid "guests"
 msgstr "invités"
 
-#: apps/activity/models.py:294
+#: apps/activity/models.py:297
 msgid "Invitation"
 msgstr "Invitation"
 
@@ -214,36 +226,40 @@ msgstr "Cette activité est actuellement ouverte."
 msgid "The validation of the activity is pending."
 msgstr "La validation de cette activité est en attente."
 
-#: apps/activity/tables.py:59
+#: apps/activity/tables.py:41 apps/treasury/tables.py:107
+msgid "Remove"
+msgstr "Supprimer"
+
+#: apps/activity/tables.py:54
 msgid "Entered on "
 msgstr "Entré le "
 
-#: apps/activity/tables.py:60
+#: apps/activity/tables.py:56
 msgid "remove"
 msgstr "supprimer"
 
-#: apps/activity/tables.py:84 apps/note/forms.py:66 apps/treasury/models.py:186
+#: apps/activity/tables.py:80 apps/note/forms.py:66 apps/treasury/models.py:186
 msgid "Type"
 msgstr "Type"
 
-#: apps/activity/tables.py:86 apps/member/forms.py:131
+#: apps/activity/tables.py:82 apps/member/forms.py:131
 #: apps/registration/forms.py:81 apps/treasury/forms.py:135
 #: apps/wei/forms/registration.py:96
 msgid "Last name"
 msgstr "Nom de famille"
 
-#: apps/activity/tables.py:88 apps/member/forms.py:136
+#: apps/activity/tables.py:84 apps/member/forms.py:136
 #: apps/note/templates/note/transaction_form.html:135
 #: apps/registration/forms.py:86 apps/treasury/forms.py:137
 #: apps/wei/forms/registration.py:101
 msgid "First name"
 msgstr "Prénom"
 
-#: apps/activity/tables.py:90 apps/note/models/notes.py:69
+#: apps/activity/tables.py:86 apps/note/models/notes.py:69
 msgid "Note"
 msgstr "Note"
 
-#: apps/activity/tables.py:92 apps/member/tables.py:46
+#: apps/activity/tables.py:88 apps/member/tables.py:46
 msgid "Balance"
 msgstr "Solde du compte"
 
@@ -2010,10 +2026,6 @@ msgstr "Nombre de transactions"
 msgid "View"
 msgstr "Voir"
 
-#: apps/treasury/tables.py:107
-msgid "Remove"
-msgstr "Supprimer"
-
 #: apps/treasury/tables.py:146
 msgid "Yes"
 msgstr "Oui"
-- 
GitLab