Commit db37c650 authored by Luuk Scholten's avatar Luuk Scholten Committed by Sébastiaan Versteeg

Implement first version of event view

parent 3ec66786
......@@ -60,4 +60,4 @@ class EventSerializer(CalenderJSSerializer):
model = Event
def _url(self, instance):
return reverse('#')
return reverse('events:event', kwargs={'event_id': instance.id})
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-16 08:38+0200\n"
"PO-Revision-Date: 2016-09-16 08:40+0200\n"
"POT-Creation-Date: 2016-09-16 08:49+0200\n"
"PO-Revision-Date: 2016-09-16 12:52+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: nl\n"
......@@ -75,6 +75,7 @@ msgid "cancel deadline"
msgstr "afmelddeadline"
#: models.py:54 templates/events/admin/details.html:55
#: templates/events/event.html:21
msgid "location"
msgstr "locatie"
......@@ -89,6 +90,7 @@ msgstr ""
"getoond als tekst!!"
#: models.py:66 templates/events/admin/details.html:57
#: templates/events/event.html:26
msgid "price"
msgstr "prijs"
......@@ -183,11 +185,11 @@ msgstr "aanwezig"
msgid "paid"
msgstr "betaald"
#: models.py:234 models.py:235
#: models.py:237 models.py:238
msgid "Either specify a member or a name"
msgstr "Geef een lid of een naam op"
#: models.py:257
#: models.py:260
msgid "last changed"
msgstr "laatst aangepast"
......@@ -255,6 +257,49 @@ msgstr "toevoegen"
msgid "Nobody %(verb)s yet"
msgstr "Niemand heeft zich %(verb)s"
#: templates/events/event.html:13
msgid "from"
msgstr "van"
#: templates/events/event.html:17
msgid "until"
msgstr "tot"
#: templates/events/event.html:32
msgid "registration deadline"
msgstr "aanmelddeadline"
#: templates/events/event.html:36
msgid "cancellation deadline"
msgstr "afmelddeadline"
#: templates/events/event.html:40
msgid "number of registrations"
msgstr "aantal aanmeldingen"
#: templates/events/event.html:42
#, python-format
msgid "%(counter)s registration"
msgid_plural "%(counter)s registrations"
msgstr[0] "%(counter)s aanmelding"
msgstr[1] "%(counter)s aanmeldingen"
#: templates/events/event.html:48
msgid "max"
msgstr "max"
#: templates/events/event.html:60
msgid "registration status"
msgstr "aanmeldstatus"
#: templates/events/event.html:157
msgid "You have to log in before you can register for this event."
msgstr "Je moet inloggen voordat je jezelf kunt aanmelden."
#: templates/events/event.html:241
msgid "cohort"
msgstr "jaarlaag"
#: templates/events/index.html:13
msgid "Calendar"
msgstr "Agenda"
......@@ -272,6 +317,19 @@ msgstr "Toon verjaardagen"
msgid "list"
msgstr "Lijst"
#~ msgid "From"
#~ msgstr "Vanaf"
#, fuzzy
#~| msgid "location"
#~ msgid "Location"
#~ msgstr "locatie"
#, fuzzy
#~| msgid "price"
#~ msgid "Price"
#~ msgstr "prijs"
#~ msgid "Present"
#~ msgstr "Aanwezig"
......
......@@ -230,6 +230,9 @@ class Registration(models.Model):
return [{'field': field, 'value': field.get_value_for(self)}
for field in fields]
def is_external(self):
return bool(self.name)
def clean(self):
if ((self.member is None and not self.name) or
(self.member and self.name)):
......
{% extends "base.html" %}
{% load i18n static %}
{% block body %}
<h1>{{ event.title }}</h1>
<p class="tcenter">{{ event.description }}</p>
<div class="clearfix row">
<div class="span6">
<table class="table borderless">
<tbody>
<tr>
<th>{% trans "from"|capfirst %}</th>
<td>{{ event.start }}</td>
</tr>
<tr>
<th>{% trans "until"|capfirst %}</th>
<td>{{ event.end }}</td>
</tr>
<tr>
<th>{% trans "location"|capfirst %}</th>
<td>{{ event.location }}</td>
</tr>
{% if event.price > 0 %}
<tr>
<th>{% trans "price"|capfirst %}</th>
<td> &euro;{{ event.price }}</td>
</tr>
{% endif %}
{% if event.registration_required %}
<tr>
<th>{% trans "registration deadline"|capfirst %}</th>
<td>{{ event.registration_end }}</td>
</tr>
<tr>
<th>{% trans "cancellation deadline"|capfirst %}</th>
<td>{{ event.cancel_deadline }}</td>
</tr>
<tr>
<th>{% trans "number of registrations"|capfirst %}</th>
<td>
{% blocktrans count counter=registrations|length trimmed %}
{{ counter }} registration
{% plural %}
{{ counter }} registrations
{% endblocktrans %}
{% if event.max_participants > 0 %}
<i>({{ event.max_participants }} {% trans "max"|capfirst %})</i>
{% with prc=registration_percentage %}
<div class="progress progress-style1">
<div class="bar trans-enabled" style="width: {{ prc }}%;" data-width="{{ prc }}%"></div>
</div>
{% endwith %}
{% endif %}
</td>
</tr>
<?php if ($registration !== null): ?>
{% if registration %}
<tr>
<th>{% trans "registration status"|capfirst %}</th>
<td>
<b>TODO TODO TODO</b>
{# TODO implement registration status #}
{# <?php#}
{# /** @var RegistrationModel $registration */#}
{# if ($registration->isRegisteredExcludeCoolDown()) {#}
{# $queuePos = $activity->getQueuePosition($registration);#}
{# if ($queuePos === 0) {#}
{# echo "Aangemeld";#}
{# } else {#}
{# echo "Op wachtlijst positie " . $queuePos;#}
{# }#}
{# } else if($registration->isLateCancellation()) {#}
{# echo "Te laat afgemeld";#}
{# } else {#}
{# echo "Afgemeld";#}
{# }#}
{# ?>#}
</td>
</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>
{# <?php if($show_button): ?>#}
{##}
{# <form class="form-inline pull-left" method="post" action="<?php echo $this->action('/register'); ?>">#}
{# <?php echo $form->hidden('activity_id', $activity->id); ?>#}
{# <?php echo $form->hidden('intent', $intent); ?>#}
{# <?php if($afterDeadline): ?>#}
{# <?php echo $form->submit('submit', $button_text, ['class' => 'btn btn-style1', 'onclick' => 'return confirm(\'' . $confirmText . '\');']); ?>#}
{# <?php else: ?>#}
{# <?php echo $form->submit('submit', $button_text, ['class' => 'btn btn-style1']); ?>#}
{# <?php endif; ?>#}
{# <?php echo $csrf_token; ?>#}
{# </form>#}
{##}
{# <?php endif; ?>#}
{# <?php if($registered && ($registration_status === ActivityModel::REGISTRATION_OPEN || $registration_status === ActivityModel::REGISTRATION_CLOSED_REGISTER_ONLY) && $registration->isRegisteredExcludeCoolDown() && count($activity->getExtraFields()) > 0):?>#}
{# <form class="form-inline pull-left" method="post" action="<?php echo $this->action('/register'); ?>">#}
{# <?php echo $form->hidden('activity_id', $activity->id);?>#}
{# <?php echo $form->hidden('intent', 'prompt_update_screen');?>#}
{# <?php echo $form->submit('submit', 'Bijwerken', ['class' => 'btn btn-style1']); ?>#}
{# <?php echo $csrf_token; ?>#}
{# </form>#}
{# <?php endif; ?>#}
</td>
</tr>
<tr>
<td>
</td>
<td>
<em>
{% if not request.user.is_authenticated %}
{% trans "You have to log in before you can register for this event." %}
{% endif %}
{# Todo implement aanmeldtekst #}
{# <?php if (!$user->isLoggedIn()):?>#}
{# <?php elseif($registered && $registration->isInCoolDown()): ?>#}
{# <script>#}
{# window.onload = function () {#}
{# startTimer("<?= (new \DateTime($registration->canceled))->format("Y/m/d H:i:s");?>", document.querySelector('#events_cool_down_timer'));#}
{# };#}
{# </script>#}
{# <span id="events_cool_down_text" title="Binnen de aangegeven hoeveelheid tijd kun je je afmelding annuleren door je opnieuw aan te melden. In dat geval raak je je oude plek niet kwijt.">Je hebt nog <span id="events_cool_down_timer" >een onbekende hoeveelheid tijd</span> om je afmelding ongedaan te maken.</span>#}
{# <?php elseif($registration_status === ActivityModel::REGISTRATION_NOT_NEEDED): ?>#}
{# <?php if($activity->registration_not_needed_message !== null) : ?>#}
{# <?php echo $activity->registration_not_needed_message; ?>#}
{# <?php else: ?>#}
{# Aanmelden hoeft niet#}
{# <?php endif; ?>#}
{# <?php elseif($registration_status === ActivityModel::REGISTRATION_NOT_YET_OPEN): ?>#}
{# Aanmelden kan vanaf <?php echo $activity->formatDate('begin_registration'); ?>#}
{# <?php elseif($registration && $registration->isRegisteredExcludeCoolDown() && ($registration_status === ActivityModel::REGISTRATION_CLOSED || $registration_status === ActivityModel::REGISTRATION_CLOSED_REGISTER_ONLY)): ?>#}
{# <?php // You are registered, but you can either: do nothing, or only register, so no cancelling ?>#}
{# Afmelden kan niet meer, tenzij je de boete betaalt <?php echo $costText; ?>.#}
{# <?php elseif(!($registered && $registration->isRegisteredExcludeCoolDown()) && ($registration_status === ActivityModel::REGISTRATION_CLOSED || $registration_status === ActivityModel::REGISTRATION_CLOSED_CANCEL_ONLY)): ?>#}
{# <?php // You are not registered, but you can either: do nothing, or only cancel, so no registering ?>#}
{# Aanmelden kan niet meer#}
{# <?php 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; ?>#}
</tbody>
</table>
</div>
<div class="span6">
<div class="location-map">
<img src="https://maps.googleapis.com/maps/api/staticmap?center={{ event.map_location|urlencode }}&zoom=13&size=450x250&markers={{ event.map_location|urlencode }}"/>
</div>
</div>
</div>
{% if user.is_authenticated and registrations|length > 0 %}
<div class="member-directory">
<h1 class="midhead">Aanmeldingen</h1>
<ul class="member-directory row">
{% for registration in registrations %}
<li class="post member-item span3 has-overlay{% if forloop.counter0|divisibleby:4 %} first-child{% endif %}">
{% if registration.is_external %}
<a href="#">
<div class="post-inner">
<div class="inner-img">{% static "members/images/default-avatar.jpg" %}</div>
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ registration.name }}</h2>
<p></p>
</div>
</div>
<div class="post-body avatar-subtitle">
{{ registration.name }}
</div>
</div>
</a>
{% else %}
<a href="{% url 'members:profile' pk=registration.member.pk %}">
<div class="post-inner">
<div class="inner-img">
<img src="{% if not registration.member.photo %}{% static "members/images/default-avatar.jpg" %}{% else %}{{ registration.member.photo.url }}{% endif %}" alt="{{ registration.member.display_name }}" />
</div>
<div class="post-overlay">
<div class="post-overlay-meta">
<h2>{{ registration.member.display_name }}</h2>
<p>{% trans "cohort"|capfirst %}: {{ registration.member.starting_year }}</p>
</div>
</div>
<div class="post-body avatar-subtitle">
{{ registration.member.display_name }}
</div>
</div>
</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endblock body %}
......@@ -9,5 +9,6 @@ from . import views
urlpatterns = [
url(r'admin/(?P<event_id>\d+)/$', views.admin_details, name='admin-details'),
url(r'admin/(?P<event_id>\d+)/export/$', views.export, name='export'),
url(r'^(?P<event_id>\d+)$', views.event, name='event'),
url(r'^$', views.index, name='index'),
]
......@@ -8,7 +8,7 @@ from django.contrib.auth.decorators import permission_required
from django.utils import timezone
from django.utils.text import slugify
from .models import Event
from .models import Event, Registration
@staff_member_required
......@@ -96,3 +96,32 @@ def index(request):
return render(request, 'events/index.html', {
'upcoming_activity': upcoming_activity
})
def event(request, event_id):
event = get_object_or_404(
Event.objects.filter(published=True),
pk=event_id
)
registrations = event.registration_set.all()
context = {
'event': event,
'registrations': registrations,
'user': request.user,
}
if event.max_participants:
perc = 100.0*len(registrations)/event.max_participants
context['registration_percentage'] = perc
try:
registration = Registration.objects.get(
event=event,
member=request.user.member
)
context['registration'] = registration
except:
pass
return render(request, 'events/event.html', context)
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