Commit 324e289f authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Clean HTML, fix cancellation and enable cancelling after deadline with special confirmation.

parent f71ea9c0
......@@ -108,8 +108,8 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
published = models.BooleanField(_("published"), default=False)
def after_deadline(self):
return self.registration_end < timezone.now()
def after_cancel_deadline(self):
return self.cancel_deadline <= timezone.now()
def registration_required(self):
return bool(self.registration_start) or bool(self.registration_end)
......
......@@ -84,50 +84,10 @@
</tr>
{% endif %}
{% endif %}
{# Todo implement aanmeldmechanisme #}
{# <?php#}
{##}
{# /*#}
{# * Preparation for button#}
{# */#}
{# // Get registration status#}
{# $registration_status = $activity->getRegistrationStatus();#}
{# $afterDeadline = false;#}
{##}
{# // Determine link and text for button#}
{# if(!$user->isLoggedIn() || $registration_status === ActivityModel::REGISTRATION_NOT_NEEDED) {#}
{# $show_button = false;#}
{# } elseif(!($registered && $registration->isRegisteredExcludeCoolDown())) {#}
{# // Not yet registered#}
{# if ($registration_count >= $activity->registration_limit) {#}
{# $button_text = "Op reservelijst";#}
{# } else {#}
{# $button_text = "Aanmelden";#}
{# }#}
{# if($registration !== null && $registration->isInCoolDown()) {#}
{# $button_text = "Afmelding annuleren";#}
{# }#}
{# $show_button = $registration_status === ActivityModel::REGISTRATION_OPEN || $registration_status === ActivityModel::REGISTRATION_CLOSED_REGISTER_ONLY;#}
{# $intent = "register";#}
{# } else {#}
{# // Already registered#}
{# $button_text = "Afmelden";#}
{# $show_button = true;#}
{# if(!$activity->canCancel())#}
{# {#}
{# $afterDeadline = true;#}
{# $costText = empty($activity->thalia_costs) ? '' : ' van ongeveer € ' . number_format($activity->thalia_costs, 2, ',', '.');#}
{# $confirmText = 'De deadline is verstreken, weet je zeker dat je je wilt afmelden en daarmee een boete krijgt' . $costText . '? Je kunt dit niet ongedaan maken.';#}
{##}
{# }#}
{# $intent = "cancel";#}
{# }#}
{# ?>#}
<tr>
<td></td>
<td>
{% if request.user.is_authenticated %}
{% if request.user.is_authenticated and request.user.member is not None and request.user.member.current_membership is not None %}
{% if event.status == event.REGISTRATION_OPEN or event.status == event.REGISTRATION_OPEN_NO_CANCEL %}
{% if registration is not None and registration.date_cancelled is None and event.has_fields %}
<a class="btn btn-style1" href="{% url 'events:registration' event.id 'update' %}">{% trans "Update registration" %}</a>
......@@ -146,11 +106,15 @@
</a>
{% endif %}
{% elif registration is not None and registration.date_cancelled is None %}
{# TODO: Specific message to accept costs when cancelling after the deadline, unless member is on the waiting list #}
<a class="btn btn-style1" href="{% url 'events:registration' event.id 'cancel' %}" onclick="return confirm('{% trans "Are you sure you want to cancel your registration?" %}');">{% trans "Cancel registration" %}</a>
{# Special message to accept costs when cancelling after the deadline, unless member is on the waiting list #}
{% if registration.queue_position == 0 and event.after_cancel_deadline %}
<a class="btn btn-style1" href="{% url 'events:registration' event.id 'cancel' %}" onclick="return confirm('{% blocktrans with costs=event.cost %}The deadline has passed, are you sure you want to cancel your registration and pay the full costs of €{{ costs }}? You will not be able to undo this!{% endblocktrans %}');">{% trans "Cancel registration" %}</a>
{% else %}
<a class="btn btn-style1" href="{% url 'events:registration' event.id 'cancel' %}" onclick="return confirm('{% trans "Are you sure you want to cancel your registration?" %}');">{% trans "Cancel registration" %}</a>
{% endif %}
{% endif %}
{% endif %}
{% else %}
{% elif request.user.is_authenticated is False %}
<a class="btn btn-style1" href="{% url 'login' %}?next={{ request.path }}">{% trans "Login" %}</a>
{% endif %}
</td>
......@@ -164,10 +128,6 @@
{% trans "You have to log in before you can register for this event." %}
{% elif event.status == event.REGISTRATION_NOT_YET_OPEN %}
{% blocktrans with datetime=event.registration_start %}Registration will open {{ datetime }}{% endblocktrans %}
{% elif event.status == event.REGISTRATION_OPEN_NO_CANCEL and registration.date_cancelled is None %}
{% if event.costs > 0 %}
{% blocktrans with costs=event.costs %}Cancellation isn't possible anymore without having to pay the full costs of {{ costs }}{% endblocktrans %}
{% endif %}
{% elif event.status == event.REGISTRATION_CLOSED or event.status == event.REGISTRATION_CLOSED_CANCEL_ONLY %}
{% blocktrans %}Registration is not possible anymore.{% endblocktrans %}
{% elif status == event.REGISTRATION_NOT_NEEDED %}
......@@ -177,21 +137,27 @@
{% trans "No registration required" %}
{% endif %}
{% endif %}
{% if event.status == event.REGISTRATION_OPEN_NO_CANCEL or event.status == event.REGISTRATION_CLOSED %}
{% if registration.date_cancelled is None and event.cost > 0 %}
{% blocktrans with costs=event.cost %}Cancellation isn't possible anymore without having to pay the full costs of €{{ costs }}. Also note that you will be unable to re-register.{% endblocktrans %}
{% endif %}
{% endif %}
</em>
</td>
</tr>
{# TODO IMPLEMENT PIZZA BUTTON #}
{# <tr>#}
{# <th>#}
{# Pizza#}
{# </th>#}
{# <td>#}
{# <a href="<?php echo $pizzaActivity->getUrl(); ?>" class="btn btn-style1">#}
{# Bestellen#}
{# </a>#}
{# </td>#}
{# </tr>#}
{# <?php endif; ?>#}
{#{% if event.pizzaevent %}#}
{#<tr>#}
{#<th>#}
{#Pizza#}
{#</th>#}
{#<td>#}
{#<a href="{{ url "pizzas:index" }}" class="btn btn-style1">#}
{#{% trans "Order" %}#}
{#</a>#}
{#</td>#}
{#</tr>#}
{#{% endif %}#}
</tbody>
</table>
</div>
......
......@@ -139,8 +139,8 @@ def registration(request, event_id, action=None):
pk=event_id
)
if (event.registration_required() and
event.status != Event.REGISTRATION_NOT_NEEDED):
if (event.status != Event.REGISTRATION_NOT_NEEDED and
request.user.member.current_membership is not None):
try:
obj = Registration.objects.get(
event=event,
......@@ -174,18 +174,15 @@ def registration(request, event_id, action=None):
error_message = _("You were already registered.")
if error_message is None:
success_message = _("Registration successful")
success_message = _("Registration successful.")
elif (action == 'update'
and event.has_fields()
and obj is not None and
event.status == Event.REGISTRATION_OPEN or
event.status == Event.REGISTRATION_OPEN_NO_CANCEL):
and obj is not None
and (event.status == Event.REGISTRATION_OPEN or
event.status == Event.REGISTRATION_OPEN_NO_CANCEL)):
show_fields = True
success_message = _("Registration successfully updated")
elif action == 'cancel' and (
event.status == Event.REGISTRATION_OPEN or
event.status == Event.REGISTRATION_CLOSED_CANCEL_ONLY
):
success_message = _("Registration successfully updated.")
elif action == 'cancel':
if (obj is not None and
obj.date_cancelled is None):
# Note that this doesn't remove the values for the
......@@ -193,7 +190,7 @@ def registration(request, event_id, action=None):
# But this is regarded as a feature, not a bug. Especially
# since the values will still appear in the backend.
obj.date_cancelled = timezone.now()
success_message = _("Registration successfully cancelled")
success_message = _("Registration successfully cancelled.")
else:
error_message = _("You were not registered for this event.")
......@@ -201,11 +198,11 @@ def registration(request, event_id, action=None):
if request.POST:
form = FieldsForm(request.POST, registration=obj)
if form.is_valid():
obj.save()
form_field_values = form.field_values()
for field in form_field_values:
field['field'].set_value_for(obj,
field['value'])
obj.save()
else:
form = FieldsForm(registration=obj)
context = {'event': event, 'form': form, 'action': action}
......
Markdown is supported
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