-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI for creating and chacnging vouchers
- Loading branch information
Showing
11 changed files
with
323 additions
and
13 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/pretix/base/migrations/0003_eventpermission_can_change_vouchers.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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-02-09 09:59 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pretixbase', '0002_auto_20160209_0940'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='eventpermission', | ||
name='can_change_vouchers', | ||
field=models.BooleanField(default=True, verbose_name='Can change vouchers'), | ||
), | ||
] |
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,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-02-09 10:23 | ||
from __future__ import unicode_literals | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pretixbase', '0003_eventpermission_can_change_vouchers'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='voucher', | ||
name='item', | ||
), | ||
migrations.AddField( | ||
model_name='voucher', | ||
name='item', | ||
field=models.ForeignKey(default=None, help_text="This product is added to the user's cart if the voucher is redeemed.", on_delete=django.db.models.deletion.CASCADE, related_name='vouchers', to='pretixbase.Item', verbose_name='Product'), | ||
preserve_default=False, | ||
), | ||
migrations.AlterField( | ||
model_name='voucher', | ||
name='price', | ||
field=models.DecimalField(blank=True, decimal_places=2, help_text='If empty, the product will cost its normal price.', max_digits=10, null=True, verbose_name='Set product price to'), | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pretix.base.forms import I18nModelForm | ||
from pretix.base.models import Voucher | ||
|
||
|
||
class VoucherForm(I18nModelForm): | ||
class Meta: | ||
model = Voucher | ||
localized_fields = '__all__' | ||
fields = [ | ||
'code', 'valid_until', 'block_quota', 'allow_ignore_quota', 'price', 'item' | ||
] | ||
|
||
def _get_validation_exclusions(self): | ||
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
26 changes: 26 additions & 0 deletions
26
src/pretix/control/templates/pretixcontrol/vouchers/delete.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,26 @@ | ||
{% extends "pretixcontrol/items/base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap3 %} | ||
{% block title %}{% trans "Delete voucher" %}{% endblock %} | ||
{% block inside %} | ||
<h1>{% trans "Delete voucher" %}</h1> | ||
<form action="" method="post" class="form-horizontal"> | ||
{% csrf_token %} | ||
{% if not allowed %} | ||
<p>{% trans "You can not delete this voucher after it has been redeemed" %}</p> | ||
{% else %} | ||
<p>{% blocktrans %}Are you sure you want to delete the voucher | ||
<strong>{{ voucher }}</strong>?{% endblocktrans %}</p> | ||
{% endif %} | ||
<div class="form-group submit-group"> | ||
<a href="{% url "control:event.vouchers" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default btn-cancel"> | ||
{% trans "Cancel" %} | ||
</a> | ||
{% if allowed %} | ||
<button type="submit" class="btn btn-danger btn-save"> | ||
{% trans "Delete" %} | ||
</button> | ||
{% endif %} | ||
</div> | ||
</form> | ||
{% endblock %} |
25 changes: 25 additions & 0 deletions
25
src/pretix/control/templates/pretixcontrol/vouchers/detail.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,25 @@ | ||
{% extends "pretixcontrol/items/base.html" %} | ||
{% load i18n %} | ||
{% load bootstrap3 %} | ||
{% block title %}{% trans "Voucher" %}{% endblock %} | ||
{% block inside %} | ||
<h1>{% trans "Voucher" %}</h1> | ||
<form action="" method="post" class="form-horizontal"> | ||
{% csrf_token %} | ||
{% bootstrap_form_errors form %} | ||
<fieldset> | ||
<legend>{% trans "Voucher details" %}</legend> | ||
{% bootstrap_field form.code layout="horizontal" %} | ||
{% bootstrap_field form.valid_until layout="horizontal" %} | ||
{% bootstrap_field form.block_quota layout="horizontal" %} | ||
{% bootstrap_field form.allow_ignore_quota layout="horizontal" %} | ||
{% bootstrap_field form.price layout="horizontal" %} | ||
{% bootstrap_field form.item layout="horizontal" %} | ||
</fieldset> | ||
<div class="form-group submit-group"> | ||
<button type="submit" class="btn btn-primary btn-save"> | ||
{% trans "Save" %} | ||
</button> | ||
</div> | ||
</form> | ||
{% endblock %} |
40 changes: 40 additions & 0 deletions
40
src/pretix/control/templates/pretixcontrol/vouchers/index.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,40 @@ | ||
{% extends "pretixcontrol/items/base.html" %} | ||
{% load i18n %} | ||
{% block title %}{% trans "Vouchers" %}{% endblock %} | ||
{% block inside %} | ||
<h1>{% trans "Vouchers" %}</h1> | ||
<p> | ||
<a href="{% url "control:event.vouchers.add" organizer=request.event.organizer.slug event=request.event.slug %}" | ||
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create a new voucher" %}</a> | ||
</p> | ||
<div class="table-responsive"> | ||
<table class="table table-hover table-quotas"> | ||
<thead> | ||
<tr> | ||
<th>{% trans "Voucher code" %}</th> | ||
<th>{% trans "Is redeemed" %}</th> | ||
<th>{% trans "Expiry" %}</th> | ||
<th>{% trans "Product" %}</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for v in vouchers %} | ||
<tr> | ||
<td> | ||
<strong><a href=" | ||
{% url "control:event.voucher" organizer=request.event.organizer.slug event=request.event.slug voucher=v.id %}">{{ v.code }}</a></strong> | ||
</td> | ||
<td>{% if v.is_ordered %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td> | ||
<td>{{ v.valid_until|date }}</td> | ||
<td>{{ v.item }}</td> | ||
<td class="text-right"> | ||
<a href="{% url "control:event.voucher.delete" organizer=request.event.organizer.slug event=request.event.slug voucher=v.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a> | ||
</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
Oops, something went wrong.