Add option for open event registration

parent da42c1d5
......@@ -224,14 +224,16 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
@property
def registration_allowed(self):
now = timezone.now()
return ((self.registration_start or self.registration_end) and
self.registration_end > now >= self.registration_start)
if self.registration_start or self.registration_end:
return self.registration_end > now >= self.registration_start
return self.end > now
@property
def cancellation_allowed(self):
now = timezone.now()
return ((self.registration_start or self.registration_end)
and self.registration_start <= now < self.start)
if self.registration_start or self.registration_end:
return self.registration_start <= now < self.start
return self.end > now
def is_pizza_event(self):
try:
......@@ -518,7 +520,7 @@ class Registration(models.Model):
def would_cancel_after_deadline(self):
now = timezone.now()
return (self.queue_position == 0 and
return (self.event.cancel_deadline and self.queue_position == 0 and
now >= self.event.cancel_deadline)
def clean(self):
......
......@@ -131,6 +131,7 @@
</form>
{% endif %}
{% if permissions.create_registration %}
{% if event.registration_required %}
<p>
{% url 'event-registration-terms' as terms_url %}
{% blocktrans trimmed %}
......@@ -140,27 +141,33 @@
that you understand them and that you agree to be bound by them.
{% endblocktrans %}
</p>
{% endif %}
<form action="{% url 'events:register' event.id %}" method="post">{% csrf_token %}
{% if event.reached_participants_limit %}
{% if event.reached_participants_limit and event.registration_required %}
<input type="submit" class="btn btn-primary"
value="{% trans "Put me on the waiting list" %}"/>
{% else %}
{% elif event.registration_required %}
<input type="submit" class="btn btn-primary"
value="{% trans "Register" %}"/>
{% else %}
<input type="submit" class="btn btn-primary"
value="{% trans "I'm going" %}"/>
{% endif %}
</form>
{% elif permissions.cancel_registration %}
{# Special message to accept costs when cancelling after the deadline, unless member is on the waiting list #}
<form action="{% url 'events:cancel' event.id %}" method="post">{% csrf_token %}
{% if registration.would_cancel_after_deadline %}
{% if registration.would_cancel_after_deadline and event.registration_required %}
<input type="submit" class="btn btn-primary"
value="{% trans "Cancel registration" %}"
onclick="return confirm('{% blocktrans trimmed with costs=event.fine %}The deadline has passed, are you sure you want to cancel your registration and pay the estimated full costs of €{{ costs }}? You will not be able to undo this!{% endblocktrans %}');"/>
{% else %}
{% elif event.registration_required %}
<input type="submit" class="btn btn-primary"
value="{% trans "Cancel registration" %}"
onclick="return confirm('{% trans 'Are you sure you want to cancel your registration?' %}');"/>
{% else %}
<input type="submit" class="btn btn-primary"
value="{% trans "Cancel registration" %}" />
{% endif %}
</form>
{% elif request.user.is_authenticated is False %}
......
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