Guests can pay with CB or coins, lot of other improvements

This commit is contained in:
Yohann D'ANELLO 2020-03-28 16:52:58 +01:00
parent 81cfaf12fa
commit c8b72cf1ff
10 changed files with 304 additions and 133 deletions

View File

@ -3,7 +3,7 @@
from rest_framework import serializers from rest_framework import serializers
from ..models import ActivityType, Activity, Guest, Entry from ..models import ActivityType, Activity, Guest, Entry, GuestTransaction
class ActivityTypeSerializer(serializers.ModelSerializer): class ActivityTypeSerializer(serializers.ModelSerializer):
@ -48,3 +48,14 @@ class EntrySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Entry model = Entry
fields = '__all__' fields = '__all__'
class GuestTransactionSerializer(serializers.ModelSerializer):
"""
REST API Serializer for Special transactions.
The djangorestframework plugin will analyse the model `GuestTransaction` and parse all fields in the API.
"""
class Meta:
model = GuestTransaction
fields = '__all__'

View File

@ -69,8 +69,6 @@ class Activity(models.Model):
'note.Note', 'note.Note',
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name='+', related_name='+',
null=True,
blank=True,
verbose_name=_('note'), verbose_name=_('note'),
) )
@ -152,7 +150,7 @@ class Entry(models.Model):
GuestTransaction.objects.create( GuestTransaction.objects.create(
source=self.note, source=self.note,
source_alias=self.note.user.username, source_alias=self.note.user.username,
destination=self.activity.organizer.note, destination=self.note,
destination_alias=self.activity.organizer.name, destination_alias=self.activity.organizer.name,
quantity=1, quantity=1,
amount=self.activity.activity_type.guest_entry_fee, amount=self.activity.activity_type.guest_entry_fee,

View File

@ -7,7 +7,7 @@ import django_tables2 as tables
from django_tables2 import A from django_tables2 import A
from note.templatetags.pretty_money import pretty_money from note.templatetags.pretty_money import pretty_money
from .models import Activity, Guest from .models import Activity, Guest, Entry
class ActivityTable(tables.Table): class ActivityTable(tables.Table):
@ -55,6 +55,22 @@ class GuestTable(tables.Table):
return _("remove").capitalize() return _("remove").capitalize()
def get_row_class(record):
c = "table-row"
if isinstance(record, Guest):
if record.has_entry:
c += " table-success"
else:
c += " table-warning"
else:
qs = Entry.objects.filter(note=record.note, activity=record.activity, guest=None)
if qs.exists():
c += " table-success"
elif record.note.balance < 0:
c += " table-danger"
return c
class EntryTable(tables.Table): class EntryTable(tables.Table):
type = tables.Column(verbose_name=_("Type")) type = tables.Column(verbose_name=_("Type"))
@ -82,9 +98,11 @@ class EntryTable(tables.Table):
} }
template_name = 'django_tables2/bootstrap4.html' template_name = 'django_tables2/bootstrap4.html'
row_attrs = { row_attrs = {
'class': 'table-row', 'class': lambda record: get_row_class(record),
'id': lambda record: "row-" + ("guest-" if isinstance(record, Guest) else "membership-") + str(record.pk), 'id': lambda record: "row-" + ("guest-" if isinstance(record, Guest) else "membership-") + str(record.pk),
'data-type': lambda record: "guest" if isinstance(record, Guest) else "membership", 'data-type': lambda record: "guest" if isinstance(record, Guest) else "membership",
'data-id': lambda record: record.pk, 'data-id': lambda record: record.pk if isinstance(record, Guest) else record.note.pk,
'data-inviter': lambda record: record.inviter.pk if isinstance(record, Guest) else "", 'data-inviter': lambda record: record.inviter.pk if isinstance(record, Guest) else "",
'data-last-name': lambda record: record.last_name,
'data-first-name': lambda record: record.first_name,
} }

View File

@ -1,5 +1,6 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from datetime import datetime
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
@ -8,11 +9,11 @@ from django.urls import reverse_lazy
from django.views.generic import CreateView, DetailView, UpdateView, TemplateView from django.views.generic import CreateView, DetailView, UpdateView, TemplateView
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django_tables2.views import SingleTableView from django_tables2.views import SingleTableView
from note.models import NoteUser, Alias from note.models import NoteUser, Alias, NoteSpecial
from permission.backends import PermissionBackend from permission.backends import PermissionBackend
from .forms import ActivityForm, GuestForm from .forms import ActivityForm, GuestForm
from .models import Activity, Guest from .models import Activity, Guest, Entry
from .tables import ActivityTable, GuestTable, EntryTable from .tables import ActivityTable, GuestTable, EntryTable
@ -31,7 +32,10 @@ class ActivityListView(LoginRequiredMixin, SingleTableView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs) ctx = super().get_context_data(**kwargs)
ctx['title'] = _("Upcoming activities") ctx['title'] = _("Activities")
upcoming_activities = Activity.objects.filter(date_end__gt=datetime.now())
ctx['upcoming'] = ActivityTable(data=upcoming_activities)
return ctx return ctx
@ -115,12 +119,16 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
.distinct("username")[:20] .distinct("username")[:20]
for note in note_qs: for note in note_qs:
note.type = "Adhérent" note.type = "Adhérent"
note.activity = activity
matched.append(note) matched.append(note)
table = EntryTable(data=matched) table = EntryTable(data=matched)
ctx["table"] = table ctx["table"] = table
ctx["entries"] = Entry.objects.filter(activity=activity)
ctx["title"] = _('Entry for activity "{}"').format(activity.name) ctx["title"] = _('Entry for activity "{}"').format(activity.name)
ctx["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk ctx["noteuser_ctype"] = ContentType.objects.get_for_model(NoteUser).pk
ctx["notespecial_ctype"] = ContentType.objects.get_for_model(NoteSpecial).pk
return ctx return ctx

View File

@ -163,6 +163,7 @@ class SpecialTransactionSerializer(serializers.ModelSerializer):
fields = '__all__' fields = '__all__'
# noinspection PyUnresolvedReferences
class TransactionPolymorphicSerializer(PolymorphicSerializer): class TransactionPolymorphicSerializer(PolymorphicSerializer):
model_serializer_mapping = { model_serializer_mapping = {
Transaction: TransactionSerializer, Transaction: TransactionSerializer,
@ -171,5 +172,12 @@ class TransactionPolymorphicSerializer(PolymorphicSerializer):
SpecialTransaction: SpecialTransactionSerializer, SpecialTransaction: SpecialTransactionSerializer,
} }
try:
from activity.models import GuestTransaction
from activity.api.serializers import GuestTransactionSerializer
model_serializer_mapping[GuestTransaction] = GuestTransactionSerializer
except ImportError: # Activity app is not loaded
pass
class Meta: class Meta:
model = Transaction model = Transaction

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-28 01:54+0100\n" "POT-Creation-Date: 2020-03-28 16:42+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -19,10 +19,11 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: apps/activity/apps.py:10 apps/activity/models.py:101 #: apps/activity/apps.py:10 apps/activity/models.py:101
#: apps/activity/models.py:109
msgid "activity" msgid "activity"
msgstr "" msgstr ""
#: apps/activity/models.py:19 apps/activity/models.py:44 #: apps/activity/models.py:21 apps/activity/models.py:46
#: apps/member/models.py:64 apps/member/models.py:122 #: apps/member/models.py:64 apps/member/models.py:122
#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:24
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:231 #: apps/note/models/transactions.py:44 apps/note/models/transactions.py:231
@ -30,38 +31,38 @@ msgstr ""
msgid "name" msgid "name"
msgstr "" msgstr ""
#: apps/activity/models.py:23 templates/activity/activity_detail.html:34 #: apps/activity/models.py:25 templates/activity/activity_detail.html:34
msgid "can invite" msgid "can invite"
msgstr "" msgstr ""
#: apps/activity/models.py:26 templates/activity/activity_detail.html:38 #: apps/activity/models.py:28 templates/activity/activity_detail.html:38
msgid "guest entry fee" msgid "guest entry fee"
msgstr "" msgstr ""
#: apps/activity/models.py:30 #: apps/activity/models.py:32
msgid "activity type" msgid "activity type"
msgstr "" msgstr ""
#: apps/activity/models.py:31 #: apps/activity/models.py:33
msgid "activity types" msgid "activity types"
msgstr "" msgstr ""
#: apps/activity/models.py:49 apps/note/models/transactions.py:69 #: apps/activity/models.py:51 apps/note/models/transactions.py:69
#: apps/permission/models.py:90 templates/activity/activity_detail.html:16 #: apps/permission/models.py:90 templates/activity/activity_detail.html:16
msgid "description" msgid "description"
msgstr "" msgstr ""
#: apps/activity/models.py:56 apps/note/models/notes.py:164 #: apps/activity/models.py:58 apps/note/models/notes.py:164
#: apps/note/models/transactions.py:62 #: apps/note/models/transactions.py:62
#: templates/activity/activity_detail.html:19 #: templates/activity/activity_detail.html:19
msgid "type" msgid "type"
msgstr "" msgstr ""
#: apps/activity/models.py:63 templates/activity/activity_detail.html:28 #: apps/activity/models.py:65 templates/activity/activity_detail.html:28
msgid "organizer" msgid "organizer"
msgstr "" msgstr ""
#: apps/activity/models.py:72 apps/activity/models.py:113 apps/note/apps.py:14 #: apps/activity/models.py:72 apps/activity/models.py:120 apps/note/apps.py:14
#: apps/note/models/notes.py:58 #: apps/note/models/notes.py:58
msgid "note" msgid "note"
msgstr "" msgstr ""
@ -91,43 +92,80 @@ msgstr ""
msgid "activities" msgid "activities"
msgstr "" msgstr ""
#: apps/activity/models.py:107 #: apps/activity/models.py:114
msgid "entry time" msgid "entry time"
msgstr "" msgstr ""
#: apps/activity/models.py:129 #: apps/activity/models.py:137
msgid "Already entered on "
msgstr ""
#: apps/activity/models.py:137 apps/activity/tables.py:54
msgid "{:%Y-%m-%d %H:%M:%S}"
msgstr ""
#: apps/activity/models.py:145
msgid "The balance is negative."
msgstr ""
#: apps/activity/models.py:177
msgid "last name" msgid "last name"
msgstr "" msgstr ""
#: apps/activity/models.py:134 templates/member/profile_info.html:14 #: apps/activity/models.py:182 templates/member/profile_info.html:14
msgid "first name" msgid "first name"
msgstr "" msgstr ""
#: apps/activity/models.py:141 #: apps/activity/models.py:189
msgid "inviter" msgid "inviter"
msgstr "" msgstr ""
#: apps/activity/models.py:151 #: apps/activity/models.py:202
msgid "guest" msgid "guest"
msgstr "" msgstr ""
#: apps/activity/models.py:152 #: apps/activity/models.py:203
msgid "guests" msgid "guests"
msgstr "" msgstr ""
#: apps/activity/models.py:163 #: apps/activity/models.py:214
msgid "Invitation" msgid "Invitation"
msgstr "" msgstr ""
#: apps/activity/tables.py:54 #: apps/activity/tables.py:54
msgid "Entered on "
msgstr ""
#: apps/activity/tables.py:55
msgid "remove" msgid "remove"
msgstr "" msgstr ""
#: apps/activity/views.py:34 #: apps/activity/tables.py:75 apps/treasury/models.py:126
msgid "Upcoming activities" msgid "Type"
msgstr "" msgstr ""
#: apps/activity/views.py:119 #: apps/activity/tables.py:77 apps/treasury/forms.py:120
msgid "Last name"
msgstr ""
#: apps/activity/tables.py:79 apps/treasury/forms.py:122
#: templates/note/transaction_form.html:92
msgid "First name"
msgstr ""
#: apps/activity/tables.py:81 apps/note/models/notes.py:67
msgid "Note"
msgstr ""
#: apps/activity/tables.py:83
msgid "Balance"
msgstr ""
#: apps/activity/views.py:35 templates/base.html:94
msgid "Activities"
msgstr ""
#: apps/activity/views.py:130
msgid "Entry for activity \"{}\"" msgid "Entry for activity \"{}\""
msgstr "" msgstr ""
@ -357,10 +395,6 @@ msgstr ""
msgid "notes" msgid "notes"
msgstr "" msgstr ""
#: apps/note/models/notes.py:67
msgid "Note"
msgstr ""
#: apps/note/models/notes.py:77 apps/note/models/notes.py:101 #: apps/note/models/notes.py:77 apps/note/models/notes.py:101
msgid "This alias is already taken." msgid "This alias is already taken."
msgstr "" msgstr ""
@ -573,14 +607,6 @@ msgstr ""
msgid "You can't change the type of the remittance." msgid "You can't change the type of the remittance."
msgstr "" msgstr ""
#: apps/treasury/forms.py:120
msgid "Last name"
msgstr ""
#: apps/treasury/forms.py:122 templates/note/transaction_form.html:92
msgid "First name"
msgstr ""
#: apps/treasury/forms.py:124 templates/note/transaction_form.html:98 #: apps/treasury/forms.py:124 templates/note/transaction_form.html:98
msgid "Bank" msgid "Bank"
msgstr "" msgstr ""
@ -639,10 +665,6 @@ msgstr ""
msgid "Date" msgid "Date"
msgstr "" msgstr ""
#: apps/treasury/models.py:126
msgid "Type"
msgstr ""
#: apps/treasury/models.py:131 #: apps/treasury/models.py:131
msgid "Comment" msgid "Comment"
msgstr "" msgstr ""
@ -733,10 +755,34 @@ msgstr ""
msgid "Guests list" msgid "Guests list"
msgstr "" msgstr ""
#: templates/activity/activity_list.html:7 #: templates/activity/activity_entry.html:10
msgid "Return to activity page"
msgstr ""
#: templates/activity/activity_entry.html:18
msgid "entries"
msgstr ""
#: templates/activity/activity_entry.html:18
msgid "entry"
msgstr ""
#: templates/activity/activity_list.html:5
msgid "Upcoming activities"
msgstr ""
#: templates/activity/activity_list.html:10
msgid "There is no planned activity."
msgstr ""
#: templates/activity/activity_list.html:14
msgid "New activity" msgid "New activity"
msgstr "" msgstr ""
#: templates/activity/activity_list.html:18
msgid "All activities"
msgstr ""
#: templates/base.html:13 #: templates/base.html:13
msgid "The ENS Paris-Saclay BDE note." msgid "The ENS Paris-Saclay BDE note."
msgstr "" msgstr ""
@ -745,10 +791,6 @@ msgstr ""
msgid "Clubs" msgid "Clubs"
msgstr "" msgstr ""
#: templates/base.html:94
msgid "Activities"
msgstr ""
#: templates/cas_server/base.html:7 #: templates/cas_server/base.html:7
msgid "Central Authentication Service" msgid "Central Authentication Service"
msgstr "" msgstr ""

View File

@ -3,7 +3,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-03-28 01:54+0100\n" "POT-Creation-Date: 2020-03-28 16:42+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -14,10 +14,11 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: apps/activity/apps.py:10 apps/activity/models.py:101 #: apps/activity/apps.py:10 apps/activity/models.py:101
#: apps/activity/models.py:109
msgid "activity" msgid "activity"
msgstr "activité" msgstr "activité"
#: apps/activity/models.py:19 apps/activity/models.py:44 #: apps/activity/models.py:21 apps/activity/models.py:46
#: apps/member/models.py:64 apps/member/models.py:122 #: apps/member/models.py:64 apps/member/models.py:122
#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24 #: apps/note/models/notes.py:188 apps/note/models/transactions.py:24
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:231 #: apps/note/models/transactions.py:44 apps/note/models/transactions.py:231
@ -25,45 +26,45 @@ msgstr "activité"
msgid "name" msgid "name"
msgstr "nom" msgstr "nom"
#: apps/activity/models.py:23 templates/activity/activity_detail.html:34 #: apps/activity/models.py:25 templates/activity/activity_detail.html:34
msgid "can invite" msgid "can invite"
msgstr "peut inviter" msgstr "peut inviter"
#: apps/activity/models.py:26 templates/activity/activity_detail.html:38 #: apps/activity/models.py:28 templates/activity/activity_detail.html:38
msgid "guest entry fee" msgid "guest entry fee"
msgstr "cotisation de l'entrée invité" msgstr "cotisation de l'entrée invité"
#: apps/activity/models.py:30 #: apps/activity/models.py:32
msgid "activity type" msgid "activity type"
msgstr "type d'activité" msgstr "type d'activité"
#: apps/activity/models.py:31 #: apps/activity/models.py:33
msgid "activity types" msgid "activity types"
msgstr "types d'activité" msgstr "types d'activité"
#: apps/activity/models.py:49 apps/note/models/transactions.py:69 #: apps/activity/models.py:51 apps/note/models/transactions.py:69
#: apps/permission/models.py:90 templates/activity/activity_detail.html:16 #: apps/permission/models.py:90 templates/activity/activity_detail.html:16
msgid "description" msgid "description"
msgstr "description" msgstr "description"
#: apps/activity/models.py:56 apps/note/models/notes.py:164 #: apps/activity/models.py:58 apps/note/models/notes.py:164
#: apps/note/models/transactions.py:62 #: apps/note/models/transactions.py:62
#: templates/activity/activity_detail.html:19 #: templates/activity/activity_detail.html:19
msgid "type" msgid "type"
msgstr "type" msgstr "type"
#: apps/activity/models.py:63 templates/activity/activity_detail.html:28 #: apps/activity/models.py:65 templates/activity/activity_detail.html:28
msgid "organizer" msgid "organizer"
msgstr "organisateur" msgstr "organisateur"
#: apps/activity/models.py:72 apps/activity/models.py:113 apps/note/apps.py:14 #: apps/activity/models.py:72 apps/activity/models.py:120 apps/note/apps.py:14
#: apps/note/models/notes.py:58 #: apps/note/models/notes.py:58
msgid "note" msgid "note"
msgstr "note" msgstr "note"
#: apps/activity/models.py:79 templates/activity/activity_detail.html:31 #: apps/activity/models.py:79 templates/activity/activity_detail.html:31
msgid "attendees club" msgid "attendees club"
msgstr "" msgstr "club attendu"
#: apps/activity/models.py:83 templates/activity/activity_detail.html:22 #: apps/activity/models.py:83 templates/activity/activity_detail.html:22
msgid "start date" msgid "start date"
@ -80,59 +81,96 @@ msgstr "valide"
#: apps/activity/models.py:97 templates/activity/activity_detail.html:56 #: apps/activity/models.py:97 templates/activity/activity_detail.html:56
msgid "open" msgid "open"
msgstr "" msgstr "ouvrir"
#: apps/activity/models.py:102 #: apps/activity/models.py:102
msgid "activities" msgid "activities"
msgstr "activités" msgstr "activités"
#: apps/activity/models.py:107 #: apps/activity/models.py:114
msgid "entry time" msgid "entry time"
msgstr "" msgstr "heure d'entrée"
#: apps/activity/models.py:129 #: apps/activity/models.py:137
msgid "Already entered on "
msgstr "Déjà rentré le "
#: apps/activity/models.py:137 apps/activity/tables.py:54
msgid "{:%Y-%m-%d %H:%M:%S}"
msgstr "{:%d/%m/%Y %H:%M:%S}"
#: apps/activity/models.py:145
msgid "The balance is negative."
msgstr "La note est en négatif."
#: apps/activity/models.py:177
msgid "last name" msgid "last name"
msgstr "nom de famille" msgstr "nom de famille"
#: apps/activity/models.py:134 templates/member/profile_info.html:14 #: apps/activity/models.py:182 templates/member/profile_info.html:14
msgid "first name" msgid "first name"
msgstr "prénom" msgstr "prénom"
#: apps/activity/models.py:141 #: apps/activity/models.py:189
msgid "inviter" msgid "inviter"
msgstr "hôte" msgstr "hôte"
#: apps/activity/models.py:151 #: apps/activity/models.py:202
msgid "guest" msgid "guest"
msgstr "invité" msgstr "invité"
#: apps/activity/models.py:152 #: apps/activity/models.py:203
msgid "guests" msgid "guests"
msgstr "invités" msgstr "invités"
#: apps/activity/models.py:163 #: apps/activity/models.py:214
msgid "Invitation" msgid "Invitation"
msgstr "Invitation" msgstr "Invitation"
#: apps/activity/tables.py:54 #: apps/activity/tables.py:54
msgid "Entered on "
msgstr "Entré le "
#: apps/activity/tables.py:55
msgid "remove" msgid "remove"
msgstr "supprimer" msgstr "supprimer"
#: apps/activity/views.py:34 #: apps/activity/tables.py:75 apps/treasury/models.py:126
msgid "Upcoming activities" msgid "Type"
msgstr "Activités à venir" msgstr "Type"
#: apps/activity/views.py:119 #: apps/activity/tables.py:77 apps/treasury/forms.py:120
msgid "Last name"
msgstr "Nom de famille"
#: apps/activity/tables.py:79 apps/treasury/forms.py:122
#: templates/note/transaction_form.html:92
msgid "First name"
msgstr "Prénom"
#: apps/activity/tables.py:81 apps/note/models/notes.py:67
msgid "Note"
msgstr "Note"
#: apps/activity/tables.py:83
msgid "Balance"
msgstr "Solde du compte"
#: apps/activity/views.py:35 templates/base.html:94
msgid "Activities"
msgstr "Activités"
#: apps/activity/views.py:130
msgid "Entry for activity \"{}\"" msgid "Entry for activity \"{}\""
msgstr "Entrées pour l'activité « {} »" msgstr "Entrées pour l'activité « {} »"
#: apps/api/apps.py:10 #: apps/api/apps.py:10
msgid "API" msgid "API"
msgstr "" msgstr "API"
#: apps/logs/apps.py:11 #: apps/logs/apps.py:11
msgid "Logs" msgid "Logs"
msgstr "" msgstr "Logs"
#: apps/logs/models.py:21 apps/note/models/notes.py:117 #: apps/logs/models.py:21 apps/note/models/notes.py:117
msgid "user" msgid "user"
@ -283,7 +321,7 @@ msgstr "cotisation"
#: apps/member/models.py:172 #: apps/member/models.py:172
msgid "User is not a member of the parent club" msgid "User is not a member of the parent club"
msgstr "" msgstr "L'utilisateur n'est pas membre du club parent"
#: apps/member/models.py:176 #: apps/member/models.py:176
msgid "membership" msgid "membership"
@ -357,10 +395,6 @@ msgstr "créée le"
msgid "notes" msgid "notes"
msgstr "notes" msgstr "notes"
#: apps/note/models/notes.py:67
msgid "Note"
msgstr "Note"
#: apps/note/models/notes.py:77 apps/note/models/notes.py:101 #: apps/note/models/notes.py:77 apps/note/models/notes.py:101
msgid "This alias is already taken." msgid "This alias is already taken."
msgstr "Cet alias est déjà pris." msgstr "Cet alias est déjà pris."
@ -573,14 +607,6 @@ msgstr "La remise est déjà fermée."
msgid "You can't change the type of the remittance." msgid "You can't change the type of the remittance."
msgstr "Vous ne pouvez pas changer le type de la remise." msgstr "Vous ne pouvez pas changer le type de la remise."
#: apps/treasury/forms.py:120
msgid "Last name"
msgstr "Nom de famille"
#: apps/treasury/forms.py:122 templates/note/transaction_form.html:92
msgid "First name"
msgstr "Prénom"
#: apps/treasury/forms.py:124 templates/note/transaction_form.html:98 #: apps/treasury/forms.py:124 templates/note/transaction_form.html:98
msgid "Bank" msgid "Bank"
msgstr "Banque" msgstr "Banque"
@ -639,10 +665,6 @@ msgstr "Prix unitaire"
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: apps/treasury/models.py:126
msgid "Type"
msgstr "Type"
#: apps/treasury/models.py:131 #: apps/treasury/models.py:131
msgid "Comment" msgid "Comment"
msgstr "Commentaire" msgstr "Commentaire"
@ -733,10 +755,34 @@ msgstr "Inviter"
msgid "Guests list" msgid "Guests list"
msgstr "Liste des invités" msgstr "Liste des invités"
#: templates/activity/activity_list.html:7 #: templates/activity/activity_entry.html:10
msgid "Return to activity page"
msgstr "Retour à la page de l'activité"
#: templates/activity/activity_entry.html:18
msgid "entries"
msgstr "entrées"
#: templates/activity/activity_entry.html:18
msgid "entry"
msgstr "entrée"
#: templates/activity/activity_list.html:5
msgid "Upcoming activities"
msgstr "Activités à venir"
#: templates/activity/activity_list.html:10
msgid "There is no planned activity."
msgstr "Il n'y a pas d'activité prévue."
#: templates/activity/activity_list.html:14
msgid "New activity" msgid "New activity"
msgstr "Nouvelle activité" msgstr "Nouvelle activité"
#: templates/activity/activity_list.html:18
msgid "All activities"
msgstr "Toutes les activités"
#: templates/base.html:13 #: templates/base.html:13
msgid "The ENS Paris-Saclay BDE note." msgid "The ENS Paris-Saclay BDE note."
msgstr "La note du BDE de l'ENS Paris-Saclay." msgstr "La note du BDE de l'ENS Paris-Saclay."
@ -745,10 +791,6 @@ msgstr "La note du BDE de l'ENS Paris-Saclay."
msgid "Clubs" msgid "Clubs"
msgstr "Clubs" msgstr "Clubs"
#: templates/base.html:94
msgid "Activities"
msgstr "Activités"
#: templates/cas_server/base.html:7 #: templates/cas_server/base.html:7
msgid "Central Authentication Service" msgid "Central Authentication Service"
msgstr "" msgstr ""
@ -882,9 +924,6 @@ msgstr "Changer le mot de passe"
msgid "balance" msgid "balance"
msgstr "solde du compte" msgstr "solde du compte"
msgid "Balance"
msgstr "Solde du compte"
#: templates/member/profile_info.html:41 #: templates/member/profile_info.html:41
msgid "Manage auth token" msgid "Manage auth token"
msgstr "Gérer les jetons d'authentification" msgstr "Gérer les jetons d'authentification"
@ -1138,21 +1177,3 @@ msgstr "Il n'y a pas de transaction associée à une remise ouverte."
#: templates/treasury/remittance_list.html:54 #: templates/treasury/remittance_list.html:54
msgid "Closed remittances" msgid "Closed remittances"
msgstr "Remises fermées" msgstr "Remises fermées"
#~ msgid "Account #%(id)s: %(username)s"
#~ msgstr "Compte n°%(id)s : %(username)s"
#~ msgid "Alias successfully deleted"
#~ msgstr "L'alias a bien été supprimé"
#~ msgid "New Alias"
#~ msgstr "Nouvel alias"
#~ msgid "Membership starts on"
#~ msgstr "L'adhésion commence le"
#~ msgid "Membership ends on"
#~ msgstr "L'adhésion finie le"
#~ msgid "Membership duration"
#~ msgstr "Durée de l'adhésion"

View File

@ -48,7 +48,7 @@
</div> </div>
<div class="card-footer text-center"> <div class="card-footer text-center">
{% if activity.open %} {% if activity.open and "change__open"|has_perm:activity %}
<a class="btn btn-warning btn-sm my-1" href="{% url 'activity:activity_entry' pk=activity.pk %}"> {% trans "Entry page" %}</a> <a class="btn btn-warning btn-sm my-1" href="{% url 'activity:activity_entry' pk=activity.pk %}"> {% trans "Entry page" %}</a>
{% endif %} {% endif %}

View File

@ -6,11 +6,16 @@
{% load perms %} {% load perms %}
{% block content %} {% block content %}
<a href="{% url "activity:activity_detail" pk=activity.pk %}">
<button class="btn btn-light">{% trans "Return to activity page" %}</button>
</a>
<input id="alias" type="text" class="form-control" placeholder="Nom/note ..."> <input id="alias" type="text" class="form-control" placeholder="Nom/note ...">
<hr> <hr>
<div id="entry_table"> <div id="entry_table">
<h2 class="text-center">{{ entries.count }} {% if entries.count >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %}</h2>
{% render_table table %} {% render_table table %}
</div> </div>
{% endblock %} {% endblock %}
@ -41,6 +46,8 @@
let type = target.attr("data-type"); let type = target.attr("data-type");
let id = target.attr("data-id"); let id = target.attr("data-id");
let last_name = target.attr("data-last-name");
let first_name = target.attr("data-first-name");
if (type === "membership") { if (type === "membership") {
$.post("/api/activity/entry/?format=json", { $.post("/api/activity/entry/?format=json", {
@ -56,7 +63,21 @@
}); });
} }
else { else {
let line_obj = $("#buttons_guest_" + id);
if (line_obj.length || target.attr('class').includes("table-success")) {
line_obj.remove();
return;
} }
let tr = "<tr class='text-center'>" +
"<td id='buttons_guest_" + id + "' style='table-danger center' colspan='5'>" +
"<button id='transaction_guest_" + id + "' class='btn btn-secondary'>Payer avec la note de l'hôte</button> " +
"<button id='transaction_guest_" + id + "_especes' class='btn btn-secondary'>Payer en espèces</button> " +
"<button id='transaction_guest_" + id + "_cb' class='btn btn-secondary'>Payer en CB</button></td>" +
"<tr>";
$(tr).insertAfter(target);
let makeTransaction = function() {
$.post("/api/activity/entry/?format=json", { $.post("/api/activity/entry/?format=json", {
csrfmiddlewaretoken: CSRF_TOKEN, csrfmiddlewaretoken: CSRF_TOKEN,
activity: {{ activity.id }}, activity: {{ activity.id }},
@ -68,6 +89,37 @@
}).fail(function (xhr) { }).fail(function (xhr) {
errMsg(xhr.responseJSON); errMsg(xhr.responseJSON);
}); });
};
let credit = function(credit_id, credit_name) {
return function() {
$.post("/api/note/transaction/transaction/",
{
"csrfmiddlewaretoken": CSRF_TOKEN,
"quantity": 1,
"amount": {{ activity.activity_type.guest_entry_fee }},
"reason": "Crédit " + credit_name + " (invitation {{ activity.name }})",
"valid": true,
"polymorphic_ctype": {{ notespecial_ctype }},
"resourcetype": "SpecialTransaction",
"source": credit_id,
"destination": target.attr('data-inviter'),
"last_name": last_name,
"first_name": first_name,
"bank": ""
}).done(function () {
makeTransaction();
reset();
}).fail(function (xhr) {
errMsg(xhr.responseJSON);
});
};
};
$("#transaction_guest_" + id).click(makeTransaction);
$("#transaction_guest_" + id + "_especes").click(credit(1, "espèces"));
$("#transaction_guest_" + id + "_cb").click(credit(2, "carte bancaire"));
}
}); });
} }
</script> </script>

View File

@ -2,9 +2,22 @@
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% load i18n crispy_forms_tags%} {% load i18n crispy_forms_tags%}
{% block content %} {% block content %}
{% render_table table %} <h2>{% trans "Upcoming activities" %}</h2>
{% if upcoming.data %}
{% render_table upcoming %}
{% else %}
<div class="alert alert-warning">
{% trans "There is no planned activity." %}
</div>
{% endif %}
<a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a> <a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a>
<hr>
<h2>{% trans "All activities" %}</h2>
{% render_table table %}
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}