forked from fossasia/eventyay-tickets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Accounts Feature and Enable Ticket Acquisition for Registered…
… Users (fossasia#405) * Implement feature allow organizer can buy tickets and view their orders * Safely encode the locale_code * simplify build_locale_url --------- Co-authored-by: lcduong <[email protected]> Co-authored-by: odkhang <odkhang> Co-authored-by: lcduong <lcduong> Co-authored-by: Mario Behling <[email protected]>
- Loading branch information
1 parent
ce24ea2
commit 5df752e
Showing
21 changed files
with
335 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django import template | ||
from django.urls import reverse | ||
from django.utils.http import urlencode | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag(takes_context=True) | ||
def build_login_url(context): | ||
request = context['request'] | ||
next_path = request.path | ||
query_string = request.META.get("QUERY_STRING", "") | ||
|
||
# Construct the base login URL | ||
login_url = reverse("control:auth.login") | ||
|
||
# Encode the next parameter | ||
if query_string: | ||
next_param = f"{next_path}?{query_string}" | ||
else: | ||
next_param = next_path | ||
|
||
# Full login URL with the encoded next parameter | ||
full_url = f"{login_url}?{urlencode({'next': next_param})}" | ||
|
||
return full_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/pretix/control/forms/organizer_forms/user_orders_form.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
|
||
from pretix.base.models import Event | ||
|
||
|
||
class UserOrderFilterForm(forms.Form): | ||
event = forms.ModelChoiceField( | ||
queryset=None, | ||
required=False, | ||
label="Event", | ||
widget=forms.Select(attrs={'class': 'form-control'}), | ||
empty_label="Select an Event" | ||
) | ||
|
||
def __init__(self, *args, **kwargs): | ||
user = kwargs.pop('user', None) # Get the user from the kwargs | ||
super().__init__(*args, **kwargs) | ||
|
||
if user: | ||
# Query distinct events based on the user's orders | ||
events = Event.objects.filter(orders__email__iexact=user.email).distinct() | ||
self.fields['event'].queryset = events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/pretix/control/templates/pretixcontrol/user/orders.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{% extends "pretixcontrol/base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap3 %} | ||
{% load eventurl %} | ||
{% load money %} | ||
{% block title %}{% trans "My Orders" %}{% endblock %} | ||
{% block content %} | ||
<h1>{% trans "My Orders" %}</h1> | ||
<div class="row filter-form"> | ||
<form action="" method="get"> | ||
<div class="col-md-3 col-xs-6"> | ||
<!-- Add the event filter here --> | ||
{% bootstrap_field filter_form.event layout='inline' %} | ||
</div> | ||
<div class="col-md-2 col-xs-6"> | ||
<button type="submit" class="btn btn-primary"> | ||
<span class="fa fa-filter"></span> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="table-responsive"> | ||
<table class="table table-condensed table-hover table-quotas"> | ||
<thead> | ||
<tr> | ||
<th>{% trans "Order code" %}</th> | ||
<th>{% trans "Organizer" %}</th> | ||
<th>{% trans "Event" %}</th> | ||
<th>{% trans "Order date" %}</th> | ||
<th class="text-right">{% trans "Order total" %}</th> | ||
<th class="text-right">{% trans "Status" %}</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for order in orders %} | ||
<tr> | ||
<td> | ||
<strong> | ||
<a href='{% abseventurl order.event "presale:event.order" order=order.code secret=order.secret %}' target="_blank"> | ||
{{ order.code }} | ||
</a> | ||
</strong> | ||
</td> | ||
<td> | ||
{{ order.event.organizer }} | ||
</td> | ||
<td> | ||
{{ order.event }} | ||
</td> | ||
<td> | ||
{{ order.datetime|date:"SHORT_DATETIME_FORMAT" }} | ||
</td> | ||
<td class="text-right flip"> | ||
{{ order.total|money:order.event.currency }} | ||
</td> | ||
<td class="text-right flip">{% include "pretixpresale/event/fragment_order_status.html" with order=order event=order.event %}</td> | ||
<td class="text-right flip"> | ||
<a href='{% abseventurl order.event "presale:event.order" order=order.code secret=order.secret %}' | ||
target="_blank" | ||
class="btn btn-default"> | ||
{% trans "Details" %} | ||
</a> | ||
</td> | ||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="7" class="text-center"> | ||
{% trans "You have not made any orders yet." %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% include "pretixcontrol/pagination.html" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from urllib.parse import urlencode | ||
|
||
from django import template | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def append_next(next_url=None): | ||
if next_url and next_url.strip(): | ||
return f'?{urlencode({"next": next_url})}' | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/pretix/presale/templates/pretixpresale/fragment_login_status.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
{% load i18n %} | ||
{% load eventurl %} | ||
{% load login_url %} | ||
|
||
{% if request.organizer.settings.customer_accounts %} | ||
{{ request.event.organizer.slug|json_script:"organizer_name" }} | ||
{{ request.event.slug|json_script:"event_slug" }} | ||
{{ show_organizer_area|json_script:"show_organizer_area" }} | ||
{{ 'popover-profile'|json_script:"popover_toggle" }} | ||
{{ base_path|json_script:"base_path" }} | ||
<nav class="login-hdr" aria-label='{% trans "account" %}'> | ||
{% if request.user.is_authenticated %} | ||
<div class="navigation-button"> | ||
<a target="_blank" class="header-nav btn btn-outline-success" data-toggle="popover-profile"> | ||
<i class="fa fa-user"></i> {{ request.user.fullname|default:request.user.email }} | ||
<i class="fa fa-solid fa-caret-down"></i> | ||
</a> | ||
</div> | ||
{% else %} | ||
<a href="{% build_login_url %}"> | ||
{% trans "Log in" %} | ||
</a> | ||
|
||
{% endif %} | ||
</nav> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.