mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Added "comments" and "tags" to vouchers
This commit is contained in:
25
src/pretix/base/migrations/0023_auto_20160601_1039.py
Normal file
25
src/pretix/base/migrations/0023_auto_20160601_1039.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.6 on 2016-06-01 10:39
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pretixbase', '0022_merge'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='voucher',
|
||||
name='comment',
|
||||
field=models.TextField(blank=True, help_text='The text entered in this field will not be visible to the user and is available for your convenience.', verbose_name='Comment'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='voucher',
|
||||
name='tag',
|
||||
field=models.CharField(blank=True, help_text='You can use this field to group multiple vouchers together. If you enter the same value for multiple vouchers, you can get statistics on how many of them have been redeemed etc.', max_length=255, verbose_name='Tag'),
|
||||
),
|
||||
]
|
||||
@@ -101,6 +101,18 @@ class Voucher(LoggedModel):
|
||||
"If enabled, the voucher is valid for any product affected by this quota."
|
||||
)
|
||||
)
|
||||
tag = models.CharField(
|
||||
max_length=255,
|
||||
verbose_name=_("Tag"),
|
||||
blank=True,
|
||||
help_text=_("You can use this field to group multiple vouchers together. If you enter the same value for "
|
||||
"multiple vouchers, you can get statistics on how many of them have been redeemed etc.")
|
||||
)
|
||||
comment = models.TextField(
|
||||
blank=True, verbose_name=_("Comment"),
|
||||
help_text=_("The text entered in this field will not be visible to the user and is available for your "
|
||||
"convenience.")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Voucher")
|
||||
|
||||
@@ -18,7 +18,8 @@ class VoucherForm(I18nModelForm):
|
||||
model = Voucher
|
||||
localized_fields = '__all__'
|
||||
fields = [
|
||||
'code', 'valid_until', 'block_quota', 'allow_ignore_quota', 'price'
|
||||
'code', 'valid_until', 'block_quota', 'allow_ignore_quota', 'price', 'tag',
|
||||
'comment'
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
@@ -20,13 +20,21 @@
|
||||
{% bootstrap_field form.allow_ignore_quota layout="horizontal" %}
|
||||
{% bootstrap_field form.price layout="horizontal" %}
|
||||
{% bootstrap_field form.itemvar layout="horizontal" %}
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
If you choose "any product" for a specific quota and choose to reserve quota for this
|
||||
voucher above, the product can still be unavailable to the voucher holder if another quota
|
||||
associated with the product is sold out!
|
||||
{% endblocktrans %}
|
||||
<div class="form-group">
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<div class="controls">
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
If you choose "any product" for a specific quota and choose to reserve quota for this
|
||||
voucher above, the product can still be unavailable to the voucher holder if another quota
|
||||
associated with the product is sold out!
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_field form.tag layout="horizontal" %}
|
||||
{% bootstrap_field form.comment layout="horizontal" %}
|
||||
</fieldset>
|
||||
<div class="form-group submit-group">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<th>{% trans "Voucher code" %}</th>
|
||||
<th>{% trans "Is redeemed" %}</th>
|
||||
<th>{% trans "Expiry" %}</th>
|
||||
<th>{% trans "Tag" %}</th>
|
||||
<th>{% trans "Product" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -50,6 +51,9 @@
|
||||
</td>
|
||||
<td>{% if v.redeemed %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
|
||||
<td>{{ v.valid_until|date }}</td>
|
||||
<td>
|
||||
{{ v.tag }}
|
||||
</td>
|
||||
<td>
|
||||
{% if v.item %}
|
||||
{{ v.item }}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.contrib import messages
|
||||
from django.core.urlresolvers import resolve, reverse
|
||||
from django.db import transaction
|
||||
from django.db.models import Q
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import CreateView, DeleteView, ListView, UpdateView
|
||||
@@ -21,11 +22,10 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
|
||||
qs = self.request.event.vouchers.all().select_related('item')
|
||||
if self.request.GET.get("search", "") != "":
|
||||
s = self.request.GET.get("search", "")
|
||||
qs = qs.filter(code__contains=s)
|
||||
qs = qs.filter(Q(code__icontains=s) | Q(tag__icontains=s) | Q(comment__icontains=s))
|
||||
return qs
|
||||
|
||||
|
||||
|
||||
class VoucherDelete(EventPermissionRequiredMixin, DeleteView):
|
||||
model = Voucher
|
||||
template_name = 'pretixcontrol/vouchers/delete.html'
|
||||
|
||||
Reference in New Issue
Block a user