Added can_view_vouchers permission

This commit is contained in:
Raphael Michel
2016-09-24 16:57:41 +02:00
parent 9f934858cc
commit f8c99f6d02
7 changed files with 45 additions and 6 deletions

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-09-24 14:48
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0037_invoice_payment_provider_text'),
]
operations = [
migrations.AddField(
model_name='eventpermission',
name='can_view_vouchers',
field=models.BooleanField(default=True, verbose_name='Can view vouchers'),
),
migrations.AlterField(
model_name='item',
name='allow_cancel',
field=models.BooleanField(default=True, help_text='If you deactivate this, an order including this product might not be canceled by the user. It may still be canceled by you.', verbose_name='Allow product to be canceled'),
),
migrations.AlterField(
model_name='order',
name='status',
field=models.CharField(choices=[('n', 'pending'), ('p', 'paid'), ('e', 'expired'), ('c', 'canceled'), ('r', 'refunded')], db_index=True, max_length=3, verbose_name='Status'),
),
]

View File

@@ -243,6 +243,10 @@ class EventPermission(models.Model):
default=True,
verbose_name=_("Can change orders")
)
can_view_vouchers = models.BooleanField(
default=True,
verbose_name=_("Can view vouchers")
)
can_change_vouchers = models.BooleanField(
default=True,
verbose_name=_("Can change vouchers")

View File

@@ -87,7 +87,7 @@
</a>
</li>
{% endif %}
{% if request.eventperm.can_change_vouchers %}
{% if request.eventperm.can_view_vouchers %}
<li>
<a href="{% url 'control:event.vouchers' organizer=request.event.organizer.slug event=request.event.slug %}"
{% if url_name == "event.vouchers" %}class="active"{% endif %}>

View File

@@ -18,6 +18,7 @@
<th>{% trans "View orders" %}</th>
<th>{% trans "Change orders" %}</th>
<th>{% trans "Change permissions" %}</th>
<th>{% trans "View vouchers" %}</th>
<th>{% trans "Change vouchers" %}</th>
<th>{% trans "Delete" %}</th>
</tr>
@@ -31,6 +32,7 @@
<td>{{ form.can_view_orders }}</td>
<td>{{ form.can_change_orders }}</td>
<td>{{ form.can_change_permissions }}</td>
<td>{{ form.can_view_vouchers }}</td>
<td>{{ form.can_change_vouchers }}</td>
<td>{{ form.DELETE }}</td>
</tr>
@@ -49,6 +51,7 @@
<td>{{ add_form.can_change_orders }}</td>
<td>{{ add_form.can_change_permissions }}</td>
<td>{{ add_form.can_change_vouchers }}</td>
<td>{{ add_form.can_view_vouchers }}</td>
</tr>
</tbody>
</table>

View File

@@ -445,7 +445,7 @@ class EventPermissionForm(I18nModelForm):
model = EventPermission
fields = (
'can_change_settings', 'can_change_items', 'can_change_permissions', 'can_view_orders',
'can_change_orders', 'can_change_vouchers'
'can_change_orders', 'can_view_vouchers', 'can_change_vouchers'
)

View File

@@ -28,7 +28,7 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
context_object_name = 'vouchers'
paginate_by = 30
template_name = 'pretixcontrol/vouchers/index.html'
permission = 'can_change_vouchers'
permission = 'can_view_vouchers'
def get_queryset(self):
qs = self.request.event.vouchers.all().select_related('item', 'variation')
@@ -90,7 +90,7 @@ class VoucherList(EventPermissionRequiredMixin, ListView):
class VoucherTags(EventPermissionRequiredMixin, TemplateView):
template_name = 'pretixcontrol/vouchers/tags.html'
permission = 'can_change_vouchers'
permission = 'can_view_vouchers'
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)