Verified Commit b6c71a5a authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

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

parent e6db9460
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-21 23:25+0200\n"
"PO-Revision-Date: 2017-07-21 23:26+0200\n"
"POT-Creation-Date: 2017-08-16 22:58+0200\n"
"PO-Revision-Date: 2017-08-16 23:00+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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
msgid "Event Date"
......@@ -230,35 +230,47 @@ msgstr "veldnaam"
msgid "required"
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"
msgstr "naam"
#: models.py:338
#: models.py:343
msgid "Use this for non-members"
msgstr "Gebruikt dit voor niet-leden"
#: models.py:343
#: models.py:348
msgid "registration date"
msgstr "aanmelddatum"
#: models.py:345
#: models.py:350
msgid "cancellation date"
msgstr "afmelddatum"
#: models.py:350 templates/events/admin/registrations_table.html:11
#: models.py:355 templates/events/admin/registrations_table.html:11
msgid "present"
msgstr "aanwezig"
#: models.py:354 templates/events/admin/registrations_table.html:12
msgid "paid"
msgstr "betaald"
#: models.py:362
msgid "payment"
msgstr "betaling"
#: models.py:405 models.py:406
#: models.py:413 models.py:414
msgid "Either specify a member or a name"
msgstr "Geef een lid of een naam op"
#: models.py:428
#: models.py:436
msgid "last changed"
msgstr "laatst aangepast"
......@@ -317,7 +329,7 @@ msgid "Event properties"
msgstr "Eigenschappen van evenement"
#: templates/events/admin/details.html:63
#: templates/events/admin/registrations_table.html:46
#: templates/events/admin/registrations_table.html:50
msgid "change"
msgstr "verander"
......@@ -353,19 +365,31 @@ msgid_plural "%(counter)s registrations"
msgstr[0] "%(counter)s aanmelding"
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
msgid "paid card"
msgstr "pin betaald"
#: templates/events/admin/registrations_table.html:16
msgid "late"
msgstr "te laat"
#: templates/events/admin/registrations_table.html:18
#: templates/events/admin/registrations_table.html:20
msgid "add"
msgstr "toevoegen"
#: templates/events/admin/registrations_table.html:50
#: templates/events/admin/registrations_table.html:54
msgid "registered"
msgstr "aangemeld"
#: templates/events/admin/registrations_table.html:51
#: templates/events/admin/registrations_table.html:55
#, python-format
msgid "Nobody %(verb)s yet"
msgstr "Niemand heeft zich %(verb)s"
......@@ -556,56 +580,56 @@ msgstr "Toon verjaardagen"
msgid "list"
msgstr "Lijst"
#: views.py:91
#: views.py:94
msgctxt "registration status"
msgid "registered"
msgstr "aangemeld"
#: views.py:97 views.py:132
#: views.py:100 views.py:135
msgctxt "registration status"
msgid "late cancellation"
msgstr "te laat afgemeld"
#: views.py:99
#: views.py:102
msgctxt "registration status"
msgid "cancelled"
msgstr "afgemeld"
#: views.py:103
#: views.py:106
msgctxt "registration status"
msgid "waiting"
msgstr "wachtend"
#: views.py:108 views.py:119
#: views.py:111 views.py:122
msgid "Yes"
msgstr "Ja"
#: views.py:218
#: views.py:221
msgid "[THALIA] Notification about your registration for '{}'"
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."
msgstr "Je aanmelding was succesvol."
#: views.py:268
#: views.py:271
msgid ""
"You cannot re-register anymore since you've cancelled after the deadline."
msgstr ""
"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"
msgstr "Je mag niet je aanmelden"
#: views.py:289
#: views.py:292
msgid "You were already registered."
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."
msgstr "Je bent niet aangemeld voor dit evenement."
#: views.py:318
#: views.py:321
msgid "Registration successfully cancelled."
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):
class Registration(models.Model):
"""Event registrations"""
PAYMENT_TYPES = (
('no_payment', _('No payment')),
('cash_payment', _('Paid with cash')),
('card_payment', _('Paid with card')))
event = models.ForeignKey(Event, models.CASCADE)
member = models.ForeignKey(
......@@ -350,9 +355,12 @@ class Registration(models.Model):
_('present'),
default=False,
)
paid = models.BooleanField(
_('paid'),
default=False,
payment = models.CharField(
choices=PAYMENT_TYPES,
default='no_payment',
verbose_name=_('payment'),
max_length=20,
)
def registration_information(self):
......
......@@ -2,7 +2,7 @@ django.jQuery(function () {
var $ = django.jQuery;
var url = $("#content-main").attr("data-url");
var paid_url = url + "paid/";
var payment_url = url + "payment/";
var present_url = url + "present/";
$(".present-check").change(function () {
......@@ -18,17 +18,19 @@ django.jQuery(function () {
});
});
$(".paid-check").change(function () {
var checkbox = $(this);
var id = checkbox.attr("data-id");
var checked = checkbox.prop('checked');
post(paid_url, { checked: checked, id: id }, function(result) {
if (!result.success) {
checkbox.prop('checked', !checked);
}
}, function() {
checkbox.prop('checked', !checked);
});
$(".payment-radio").change(function () {
var radiobutton = $(this);
var id = radiobutton.attr("data-id");
var value = radiobutton.attr("data-value");
if (radiobutton.prop('checked')) {
post(payment_url, { value: value, id: id }, function(result) {
if (!result.success) {
radiobutton.prop('checked', !checked);
}
}, function() {
radiobutton.prop('checked', !checked);
});
}
});
});
......@@ -58,4 +60,4 @@ function getCookie(name) {
}
}
return cookieValue;
}
\ No newline at end of file
}
......@@ -9,7 +9,9 @@
<th scope="col">{{ field.name }}</th>
{% endfor %}
<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 %}
<th>{% trans "late"|capfirst %}</th>
{% endif %}
......@@ -39,7 +41,9 @@
{% endif %}
{% endfor %}
<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 %}
<td>{{ registration.is_late_cancellation|yesno }}</td>
{% endif %}
......
......@@ -53,14 +53,17 @@ def admin_change_registration(request, event_id, action=None):
try:
id = request.POST.get("id", -1)
checked = json.loads(request.POST.get("checked"))
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
elif action == 'paid':
obj.paid = checked
obj.save()
obj.save()
elif action == 'payment':
value = request.POST.get("value")
if value is not None:
obj.payment = value
obj.save()
except Registration.DoesNotExist:
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