Skip to content
Snippets Groups Projects
Commit de2b98bc authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Display individual price at event detail page

parent 83fe8dac
No related branches found
No related tags found
1 merge request!37Resolve "Display individual price at registration with voucher"
Pipeline #95486 failed
......@@ -188,6 +188,15 @@ class Event(ExtensibleModel):
def get_absolute_url(self):
return reverse("event_by_name", kwargs={"slug": self.slug})
def individual_cost(self, request=None):
if request and request.user.is_authenticated:
if Voucher.objects.filter(event=self, person=request.user.person, used=False).exists():
voucher = Voucher.objects.get(event=self, person=request.user.person, used=False)
individual_cost = voucher.discount * self.cost / 100
return individual_cost
else:
return self.cost
@property
def booked_percentage(self):
return self.linked_group.members.count() / self.max_participants * 100
......
......@@ -50,7 +50,7 @@
<tr>
<td><i class="material-icons small">money</i></td>
<td colspan="2">{% trans "Participation fee (all inclusive)" %}</td>
<td>{{ event.cost }}</td>
<td>{{ individual_cost }}</td>
</tr>
<tr>
<td><i class="material-icons small">group</i></td>
......
......@@ -34,7 +34,7 @@
<tr>
<td><i class="material-icons small">money</i></td>
<td colspan="2">{% trans "Participation fee (all inclusive)" %}</td>
<td>{{ event.cost }}</td>
<td>{{ individual_cost }}</td>
</tr>
<tr>
<td><i class="material-icons small">group</i></td>
......
......@@ -691,6 +691,8 @@ class EventFullView(PermissionRequiredMixin, DetailView):
context["can_register"] = context["event"].can_register(request=self.request)
context["is_authenticated"] = self.request.user.is_authenticated
context["individual_cost"] = context["event"].individual_cost(request=self.request)
return context
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment