mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Added filtering to the voucher list
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "pretixcontrol/event/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
{% block title %}{% trans "Vouchers" %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>{% trans "Vouchers" %}</h1>
|
||||||
|
<ul class="nav nav-pills">
|
||||||
|
<li {% if "event.vouchers" == url_name %}class="active"{% endif %}>
|
||||||
|
<a href="{% url 'control:event.vouchers' organizer=request.event.organizer.slug event=request.event.slug %}">
|
||||||
|
{% trans "All Vouchers" %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% block inside %}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
@@ -1,20 +1,38 @@
|
|||||||
{% extends "pretixcontrol/items/base.html" %}
|
{% extends "pretixcontrol/vouchers/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block title %}{% trans "Vouchers" %}{% endblock %}
|
{% block title %}{% trans "Vouchers" %}{% endblock %}
|
||||||
{% block inside %}
|
{% block inside %}
|
||||||
<h1>{% trans "Vouchers" %}</h1>
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
Vouchers allow you to assign tickets to specific persons for a lower price. They also enable you to
|
Vouchers allow you to assign tickets to specific persons for a lower price. They also enable you to
|
||||||
reserve some quota for your very special guests.
|
reserve some quota for your very special guests.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
<form class="form-inline helper-display-inline" action="" method="get">
|
||||||
|
<p>
|
||||||
|
<input type="text" name="search" class="form-control" placeholder="{% trans "Search voucher" %}"
|
||||||
|
value="{{ request.GET.search }}">
|
||||||
|
<input type="text" name="tag" class="form-control" placeholder="{% trans "Filter by tag" %}"
|
||||||
|
value="{{ request.GET.tag }}">
|
||||||
|
<select name="status" class="form-control">
|
||||||
|
<option value="">{% trans "All vouchers" %}</option>
|
||||||
|
<option value="v" {% if request.GET.status == "v" %}selected="selected"{% endif %}>{% trans "Valid" %}</option>
|
||||||
|
<option value="r" {% if request.GET.status == "r" %}selected="selected"{% endif %}>{% trans "Redeemd" %}</option>
|
||||||
|
<option value="e" {% if request.GET.status == "e" %}selected="selected"{% endif %}>{% trans "Expired" %}</option>
|
||||||
|
</select>
|
||||||
|
<button class="btn btn-primary" type="submit">{% trans "Filter" %}</button>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
{% if vouchers|length == 0 %}
|
{% if vouchers|length == 0 %}
|
||||||
<div class="empty-collection">
|
<div class="empty-collection">
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% if request.GET.search or request.GET.tag or request.GET.status %}
|
||||||
You haven't created any vouchers yet.
|
{% trans "Your search did not match any vouchers." %}
|
||||||
{% endblocktrans %}
|
{% else %}
|
||||||
|
{% blocktrans trimmed %}
|
||||||
|
You haven't created any vouchers yet.
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<a href="{% url "control:event.vouchers.add" organizer=request.event.organizer.slug event=request.event.slug %}"
|
<a href="{% url "control:event.vouchers.add" organizer=request.event.organizer.slug event=request.event.slug %}"
|
||||||
@@ -30,11 +48,6 @@
|
|||||||
class="btn btn-default"><i class="fa fa-plus"></i>
|
class="btn btn-default"><i class="fa fa-plus"></i>
|
||||||
{% trans "Create multiple new vouchers" %}</a>
|
{% trans "Create multiple new vouchers" %}</a>
|
||||||
</p>
|
</p>
|
||||||
<form class="form-inline helper-display-inline" action="" method="get">
|
|
||||||
<input type="text" name="search" class="form-control" placeholder="{% trans "Search voucher" %}"
|
|
||||||
value="{{ request.GET.search }}">
|
|
||||||
<button class="btn btn-primary" type="submit">{% trans "Filter" %}</button>
|
|
||||||
</form>
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-hover table-quotas">
|
<table class="table table-hover table-quotas">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from django.core.urlresolvers import resolve, reverse
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.http import Http404, HttpResponseRedirect
|
from django.http import Http404, HttpResponseRedirect
|
||||||
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
|
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
|
||||||
|
|
||||||
@@ -24,6 +25,17 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
|
|||||||
if self.request.GET.get("search", "") != "":
|
if self.request.GET.get("search", "") != "":
|
||||||
s = self.request.GET.get("search", "")
|
s = self.request.GET.get("search", "")
|
||||||
qs = qs.filter(Q(code__icontains=s) | Q(tag__icontains=s) | Q(comment__icontains=s))
|
qs = qs.filter(Q(code__icontains=s) | Q(tag__icontains=s) | Q(comment__icontains=s))
|
||||||
|
if self.request.GET.get("tag", "") != "":
|
||||||
|
s = self.request.GET.get("tag", "")
|
||||||
|
qs = qs.filter(tag=s)
|
||||||
|
if self.request.GET.get("status", "") != "":
|
||||||
|
s = self.request.GET.get("status", "")
|
||||||
|
if s == 'v':
|
||||||
|
qs = qs.filter(Q(valid_until__isnull=True) | Q(valid_until__gt=now())).filter(redeemed=False)
|
||||||
|
elif s == 'r':
|
||||||
|
qs = qs.filter(redeemed=True)
|
||||||
|
elif s == 'e':
|
||||||
|
qs = qs.filter(Q(valid_until__isnull=False) & Q(valid_until__lt=now())).filter(redeemed=False)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user