Commit 730f686b authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

Merge branch 'feature/payment-type-registration' into 'master'

Change paid boolean value for registration to enum field to support registration of pin payments

Closes #457

See merge request !528
parents 9f597408 b6c71a5a
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-21 23:25+0200\n" "POT-Creation-Date: 2017-08-16 22:58+0200\n"
"PO-Revision-Date: 2017-07-21 23:26+0200\n" "PO-Revision-Date: 2017-08-16 23:00+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n" "Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: nl\n" "Language: nl\n"
...@@ -16,7 +16,7 @@ msgstr "" ...@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.2\n" "X-Generator: Poedit 2.0.3\n"
#: admin.py:89 #: admin.py:89
msgid "Event Date" msgid "Event Date"
...@@ -230,35 +230,47 @@ msgstr "veldnaam" ...@@ -230,35 +230,47 @@ msgstr "veldnaam"
msgid "required" msgid "required"
msgstr "verplicht" msgstr "verplicht"
#: models.py:336 templates/events/admin/registrations_table.html:6 #: models.py:326
msgid "No payment"
msgstr "Niet betaald"
#: models.py:327
msgid "Paid with cash"
msgstr "Contant betaald"
#: models.py:328
msgid "Paid with card"
msgstr "Pin betaald"
#: models.py:341 templates/events/admin/registrations_table.html:6
msgid "name" msgid "name"
msgstr "naam" msgstr "naam"
#: models.py:338 #: models.py:343
msgid "Use this for non-members" msgid "Use this for non-members"
msgstr "Gebruikt dit voor niet-leden" msgstr "Gebruikt dit voor niet-leden"
#: models.py:343 #: models.py:348
msgid "registration date" msgid "registration date"
msgstr "aanmelddatum" msgstr "aanmelddatum"
#: models.py:345 #: models.py:350
msgid "cancellation date" msgid "cancellation date"
msgstr "afmelddatum" msgstr "afmelddatum"
#: models.py:350 templates/events/admin/registrations_table.html:11 #: models.py:355 templates/events/admin/registrations_table.html:11
msgid "present" msgid "present"
msgstr "aanwezig" msgstr "aanwezig"
#: models.py:354 templates/events/admin/registrations_table.html:12 #: models.py:362
msgid "paid" msgid "payment"
msgstr "betaald" msgstr "betaling"
#: models.py:405 models.py:406 #: models.py:413 models.py:414
msgid "Either specify a member or a name" msgid "Either specify a member or a name"
msgstr "Geef een lid of een naam op" msgstr "Geef een lid of een naam op"
#: models.py:428 #: models.py:436
msgid "last changed" msgid "last changed"
msgstr "laatst aangepast" msgstr "laatst aangepast"
...@@ -317,7 +329,7 @@ msgid "Event properties" ...@@ -317,7 +329,7 @@ msgid "Event properties"
msgstr "Eigenschappen van evenement" msgstr "Eigenschappen van evenement"
#: templates/events/admin/details.html:63 #: templates/events/admin/details.html:63
#: templates/events/admin/registrations_table.html:46 #: templates/events/admin/registrations_table.html:50
msgid "change" msgid "change"
msgstr "verander" msgstr "verander"
...@@ -353,19 +365,31 @@ msgid_plural "%(counter)s registrations" ...@@ -353,19 +365,31 @@ msgid_plural "%(counter)s registrations"
msgstr[0] "%(counter)s aanmelding" msgstr[0] "%(counter)s aanmelding"
msgstr[1] "%(counter)s aanmeldingen" msgstr[1] "%(counter)s aanmeldingen"
#: templates/events/admin/registrations_table.html:12
msgid "not paid"
msgstr "niet betaald"
#: templates/events/admin/registrations_table.html:13
msgid "paid cash"
msgstr "contant betaald"
#: templates/events/admin/registrations_table.html:14 #: templates/events/admin/registrations_table.html:14
msgid "paid card"
msgstr "pin betaald"
#: templates/events/admin/registrations_table.html:16
msgid "late" msgid "late"
msgstr "te laat" msgstr "te laat"
#: templates/events/admin/registrations_table.html:18 #: templates/events/admin/registrations_table.html:20
msgid "add" msgid "add"
msgstr "toevoegen" msgstr "toevoegen"
#: templates/events/admin/registrations_table.html:50 #: templates/events/admin/registrations_table.html:54
msgid "registered" msgid "registered"
msgstr "aangemeld" msgstr "aangemeld"
#: templates/events/admin/registrations_table.html:51 #: templates/events/admin/registrations_table.html:55
#, python-format #, python-format
msgid "Nobody %(verb)s yet" msgid "Nobody %(verb)s yet"
msgstr "Niemand heeft zich %(verb)s" msgstr "Niemand heeft zich %(verb)s"
...@@ -556,56 +580,56 @@ msgstr "Toon verjaardagen" ...@@ -556,56 +580,56 @@ msgstr "Toon verjaardagen"
msgid "list" msgid "list"
msgstr "Lijst" msgstr "Lijst"
#: views.py:91 #: views.py:94
msgctxt "registration status" msgctxt "registration status"
msgid "registered" msgid "registered"
msgstr "aangemeld" msgstr "aangemeld"
#: views.py:97 views.py:132 #: views.py:100 views.py:135
msgctxt "registration status" msgctxt "registration status"
msgid "late cancellation" msgid "late cancellation"
msgstr "te laat afgemeld" msgstr "te laat afgemeld"
#: views.py:99 #: views.py:102
msgctxt "registration status" msgctxt "registration status"
msgid "cancelled" msgid "cancelled"
msgstr "afgemeld" msgstr "afgemeld"
#: views.py:103 #: views.py:106
msgctxt "registration status" msgctxt "registration status"
msgid "waiting" msgid "waiting"
msgstr "wachtend" msgstr "wachtend"
#: views.py:108 views.py:119 #: views.py:111 views.py:122
msgid "Yes" msgid "Yes"
msgstr "Ja" msgstr "Ja"
#: views.py:218 #: views.py:221
msgid "[THALIA] Notification about your registration for '{}'" msgid "[THALIA] Notification about your registration for '{}'"
msgstr "[THALIA] Bericht over je aanmelding voor ‘{}’" msgstr "[THALIA] Bericht over je aanmelding voor ‘{}’"
#: views.py:262 views.py:273 views.py:286 #: views.py:265 views.py:276 views.py:289
msgid "Registration successful." msgid "Registration successful."
msgstr "Je aanmelding was succesvol." msgstr "Je aanmelding was succesvol."
#: views.py:268 #: views.py:271
msgid "" msgid ""
"You cannot re-register anymore since you've cancelled after the deadline." "You cannot re-register anymore since you've cancelled after the deadline."
msgstr "" msgstr ""
"Je kunt je niet opnieuw aanmelden omdat je je hebt afgemeld na de deadline." "Je kunt je niet opnieuw aanmelden omdat je je hebt afgemeld na de deadline."
#: views.py:281 #: views.py:284
msgid "You may not register" msgid "You may not register"
msgstr "Je mag niet je aanmelden" msgstr "Je mag niet je aanmelden"
#: views.py:289 #: views.py:292
msgid "You were already registered." msgid "You were already registered."
msgstr "Je bent al aangemeld." msgstr "Je bent al aangemeld."
#: views.py:298 views.py:306 #: views.py:301 views.py:309
msgid "You are not registered for this event." msgid "You are not registered for this event."
msgstr "Je bent niet aangemeld voor dit evenement." msgstr "Je bent niet aangemeld voor dit evenement."
#: views.py:318 #: views.py:321
msgid "Registration successfully cancelled." msgid "Registration successfully cancelled."
msgstr "Je afmelding was succesvol." msgstr "Je afmelding was succesvol."
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-07-21 19:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0017_auto_20170524_2046'),
]
def forwards_func(apps, schema_editor):
Registration = apps.get_model('events', 'registration')
db_alias = schema_editor.connection.alias
for reg in Registration.objects.using(db_alias).all():
if reg.paid:
reg.payment = 'cash_payment'
reg.save()
def reverse_func(apps, schema_editor):
Registration = apps.get_model('events', 'registration')
db_alias = schema_editor.connection.alias
for reg in Registration.objects.using(db_alias).all():
if reg.payment != 'no_payment':
reg.paid = True
reg.save()
operations = [
migrations.AddField(
model_name='registration',
name='payment',
field=models.CharField(choices=[('no_payment', 'No payment'), ('cash_payment', 'Paid with cash'), ('card_payment', 'Paid with card')], default='no_payment', max_length=20, verbose_name='payment'),
),
migrations.RunPython(forwards_func, reverse_func),
migrations.RemoveField(
model_name='registration',
name='paid'
)
]
...@@ -322,6 +322,11 @@ class RegistrationInformationField(models.Model, metaclass=ModelTranslateMeta): ...@@ -322,6 +322,11 @@ class RegistrationInformationField(models.Model, metaclass=ModelTranslateMeta):
class Registration(models.Model): class Registration(models.Model):
"""Event registrations""" """Event registrations"""
PAYMENT_TYPES = (
('no_payment', _('No payment')),
('cash_payment', _('Paid with cash')),
('card_payment', _('Paid with card')))
event = models.ForeignKey(Event, models.CASCADE) event = models.ForeignKey(Event, models.CASCADE)
member = models.ForeignKey( member = models.ForeignKey(
...@@ -350,9 +355,12 @@ class Registration(models.Model): ...@@ -350,9 +355,12 @@ class Registration(models.Model):
_('present'), _('present'),
default=False, default=False,
) )
paid = models.BooleanField(
_('paid'), payment = models.CharField(
default=False, choices=PAYMENT_TYPES,
default='no_payment',
verbose_name=_('payment'),
max_length=20,
) )
def registration_information(self): def registration_information(self):
......
...@@ -2,7 +2,7 @@ django.jQuery(function () { ...@@ -2,7 +2,7 @@ django.jQuery(function () {
var $ = django.jQuery; var $ = django.jQuery;
var url = $("#content-main").attr("data-url"); var url = $("#content-main").attr("data-url");
var paid_url = url + "paid/"; var payment_url = url + "payment/";
var present_url = url + "present/"; var present_url = url + "present/";
$(".present-check").change(function () { $(".present-check").change(function () {
...@@ -18,17 +18,19 @@ django.jQuery(function () { ...@@ -18,17 +18,19 @@ django.jQuery(function () {
}); });
}); });
$(".paid-check").change(function () { $(".payment-radio").change(function () {
var checkbox = $(this); var radiobutton = $(this);
var id = checkbox.attr("data-id"); var id = radiobutton.attr("data-id");
var checked = checkbox.prop('checked'); var value = radiobutton.attr("data-value");
post(paid_url, { checked: checked, id: id }, function(result) { if (radiobutton.prop('checked')) {
if (!result.success) { post(payment_url, { value: value, id: id }, function(result) {
checkbox.prop('checked', !checked); if (!result.success) {
} radiobutton.prop('checked', !checked);
}, function() { }
checkbox.prop('checked', !checked); }, function() {
}); radiobutton.prop('checked', !checked);
});
}
}); });
}); });
...@@ -58,4 +60,4 @@ function getCookie(name) { ...@@ -58,4 +60,4 @@ function getCookie(name) {
} }
} }
return cookieValue; return cookieValue;
} }
\ No newline at end of file
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
<th scope="col">{{ field.name }}</th> <th scope="col">{{ field.name }}</th>
{% endfor %} {% endfor %}
<th>{% trans "present"|capfirst %}</th> <th>{% trans "present"|capfirst %}</th>
<th>{% trans "paid"|capfirst %}</th> <th>{% trans "not paid"|capfirst %}</th>
<th>{% trans "paid cash"|capfirst %}</th>
<th>{% trans "paid card"|capfirst %}</th>
{% if registrations|length > 0 and registrations.0.date_cancelled is not None %} {% if registrations|length > 0 and registrations.0.date_cancelled is not None %}
<th>{% trans "late"|capfirst %}</th> <th>{% trans "late"|capfirst %}</th>
{% endif %} {% endif %}
...@@ -39,7 +41,9 @@ ...@@ -39,7 +41,9 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<td><input type="checkbox" {{ registration.present|yesno:'checked="checked",' }} data-id="{{ registration.id }}" class="present-check" /></td> <td><input type="checkbox" {{ registration.present|yesno:'checked="checked",' }} data-id="{{ registration.id }}" class="present-check" /></td>
<td><input type="checkbox" {{ registration.paid|yesno:'checked="checked",' }} data-id="{{ registration.id }}" class="paid-check" /></td> <td><input type="radio" name="payment-{{ registration.id }}" {% if registration.payment == 'no_payment' %}checked="checked"{% endif %} data-value="no_payment" data-id="{{ registration.id }}" class="payment-radio" /></td>
<td><input type="radio" name="payment-{{ registration.id }}" {% if registration.payment == 'cash_payment' %}checked="checked"{% endif %} data-value="cash_payment" data-id="{{ registration.id }}" class="payment-radio" /></td>
<td><input type="radio" name="payment-{{ registration.id }}" {% if registration.payment == 'card_payment' %}checked="checked"{% endif %} data-value="card_payment" data-id="{{ registration.id }}" class="payment-radio" /></td>
{% if registration.date_cancelled is not None %} {% if registration.date_cancelled is not None %}
<td>{{ registration.is_late_cancellation|yesno }}</td> <td>{{ registration.is_late_cancellation|yesno }}</td>
{% endif %} {% endif %}
......
...@@ -54,14 +54,17 @@ def admin_change_registration(request, event_id, action=None): ...@@ -54,14 +54,17 @@ def admin_change_registration(request, event_id, action=None):
try: try:
id = request.POST.get("id", -1) id = request.POST.get("id", -1)
checked = json.loads(request.POST.get("checked"))
obj = Registration.objects.get(event=event_id, pk=id) obj = Registration.objects.get(event=event_id, pk=id)
if checked is not None: if action == 'present':
if action == 'present': checked = json.loads(request.POST.get("checked"))
if checked is not None:
obj.present = checked obj.present = checked
elif action == 'paid': obj.save()
obj.paid = checked elif action == 'payment':
obj.save() value = request.POST.get("value")
if value is not None:
obj.payment = value
obj.save()
except Registration.DoesNotExist: except Registration.DoesNotExist:
data['success'] = False data['success'] = False
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment