mirror of
https://github.com/pretix/pretix.git
synced 2026-11-26 03:51:56 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4289632e9 |
No files matched your search
@@ -605,19 +605,19 @@ Order position endpoints
|
||||
Tries to redeem an order position, identified by its internal ID, i.e. checks the attendee in. This endpoint
|
||||
accepts a number of optional requests in the body.
|
||||
|
||||
**Deprecated behavior:** For legacy compatibility, the ``secret`` field is also accepted as the lookup parameter.
|
||||
Do not depend on that behaviour as it will be removed in the future, such that only the internal ID is accepted.
|
||||
**Tip:** Instead of an ID, you can also use the ``secret`` field as the lookup parameter. In this case, you should
|
||||
always set ``untrusted_input=true`` as a query parameter to avoid security issues.
|
||||
|
||||
.. note::
|
||||
|
||||
Do not use this API to redeem tickets if you're building a ticket scanning application, as it has a few design
|
||||
We no longer recommend using this API if you're building a ticket scanning application, as it has a few design
|
||||
flaws that can lead to `security issues`_ or compatibility issues due to barcode content characters that are not
|
||||
URL-safe. We recommend to use our new :ref:`check-in API <rest-checkin>` instead. Advanced features like medium
|
||||
exchange are only supported on the new API.
|
||||
|
||||
:query boolean untrusted_input: If set to true, the lookup parameter is **always** interpreted as a ``secret``, never
|
||||
as an ``id``. This should be always set if you are passing through untrusted, scanned
|
||||
data to avoid guessing of ticket IDs. (**Deprecated**, use the new :ref:`check-in API <rest-checkin>` instead)
|
||||
data to avoid guessing of ticket IDs.
|
||||
:>json boolean questions_supported: When this parameter is set to ``true``, handling of questions is supported. If
|
||||
you do not implement question handling in your user interface, you **must**
|
||||
set this to ``false``. In that case, questions will just be ignored. Defaults
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
Gate resource
|
||||
-------------
|
||||
|
||||
The gate resource contains the following public fields:
|
||||
|
||||
.. rst-class:: rest-resource-table
|
||||
|
||||
===================================== ========================== =======================================================
|
||||
Field Type Description
|
||||
===================================== ========================== =======================================================
|
||||
id integer Internal ID of the gate within this organizer
|
||||
name string gate name
|
||||
identifier string Internal identifier to make it easier to match the data with other sources
|
||||
===================================== ========================== =======================================================
|
||||
|
||||
Endpoints
|
||||
----------------
|
||||
|
||||
.. http:get:: /api/v1/organizers/(organizer)/gates/
|
||||
|
||||
Returns a list of all gates within a given organizer.
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/v1/organizers/bigevents/gates/ HTTP/1.1
|
||||
Host: pretix.eu
|
||||
Accept: application/json, text/javascript
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Vary: Accept
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"count": 1,
|
||||
"next": null,
|
||||
"previous": null,
|
||||
"results": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Main door",
|
||||
"identifier": "west_entry"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
:param organizer: The ``slug`` field of the organizer to fetch
|
||||
:statuscode 200: no error
|
||||
:statuscode 401: Authentication failure
|
||||
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
|
||||
|
||||
.. http:get:: /api/v1/organizers/(organizer)/gates/(id)/
|
||||
|
||||
Returns information on one gate, identified by its ID.
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/v1/organizers/bigevents/gates/1/ HTTP/1.1
|
||||
Host: pretix.eu
|
||||
Accept: application/json, text/javascript
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Vary: Accept
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Main door",
|
||||
"identifier": "west_entry"
|
||||
}
|
||||
|
||||
:param organizer: The ``slug`` field of the organizer to fetch
|
||||
:param id: The ``id`` of the gate to fetch
|
||||
:statuscode 200: no error
|
||||
:statuscode 401: Authentication failure
|
||||
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
|
||||
|
||||
.. http:post:: /api/v1/organizers/(organizer)/gates/
|
||||
|
||||
Creates a new gate
|
||||
|
||||
You can supply the following fields of the resource:
|
||||
|
||||
* ``name``
|
||||
* ``identifier`` (optional, if you do not supply one, it will be auto-generated)
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/v1/organizers/bigevents/gates/ HTTP/1.1
|
||||
Host: pretix.eu
|
||||
Accept: application/json, text/javascript
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "South gate",
|
||||
"identifier": "south_entry",
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 201 Created
|
||||
Vary: Accept
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"name": "South gate",
|
||||
"identifier": "south_entry"
|
||||
}
|
||||
|
||||
:param organizer: The ``slug`` field of the organizer to create a gate for
|
||||
:statuscode 201: no error
|
||||
:statuscode 400: The gate could not be created due to invalid submitted data.
|
||||
:statuscode 401: Authentication failure
|
||||
:statuscode 403: The requested organizer/gate does not exist **or** you have no permission to create this resource.
|
||||
|
||||
.. http:patch:: /api/v1/organizers/(organizer)/gates/(id)/
|
||||
|
||||
Update a gate.
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
PATCH /api/v1/organizers/bigevents/gates/1/ HTTP/1.1
|
||||
Host: pretix.eu
|
||||
Accept: application/json, text/javascript
|
||||
Content-Type: application/json
|
||||
Content-Length: 94
|
||||
|
||||
{
|
||||
"name": "Foo"
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Vary: Accept
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Foo",
|
||||
"identifier": "south_entry"
|
||||
}
|
||||
|
||||
:param organizer: The ``slug`` field of the organizer to modify
|
||||
:param id: The ``id`` field of the gate to modify
|
||||
:statuscode 200: no error
|
||||
:statuscode 400: The gate could not be modified due to invalid submitted data
|
||||
:statuscode 401: Authentication failure
|
||||
:statuscode 403: The requested organizer/gate does not exist **or** you have no permission to change this resource.
|
||||
|
||||
.. http:delete:: /api/v1/organizers/(organizer)/gates/(id)/
|
||||
|
||||
Delete a gate.
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
DELETE /api/v1/organizers/bigevents/gates/1/ HTTP/1.1
|
||||
Host: pretix.eu
|
||||
Accept: application/json, text/javascript
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
Vary: Accept
|
||||
|
||||
:param organizer: The ``slug`` field of the organizer to modify
|
||||
:param id: The ``id`` field of the gate to delete
|
||||
:statuscode 204: no error
|
||||
:statuscode 401: Authentication failure
|
||||
:statuscode 403: The requested organizer/gate does not exist **or** you have no permission to change it **or** this gate cannot be deleted since it is currently in use.
|
||||
|
||||
@@ -43,6 +43,8 @@ const ignores = globalIgnores([
|
||||
'src/pretix/static/pretixbase/js/addressform.js',
|
||||
'src/pretix/static/pretixbase/js/asynctask.js',
|
||||
'src/pretix/static/pretixbase/js/details.js',
|
||||
'src/pretix/static/pretixbase/js/gettextstub.js',
|
||||
'src/pretix/static/pretixbase/js/i18nstring.js',
|
||||
'src/pretix/static/pretixcontrol/js/menu.js',
|
||||
'src/pretix/static/pretixcontrol/js/ui/editor.js',
|
||||
'src/pretix/static/pretixcontrol/js/ui/geo.js',
|
||||
|
||||
@@ -41,7 +41,7 @@ from pretix.api.serializers.settings import SettingsSerializer
|
||||
from pretix.base.auth import get_auth_backends
|
||||
from pretix.base.i18n import get_language_without_region
|
||||
from pretix.base.models import (
|
||||
Customer, Device, EventMetaProperty, Gate, GiftCard, GiftCardTransaction,
|
||||
Customer, Device, EventMetaProperty, GiftCard, GiftCardTransaction,
|
||||
Membership, MembershipType, OrderPosition, Organizer, ReusableMedium,
|
||||
SalesChannel, SeatingPlan, Team, TeamAPIToken, TeamInvite, User,
|
||||
)
|
||||
@@ -477,13 +477,6 @@ class DeviceSerializer(serializers.ModelSerializer):
|
||||
del self.fields['initialization_token']
|
||||
|
||||
|
||||
class GateSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Gate
|
||||
fields = ('id', 'name', 'identifier')
|
||||
|
||||
|
||||
class TeamInviteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = TeamInvite
|
||||
|
||||
@@ -62,7 +62,6 @@ orga_router.register(r'membershiptypes', organizer.MembershipTypeViewSet)
|
||||
orga_router.register(r'reusablemedia', media.ReusableMediaViewSet)
|
||||
orga_router.register(r'teams', organizer.TeamViewSet)
|
||||
orga_router.register(r'devices', organizer.DeviceViewSet)
|
||||
orga_router.register(r'gates', organizer.GateViewSet)
|
||||
orga_router.register(r'orders', order.OrganizerOrderViewSet)
|
||||
orga_router.register(r'invoices', order.InvoiceViewSet)
|
||||
orga_router.register(r'scheduled_exports', exporters.ScheduledOrganizerExportViewSet)
|
||||
|
||||
@@ -44,16 +44,16 @@ from pretix.api.models import OAuthAccessToken
|
||||
from pretix.api.pagination import TotalOrderingFilter
|
||||
from pretix.api.serializers.organizer import (
|
||||
CustomerCreateSerializer, CustomerSerializer, DeviceSerializer,
|
||||
EventMetaPropertiesSerializer, GateSerializer, GiftCardSerializer,
|
||||
EventMetaPropertiesSerializer, GiftCardSerializer,
|
||||
GiftCardTransactionSerializer, MembershipSerializer,
|
||||
MembershipTypeSerializer, OrganizerSerializer, OrganizerSettingsSerializer,
|
||||
SalesChannelSerializer, SeatingPlanSerializer, TeamAPITokenSerializer,
|
||||
TeamInviteSerializer, TeamMemberSerializer, TeamSerializer,
|
||||
)
|
||||
from pretix.base.models import (
|
||||
Customer, Device, Event, EventMetaProperty, Gate, GiftCard,
|
||||
GiftCardTransaction, LogEntry, Membership, MembershipType, Organizer,
|
||||
SalesChannel, SeatingPlan, Team, TeamAPIToken, TeamInvite, User,
|
||||
Customer, Device, Event, EventMetaProperty, GiftCard, GiftCardTransaction,
|
||||
LogEntry, Membership, MembershipType, Organizer, SalesChannel, SeatingPlan,
|
||||
Team, TeamAPIToken, TeamInvite, User,
|
||||
)
|
||||
from pretix.base.plugins import (
|
||||
PLUGIN_LEVEL_EVENT, PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID,
|
||||
@@ -571,52 +571,6 @@ class DeviceViewSet(mixins.CreateModelMixin,
|
||||
return inst
|
||||
|
||||
|
||||
class GateViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = GateSerializer
|
||||
queryset = Gate.objects.none()
|
||||
permission = 'organizer.devices:read'
|
||||
write_permission = 'organizer.devices:write'
|
||||
|
||||
def get_queryset(self):
|
||||
return self.request.organizer.gates.order_by('pk')
|
||||
|
||||
def get_serializer_context(self):
|
||||
ctx = super().get_serializer_context()
|
||||
ctx['organizer'] = self.request.organizer
|
||||
return ctx
|
||||
|
||||
@transaction.atomic()
|
||||
def perform_destroy(self, instance):
|
||||
instance.log_action(
|
||||
'pretix.gate.deleted',
|
||||
user=self.request.user,
|
||||
auth=self.request.auth,
|
||||
data={'id': instance.pk}
|
||||
)
|
||||
instance.delete()
|
||||
|
||||
@transaction.atomic()
|
||||
def perform_create(self, serializer):
|
||||
inst = serializer.save(organizer=self.request.organizer)
|
||||
inst.log_action(
|
||||
'pretix.gate.created',
|
||||
user=self.request.user,
|
||||
auth=self.request.auth,
|
||||
data=merge_dicts(self.request.data, {'id': inst.pk})
|
||||
)
|
||||
|
||||
@transaction.atomic()
|
||||
def perform_update(self, serializer):
|
||||
inst = serializer.save()
|
||||
inst.log_action(
|
||||
'pretix.gate.changed',
|
||||
user=self.request.user,
|
||||
auth=self.request.auth,
|
||||
data=self.request.data
|
||||
)
|
||||
return inst
|
||||
|
||||
|
||||
class OrganizerSettingsView(views.APIView):
|
||||
permission = None
|
||||
write_permission = 'organizer.settings.general:write'
|
||||
|
||||
@@ -621,8 +621,7 @@ class Item(LoggedModel):
|
||||
verbose_name=_('This product can only be bought using a voucher.'),
|
||||
default=False,
|
||||
help_text=_('To buy this product, the user needs a voucher that applies to this product '
|
||||
'either directly or via a quota. Please note that the waitinglist is not '
|
||||
'available for products requiring a voucher.')
|
||||
'either directly or via a quota.')
|
||||
)
|
||||
require_approval = models.BooleanField(
|
||||
verbose_name=_('Buying this product requires approval'),
|
||||
|
||||
@@ -23,13 +23,17 @@ from django import template
|
||||
from django.utils.html import format_html
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from pretix.helpers.templatetags.simple_block_tag import (
|
||||
register_simple_block_tag,
|
||||
)
|
||||
|
||||
from django.utils.translation import gettext_lazy as _ # NOQA
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_block_tag
|
||||
@register_simple_block_tag(register)
|
||||
def dialog(content, html_id, title, description, *args, **kwargs):
|
||||
format_kwargs = {
|
||||
"id": html_id,
|
||||
|
||||
@@ -39,16 +39,6 @@
|
||||
</button>
|
||||
{% endif %}
|
||||
</dd>
|
||||
<dt>{% trans "Claim token" context "reusable_media" %}</dt>
|
||||
<dd>
|
||||
{% if medium.claim_token %}
|
||||
{% if staff_session %}
|
||||
<code>{{ medium.claim_token }}</code>
|
||||
{% else %}
|
||||
*****
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>
|
||||
{% if not medium.active %}
|
||||
|
||||
@@ -242,26 +242,20 @@
|
||||
<p> </p>
|
||||
<fieldset>
|
||||
<legend>{% trans "Check-in lists" %}</legend>
|
||||
{% if block_list_change %}
|
||||
{% if sampled_lists|default_if_none:"NONE" == "NONE" %}
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
You selected a set of dates that currently have different check-in list setups and already
|
||||
contain checkins. You can therefore not change their check-in lists in bulk.
|
||||
You selected a set of dates that currently have different check-in list setups. You can
|
||||
therefore not change their check-in lists in bulk.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="bulk-edit-field-group">
|
||||
<label class="field-toggle">
|
||||
<input type="checkbox" name="_bulk" value="__checkinlists" {% if "__checkinlists" in bulk_selected %}checked{% endif %}>
|
||||
{% trans "change" context "form_bulk" %}
|
||||
</label>
|
||||
<div class="field-content">
|
||||
{% if sampled_lists|default_if_none:"NONE" == "NONE" %}
|
||||
<div class="alert alert-warning">
|
||||
{% trans "You selected a set of dates that currently have different check-in list setups." %}
|
||||
{% trans "Using this option will <strong>delete all current check-in lists</strong> from <strong>all selected dates</strong>." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="bulk-edit-field-group">
|
||||
<label class="field-toggle">
|
||||
<input type="checkbox" name="_bulk" value="__checkinlists" {% if "__checkinlists" in bulk_selected %}checked{% endif %}>
|
||||
{% trans "change" context "form_bulk" %}
|
||||
</label>
|
||||
<div class="field-content">
|
||||
<div class="formset" data-formset data-formset-prefix="{{ cl_formset.prefix }}">
|
||||
{{ cl_formset.management_form }}
|
||||
{% bootstrap_formset_errors cl_formset %}
|
||||
|
||||
@@ -60,7 +60,7 @@ from django.views.generic import (
|
||||
)
|
||||
|
||||
from pretix.base.models import CartPosition, LogEntry, OrderPosition
|
||||
from pretix.base.models.checkin import Checkin, CheckinList
|
||||
from pretix.base.models.checkin import CheckinList
|
||||
from pretix.base.models.event import SubEvent, SubEventMetaValue
|
||||
from pretix.base.models.items import (
|
||||
Item, ItemVariation, Quota, SubEventItem, SubEventItemVariation,
|
||||
@@ -1320,13 +1320,9 @@ class SubEventBulkEdit(SubEventQueryMixin, EventPermissionRequiredMixin, FormVie
|
||||
extra = 0
|
||||
kwargs = {}
|
||||
|
||||
if self.block_list_change:
|
||||
if self.sampled_lists is None:
|
||||
return None
|
||||
if self.sampled_lists is not None:
|
||||
try:
|
||||
kwargs['instance'] = self.get_queryset()[0]
|
||||
except IndexError:
|
||||
raise Http404("No matching dates")
|
||||
kwargs['instance'] = self.get_queryset()[0]
|
||||
|
||||
formsetclass = inlineformset_factory(
|
||||
SubEvent, CheckinList,
|
||||
@@ -1339,7 +1335,7 @@ class SubEventBulkEdit(SubEventQueryMixin, EventPermissionRequiredMixin, FormVie
|
||||
)
|
||||
|
||||
def save_list_formset(self, log_entries):
|
||||
if self.block_list_change or not self.list_formset.has_changed():
|
||||
if self.sampled_lists is None or not self.list_formset.has_changed():
|
||||
return
|
||||
qidx = 0
|
||||
subevents = list(self.get_queryset().prefetch_related('checkinlist_set'))
|
||||
@@ -1347,21 +1343,6 @@ class SubEventBulkEdit(SubEventQueryMixin, EventPermissionRequiredMixin, FormVie
|
||||
to_save_gates = []
|
||||
to_delete_list_ids = []
|
||||
|
||||
if self.sampled_lists is None:
|
||||
if len(self.list_formset.forms) == 0:
|
||||
return
|
||||
else:
|
||||
for se in subevents:
|
||||
for q in se.checkinlist_set.all():
|
||||
to_delete_list_ids.append(q.pk)
|
||||
log_entries += [
|
||||
q.log_action(action='pretix.event.checkinlist.deleted', user=self.request.user, save=False),
|
||||
]
|
||||
|
||||
if to_delete_list_ids:
|
||||
CheckinList.objects.filter(id__in=to_delete_list_ids).delete()
|
||||
to_delete_list_ids = []
|
||||
|
||||
for f in self.list_formset.forms:
|
||||
if self.list_formset._should_delete_form(f) and f in self.list_formset.extra_forms:
|
||||
continue
|
||||
@@ -1513,7 +1494,6 @@ class SubEventBulkEdit(SubEventQueryMixin, EventPermissionRequiredMixin, FormVie
|
||||
ctx['filter_form'] = self.filter_form
|
||||
ctx['sampled_quotas'] = self.sampled_quotas
|
||||
ctx['sampled_lists'] = self.sampled_lists
|
||||
ctx['block_list_change'] = self.block_list_change
|
||||
ctx['formset'] = self.quota_formset
|
||||
ctx['cl_formset'] = self.list_formset
|
||||
ctx['itemvar_forms'] = self.itemvar_forms
|
||||
@@ -1560,14 +1540,6 @@ class SubEventBulkEdit(SubEventQueryMixin, EventPermissionRequiredMixin, FormVie
|
||||
return None
|
||||
return se.quotas.all()
|
||||
|
||||
@cached_property
|
||||
def block_list_change(self):
|
||||
if self.sampled_lists:
|
||||
return False # all the same, safe to change
|
||||
return Checkin.all.filter(
|
||||
list__subevent__in=self.get_queryset()
|
||||
).exists()
|
||||
|
||||
@cached_property
|
||||
def sampled_lists(self):
|
||||
all_lists = CheckinList.objects.filter(
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# This file is part of pretix (Community Edition).
|
||||
#
|
||||
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||
# Copyright (C) 2020-today pretix GmbH and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||
#
|
||||
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||
# this file, see <https://pretix.eu/about/en/license>.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# backport from Django 5.2 (django/django/template/library.py)
|
||||
#
|
||||
# TODO: remove once we upgrade to Django 5.2
|
||||
|
||||
from functools import wraps
|
||||
from inspect import getfullargspec, unwrap
|
||||
|
||||
from django.template.exceptions import TemplateSyntaxError
|
||||
from django.template.library import SimpleNode, parse_bits
|
||||
|
||||
|
||||
class SimpleBlockNode(SimpleNode):
|
||||
def __init__(self, nodelist, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.nodelist = nodelist
|
||||
|
||||
def get_resolved_arguments(self, context):
|
||||
resolved_args, resolved_kwargs = super().get_resolved_arguments(context)
|
||||
|
||||
# Restore the "content" argument.
|
||||
# It will move depending on whether takes_context was passed.
|
||||
resolved_args.insert(
|
||||
1 if self.takes_context else 0, self.nodelist.render(context)
|
||||
)
|
||||
|
||||
return resolved_args, resolved_kwargs
|
||||
|
||||
|
||||
def register_simple_block_tag(library, func=None, takes_context=None, name=None, end_name=None):
|
||||
"""
|
||||
Register a callable as a compiled block template tag. Example:
|
||||
|
||||
@register_simple_block_tag(register)
|
||||
def hello(content):
|
||||
return 'world'
|
||||
"""
|
||||
def dec(func):
|
||||
nonlocal end_name
|
||||
|
||||
(
|
||||
params,
|
||||
varargs,
|
||||
varkw,
|
||||
defaults,
|
||||
kwonly,
|
||||
kwonly_defaults,
|
||||
_,
|
||||
) = getfullargspec(unwrap(func))
|
||||
function_name = name or func.__name__
|
||||
|
||||
if end_name is None:
|
||||
end_name = f"end{function_name}"
|
||||
|
||||
@wraps(func)
|
||||
def compile_func(parser, token):
|
||||
tag_params = params.copy()
|
||||
|
||||
if takes_context:
|
||||
if len(tag_params) >= 2 and tag_params[1] == "content":
|
||||
del tag_params[1]
|
||||
else:
|
||||
raise TemplateSyntaxError(
|
||||
f"{function_name!r} is decorated with takes_context=True so"
|
||||
" it must have a first argument of 'context' and a second "
|
||||
"argument of 'content'"
|
||||
)
|
||||
elif tag_params and tag_params[0] == "content":
|
||||
del tag_params[0]
|
||||
else:
|
||||
raise TemplateSyntaxError(
|
||||
f"'{function_name}' must have a first argument of 'content'"
|
||||
)
|
||||
|
||||
bits = token.split_contents()[1:]
|
||||
target_var = None
|
||||
if len(bits) >= 2 and bits[-2] == "as":
|
||||
target_var = bits[-1]
|
||||
bits = bits[:-2]
|
||||
|
||||
nodelist = parser.parse((end_name,))
|
||||
parser.delete_first_token()
|
||||
|
||||
args, kwargs = parse_bits(
|
||||
parser,
|
||||
bits,
|
||||
tag_params,
|
||||
varargs,
|
||||
varkw,
|
||||
defaults,
|
||||
kwonly,
|
||||
kwonly_defaults,
|
||||
takes_context,
|
||||
function_name,
|
||||
)
|
||||
|
||||
return SimpleBlockNode(
|
||||
nodelist, func, takes_context, args, kwargs, target_var
|
||||
)
|
||||
|
||||
library.tag(function_name, compile_func)
|
||||
return func
|
||||
|
||||
if func is None:
|
||||
# @register.simple_block_tag(...)
|
||||
return dec
|
||||
elif callable(func):
|
||||
# @register.simple_block_tag
|
||||
return dec(func)
|
||||
else:
|
||||
raise ValueError("Invalid arguments provided to simple_block_tag")
|
||||
@@ -1161,6 +1161,33 @@ class StripeCC(StripeMethod):
|
||||
}
|
||||
return template.render(ctx)
|
||||
|
||||
def _migrate_session(self, request):
|
||||
# todo: remove after pretix 2023.8 was released
|
||||
keymap = {
|
||||
'payment_stripe_payment_method_id': 'payment_stripe_card_payment_method_id',
|
||||
'payment_stripe_brand': 'payment_stripe_card_brand',
|
||||
'payment_stripe_last4': 'payment_stripe_card_last4',
|
||||
}
|
||||
for old, new in keymap.items():
|
||||
if old in request.session:
|
||||
request.session[new] = request.session[old]
|
||||
del request.session[old]
|
||||
|
||||
def checkout_prepare(self, request, cart):
|
||||
self._migrate_session(request)
|
||||
request.session['payment_stripe_card_brand'] = request.POST.get('stripe_card_brand', '')
|
||||
request.session['payment_stripe_card_last4'] = request.POST.get('stripe_card_last4', '')
|
||||
|
||||
return super().checkout_prepare(request, cart)
|
||||
|
||||
def payment_is_valid_session(self, request):
|
||||
self._migrate_session(request)
|
||||
return super().payment_is_valid_session(request)
|
||||
|
||||
def _handle_payment_intent(self, request, payment, intent=None):
|
||||
self._migrate_session(request)
|
||||
return super()._handle_payment_intent(request, payment, intent)
|
||||
|
||||
def is_moto(self, request, payment=None) -> bool:
|
||||
# We don't have a payment yet when checking if we should display the MOTO-flag
|
||||
# However, before we execute the payment, we absolutely have to check if the request-SalesChannel as well as the
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { SubEvent } from './i18n'
|
||||
import type { LocalizableString } from '@/pretix/static/pretixbase/js/i18n'
|
||||
import type { I18nString, SubEvent } from './i18n'
|
||||
|
||||
const settingsEl = document.getElementById('api-settings')
|
||||
const { urls } = JSON.parse(settingsEl.textContent || '{}') as { urls: {
|
||||
@@ -60,8 +59,8 @@ export interface Position {
|
||||
order: string
|
||||
positionid: number
|
||||
canceled?: boolean
|
||||
item: { id?: number; name: LocalizableString; internal_name?: string; admission?: boolean }
|
||||
variation: { id?: number; value: LocalizableString } | null
|
||||
item: { id?: number; name: I18nString; internal_name?: string; admission?: boolean }
|
||||
variation: { id?: number; value: I18nString } | null
|
||||
price: string
|
||||
attendee_name: string
|
||||
attendee_name_parts: Record<string, string>
|
||||
@@ -111,8 +110,8 @@ export interface Answer {
|
||||
|
||||
export interface AnswerQuestion {
|
||||
id: number
|
||||
question: LocalizableString
|
||||
help_text?: LocalizableString
|
||||
question: I18nString
|
||||
help_text?: I18nString
|
||||
type: string
|
||||
required: boolean
|
||||
position: number
|
||||
@@ -139,12 +138,12 @@ export interface QuestionOption {
|
||||
id: number
|
||||
identifier: string
|
||||
position: number
|
||||
answer: LocalizableString
|
||||
answer: I18nString
|
||||
}
|
||||
|
||||
export interface Addon {
|
||||
item: { name: LocalizableString; internal_name?: string }
|
||||
variation: { value: LocalizableString } | null
|
||||
item: { name: I18nString; internal_name?: string }
|
||||
variation: { value: I18nString } | null
|
||||
}
|
||||
|
||||
export interface CheckinStatusVariation {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
import { ref, computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import { api } from '../api'
|
||||
import type { CheckinList, Position, RedeemResponse, CheckinStatus, AnswerQuestion } from '../api'
|
||||
import { STRINGS, formatSubevent, formatAnswer } from '../i18n'
|
||||
import { localize_string } from '@/pretix/static/pretixbase/js/i18n'
|
||||
import { STRINGS, i18nstringLocalize, formatSubevent, formatAnswer } from '../i18n'
|
||||
|
||||
import CheckinlistSelect from './checkinlist-select.vue'
|
||||
import SearchresultItem from './searchresult-item.vue'
|
||||
@@ -115,9 +114,9 @@ const checkResultAddons = computed(() => {
|
||||
if (!checkResult.value?.position?.addons) return ''
|
||||
return checkResult.value.position.addons.map((addon) => {
|
||||
if (addon.variation) {
|
||||
return `+ ${addon.item.internal_name || localize_string(addon.item.name)} – ${localize_string(addon.variation.value)}`
|
||||
return `+ ${addon.item.internal_name || i18nstringLocalize(addon.item.name)} – ${i18nstringLocalize(addon.variation.value)}`
|
||||
}
|
||||
return '+ ' + (addon.item.internal_name || localize_string(addon.item.name))
|
||||
return '+ ' + (addon.item.internal_name || i18nstringLocalize(addon.item.name))
|
||||
}).join('\n')
|
||||
})
|
||||
|
||||
@@ -126,9 +125,9 @@ const checkResultSubevent = computed(() => formatSubevent(checkResult.value?.pos
|
||||
const checkResultItemvar = computed(() => {
|
||||
if (!checkResult.value?.position) return ''
|
||||
if (checkResult.value.position.variation) {
|
||||
return `${localize_string(checkResult.value.position.item.name)} – ${localize_string(checkResult.value.position.variation.value)}`
|
||||
return `${i18nstringLocalize(checkResult.value.position.item.name)} – ${i18nstringLocalize(checkResult.value.position.variation.value)}`
|
||||
}
|
||||
return localize_string(checkResult.value.position.item.name)
|
||||
return i18nstringLocalize(checkResult.value.position.item.name)
|
||||
})
|
||||
|
||||
const checkResultText = computed(() => {
|
||||
@@ -317,9 +316,9 @@ async function check (
|
||||
if (!answers.value[q.id.toString()]) {
|
||||
answers.value[q.id.toString()] = ''
|
||||
}
|
||||
;(q as AnswerQuestion).question = localize_string(q.question)
|
||||
;(q as AnswerQuestion).question = i18nstringLocalize(q.question)
|
||||
for (const o of q.options) {
|
||||
;(o as { answer: string }).answer = localize_string(o.answer)
|
||||
;(o as { answer: string }).answer = i18nstringLocalize(o.answer)
|
||||
}
|
||||
}
|
||||
nextTick(() => {
|
||||
@@ -411,7 +410,7 @@ onUnmounted(() => {
|
||||
span(v-for="a in checkResult.position.answers")
|
||||
span(v-if="a.question.show_during_checkin")
|
||||
br
|
||||
strong {{ localize_string(a.question.question) }}:
|
||||
strong {{ i18nstringLocalize(a.question.question) }}:
|
||||
| {{ formatAnswer(a.answer, a.question) }}
|
||||
strong(v-for="t in checkResult.checkin_texts")
|
||||
br
|
||||
|
||||
+3
-4
@@ -1,8 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import type { Position } from '../api'
|
||||
import { STRINGS, formatSubevent } from '../i18n'
|
||||
import { localize_string } from '@/pretix/static/pretixbase/js/i18n'
|
||||
import { STRINGS, i18nstringLocalize, formatSubevent } from '../i18n'
|
||||
|
||||
const props = defineProps<{
|
||||
position: Position
|
||||
@@ -23,9 +22,9 @@ const status = computed(() => {
|
||||
|
||||
const itemvar = computed(() => {
|
||||
if (props.position.variation) {
|
||||
return `${localize_string(props.position.item.name)} – ${localize_string(props.position.variation.value)}`
|
||||
return `${i18nstringLocalize(props.position.item.name)} – ${i18nstringLocalize(props.position.variation.value)}`
|
||||
}
|
||||
return localize_string(props.position.item.name)
|
||||
return i18nstringLocalize(props.position.item.name)
|
||||
})
|
||||
|
||||
const subevent = computed(() => formatSubevent(props.position.subevent))
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { localize_string } from '@/pretix/static/pretixbase/js/i18n'
|
||||
import '@/pretix/static/pretixbase/js/gettextstub'
|
||||
|
||||
const body = document.body
|
||||
|
||||
export const timezone = body.dataset.timezone ?? 'UTC'
|
||||
@@ -12,6 +9,27 @@ export const pretixLocale = body.dataset.pretixlocale ?? 'en'
|
||||
|
||||
moment.locale(datetimeLocale)
|
||||
|
||||
export function gettext (msgid: string): string {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid)
|
||||
}
|
||||
return msgid
|
||||
}
|
||||
|
||||
export function ngettext (singular: string, plural: string, count: number): string {
|
||||
if (typeof django !== 'undefined' && typeof django.ngettext !== 'undefined') {
|
||||
return django.ngettext(singular, plural, count)
|
||||
}
|
||||
return plural
|
||||
}
|
||||
|
||||
export type I18nString = string | Record<string, string> | null | undefined
|
||||
|
||||
export function i18nstringLocalize (obj: I18nString): string {
|
||||
// external
|
||||
return i18nstring_localize(obj)
|
||||
}
|
||||
|
||||
export const STRINGS: Record<string, string> = {
|
||||
'checkinlist.select': gettext('Select a check-in list'),
|
||||
'checkinlist.none': gettext('No active check-in lists found.'),
|
||||
@@ -65,7 +83,7 @@ export interface SubEvent {
|
||||
|
||||
export function formatSubevent (subevent: SubEvent | null | undefined): string {
|
||||
if (!subevent) return ''
|
||||
const name = localize_string(subevent.name)
|
||||
const name = i18nstringLocalize(subevent.name)
|
||||
const date = moment.utc(subevent.date_from).tz(timezone).format(datetimeFormat)
|
||||
return `${name} · ${date}`
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
data-pretixlocale="{{ request.LANGUAGE_CODE }}" data-timezone="{{ request.event.settings.timezone }}">
|
||||
<div id="app" data-event-name="{{ request.event.name }}"></div>
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="{% static "pretixbase/js/i18nstring.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "moment/moment-with-locales.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "moment/moment-timezone-with-data-1970-2030.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "jquery/js/jquery-3.6.4.min.js" %}"></script>
|
||||
|
||||
@@ -83,7 +83,8 @@ class CheckoutView(View):
|
||||
return self.redirect(previous_step.get_step_url(request) if previous_step else self.get_index_url(request))
|
||||
|
||||
if 'step' not in kwargs:
|
||||
return self.redirect(step.get_step_url(request))
|
||||
utm_params = {k: v for k, v in request.GET.items() if k.startswith("utm_") or k == "gclid" or k == "_gl"}
|
||||
return self.redirect(step.get_step_url(request) + '?' + urlencode(utm_params))
|
||||
is_selected = (step.identifier == kwargs.get('step', ''))
|
||||
|
||||
if not is_asyncaction_call and not is_selected and not step.is_completed(request, warn=not is_selected):
|
||||
@@ -104,6 +105,6 @@ class CheckoutView(View):
|
||||
raise Http404()
|
||||
|
||||
def redirect(self, url):
|
||||
params = {k: v for k, v in self.request.GET.items() if k in ("cart_id", "gclid", "_gl") or k.startswith("utm_")}
|
||||
url += ('&' if '?' in url else '?') + urlencode(params)
|
||||
if 'cart_id' in self.request.GET:
|
||||
url += ('&' if '?' in url else '?') + 'cart_id=' + quote(self.request.GET.get('cart_id'))
|
||||
return redirect_to_url(url)
|
||||
@@ -57,7 +57,6 @@ class WaitingView(EventViewMixin, FormView):
|
||||
self.request.event,
|
||||
subevent=self.subevent,
|
||||
require_seat=None,
|
||||
base_qs=self.request.event.items.filter(require_voucher=False),
|
||||
channel=self.request.organizer.sales_channels.get(identifier="web"),
|
||||
memberships=(
|
||||
customer.usable_memberships(
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { watchEffect } from 'vue'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
placeholders?: Record<string, string>;
|
||||
locales: Record<string, string>;
|
||||
errors?: string[];
|
||||
multiline?: boolean;
|
||||
}>()
|
||||
|
||||
const modelValue = defineModel<Record<string, string> | string>({ default: () => ({}) })
|
||||
|
||||
watchEffect(() => {
|
||||
if (typeof modelValue.value === 'string') {
|
||||
const oldVal = modelValue.value
|
||||
modelValue.value = Object.fromEntries(
|
||||
Object.keys(props.locales).map((x): [string, string] => [x, oldVal]),
|
||||
)
|
||||
}
|
||||
|
||||
const additionalLocales = new Set(Object.keys(modelValue.value)).difference(new Set(Object.keys(props.locales)))
|
||||
for (const additionalLocale of additionalLocales) {
|
||||
delete modelValue.value[additionalLocale]
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template lang="pug">
|
||||
template(v-if="!!modelValue")
|
||||
div.i18n-form-group
|
||||
component.form-control(
|
||||
:is="multiline ? 'textarea' : 'input'"
|
||||
v-for="(human_readable, locale) in locales"
|
||||
v-bind="$attrs"
|
||||
:key="locale"
|
||||
:lang="locale"
|
||||
:title="human_readable"
|
||||
:placeholder="placeholders?.[locale] || human_readable"
|
||||
:value="modelValue[locale]"
|
||||
@input="event => modelValue[locale] = event.target.value"
|
||||
)
|
||||
template(v-if="!!errors")
|
||||
.help-block(v-for="error in errors") {{ error }}
|
||||
</template>
|
||||
@@ -1,29 +1,29 @@
|
||||
// The actual gettext implementation is loaded asynchronously with the translation
|
||||
globalThis.gettext = (msgid) => {
|
||||
function gettext (msgid) {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid)
|
||||
}
|
||||
return msgid
|
||||
}
|
||||
|
||||
globalThis.ngettext = (singular, plural, count) => {
|
||||
function ngettext (singular, plural, count) {
|
||||
if (typeof django !== 'undefined' && typeof django.ngettext !== 'undefined') {
|
||||
return django.ngettext(singular, plural, count)
|
||||
}
|
||||
return plural
|
||||
}
|
||||
|
||||
globalThis.pgettext = (context, msgid) => {
|
||||
function pgettext (context, msgid) {
|
||||
if (typeof django !== 'undefined' && typeof django.pgettext !== 'undefined') {
|
||||
return django.pgettext(context, msgid)
|
||||
}
|
||||
return msgid
|
||||
}
|
||||
|
||||
globalThis.interpolate = (fmt, obj, named) => {
|
||||
function interpolate (fmt, obj, named) {
|
||||
if (named) {
|
||||
return fmt.replace(/%\(\w+\)s/g, function (match) { return String(obj[match.slice(2, -2)]) })
|
||||
} else {
|
||||
return fmt.replace(/%s/g, function (match) { return String(obj.shift()) })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
export type LocalizableString = null | string | Record<string, string>;
|
||||
|
||||
export function localize_string(s: LocalizableString, locale?: string): string {
|
||||
if (typeof s === "string") {
|
||||
return s;
|
||||
}
|
||||
if (s === null) {
|
||||
return null;
|
||||
}
|
||||
if (!locale) {
|
||||
locale = document.body.attributes["data-pretixlocale"].value;
|
||||
}
|
||||
var short_locale = locale.split("-")[0];
|
||||
if (locale in s) return s[locale];
|
||||
|
||||
if (short_locale in s) return s[short_locale];
|
||||
|
||||
for (const k of Object.keys(s)) {
|
||||
if (k.split("-")[0] === short_locale && s[k]) {
|
||||
return s[k];
|
||||
}
|
||||
}
|
||||
|
||||
if (s["en"]) return s["en"];
|
||||
|
||||
for (const k of Object.keys(s)) {
|
||||
if (s[k]) {
|
||||
return s[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
function i18nstring_localize (o) {
|
||||
let locale = document.body.attributes['data-pretixlocale'].value
|
||||
let short_locale = locale.split('-')[0]
|
||||
if (o[locale])
|
||||
return o[locale]
|
||||
|
||||
if (o[short_locale])
|
||||
return o[short_locale]
|
||||
|
||||
for (let k of Object.keys(o)) {
|
||||
if (k.split('-')[0] === short_locale && o[k]) {
|
||||
return o[k]
|
||||
}
|
||||
}
|
||||
|
||||
if (o['en'])
|
||||
return o['en']
|
||||
|
||||
for (let k of Object.keys(o)) {
|
||||
if (o[k]) {
|
||||
return o[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
/* global gettext, pgettext */
|
||||
|
||||
export const TEXTS = {
|
||||
and: gettext('All of the conditions below (AND)'),
|
||||
or: gettext('At least one of the conditions below (OR)'),
|
||||
|
||||
@@ -153,8 +153,8 @@ export function createWidgetStore (config: {
|
||||
},
|
||||
additionalURLParams (): string {
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
for (const key of [...params.keys()]) {
|
||||
if (!key.startsWith('utm_') && key !== 'gclid' && key !== '_gl') {
|
||||
for (const [key] of params.entries()) {
|
||||
if (!key.startsWith('utm_') || key !== 'gclid' || key !== '_gl') {
|
||||
params.delete(key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ from django.utils.timezone import now
|
||||
from django_scopes import scopes_disabled
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from pretix.base.models import Device, Event, Gate, Organizer, Team, User
|
||||
from pretix.base.models import Device, Event, Organizer, Team, User
|
||||
from pretix.base.models.devices import generate_api_token
|
||||
|
||||
|
||||
@@ -132,16 +132,6 @@ def device(organizer):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@scopes_disabled()
|
||||
def gate(organizer):
|
||||
return Gate.objects.create(
|
||||
organizer=organizer,
|
||||
name='Entry',
|
||||
identifier='entry'
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user():
|
||||
return User.objects.create_user('dummy@dummy.dummy', 'dummy')
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
#
|
||||
# This file is part of pretix (Community Edition).
|
||||
#
|
||||
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||
# Copyright (C) 2020-today pretix GmbH and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||
#
|
||||
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||
# this file, see <https://pretix.eu/about/en/license>.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
import pytest
|
||||
from django_scopes import scopes_disabled
|
||||
|
||||
from pretix.base.models import Gate
|
||||
|
||||
TEST_RES = {
|
||||
"name": "Entry",
|
||||
"identifier": "entry"
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gate_list(token_client, organizer, gate):
|
||||
res = dict(TEST_RES)
|
||||
|
||||
resp = token_client.get('/api/v1/organizers/{}/gates/'.format(organizer.slug))
|
||||
assert resp.status_code == 200
|
||||
gate.refresh_from_db()
|
||||
res["id"] = gate.pk
|
||||
assert [res] == resp.data['results']
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gate_detail(token_client, organizer, gate):
|
||||
res = dict(TEST_RES)
|
||||
resp = token_client.get('/api/v1/organizers/{}/gates/{}/'.format(organizer.slug, gate.id))
|
||||
assert resp.status_code == 200
|
||||
gate.refresh_from_db()
|
||||
res["id"] = gate.pk
|
||||
assert res == resp.data
|
||||
|
||||
|
||||
TEST_GATE_CREATE_PAYLOAD = {
|
||||
"name": "Second entry",
|
||||
"identifier": "entry_2"
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gate_create(token_client, organizer):
|
||||
resp = token_client.post(
|
||||
'/api/v1/organizers/{}/gates/'.format(organizer.slug),
|
||||
TEST_GATE_CREATE_PAYLOAD,
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
g = Gate.objects.get(id=resp.data['id'])
|
||||
assert g.name == TEST_GATE_CREATE_PAYLOAD.get('name')
|
||||
assert g.identifier == TEST_GATE_CREATE_PAYLOAD.get('identifier')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gate_update(token_client, organizer, gate):
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/gates/{}/'.format(organizer.slug, gate.id),
|
||||
{
|
||||
'name': 'Main entry'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
gate.refresh_from_db()
|
||||
assert gate.name == 'Main entry'
|
||||
assert gate.identifier == TEST_RES.get('identifier')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gate_delete(token_client, organizer, gate):
|
||||
resp = token_client.delete(
|
||||
'/api/v1/organizers/{}/gates/{}/'.format(organizer.slug, gate.id),
|
||||
)
|
||||
assert resp.status_code == 204
|
||||
with scopes_disabled():
|
||||
assert organizer.gates.count() == 0
|
||||
@@ -255,12 +255,6 @@ org_permission_sub_urls = [
|
||||
('get', 'organizer.devices:read', 'devices/1/', 404),
|
||||
('put', 'organizer.devices:write', 'devices/1/', 404),
|
||||
('patch', 'organizer.devices:write', 'devices/1/', 404),
|
||||
('get', 'organizer.devices:read', 'gates/', 200),
|
||||
('post', 'organizer.devices:write', 'gates/', 400),
|
||||
('get', 'organizer.devices:read', 'gates/1/', 404),
|
||||
('put', 'organizer.devices:write', 'gates/1/', 404),
|
||||
('patch', 'organizer.devices:write', 'gates/1/', 404),
|
||||
('delete', 'organizer.devices:write', 'gates/1/', 404),
|
||||
('get', 'organizer.teams:write', 'teams/', 200),
|
||||
('post', 'organizer.teams:write', 'teams/', 400),
|
||||
('get', 'organizer.teams:write', 'teams/{team_id}/', 200),
|
||||
@@ -326,13 +320,6 @@ def test_organizer_not_allowed_device(device_client, organizer):
|
||||
assert resp.status_code == 403
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organizer_not_allowed_gate(token_client, organizer):
|
||||
o2 = Organizer.objects.create(slug='o2', name='Organizer 2')
|
||||
resp = token_client.get('/api/v1/organizers/{}/gates/'.format(o2.slug))
|
||||
assert resp.status_code == 403
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organizer_not_existing(token_client, organizer):
|
||||
resp = token_client.get('/api/v1/organizers/{}/events/'.format('o2'))
|
||||
|
||||
@@ -1307,20 +1307,7 @@ class SubEventsTest(SoupTest):
|
||||
for se in [self.subevent1, self.subevent2]:
|
||||
assert se.checkinlist_set.count() == 1
|
||||
|
||||
def test_edit_bulk_lists_keep_mixed_if_checked_in(self):
|
||||
with scopes_disabled():
|
||||
self.subevent1.checkinlist_set.create(event=self.event1, name="C1")
|
||||
cl = self.subevent2.checkinlist_set.create(event=self.event1, name="C2")
|
||||
cl.checkins.create(
|
||||
successful=False,
|
||||
)
|
||||
doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', {
|
||||
'__ALL': 'on',
|
||||
}, follow=True)
|
||||
fields = extract_form_fields(doc)
|
||||
assert 'checkinlist_set-TOTAL_FORMS' not in fields
|
||||
|
||||
def test_edit_bulk_lists_replace_mixed_if_unused(self):
|
||||
def test_edit_bulk_lists_keep_mixed(self):
|
||||
with scopes_disabled():
|
||||
self.subevent1.checkinlist_set.create(event=self.event1, name="C1")
|
||||
self.subevent2.checkinlist_set.create(event=self.event1, name="C2")
|
||||
@@ -1328,18 +1315,4 @@ class SubEventsTest(SoupTest):
|
||||
'__ALL': 'on',
|
||||
}, follow=True)
|
||||
fields = extract_form_fields(doc)
|
||||
|
||||
fields.update({
|
||||
'_bulk': ['__checkinlists'],
|
||||
'checkinlist_set-TOTAL_FORMS': '1',
|
||||
'checkinlist_set-INITIAL_FORMS': '0',
|
||||
'checkinlist_set-MIN_NUM_FORMS': '0',
|
||||
'checkinlist_set-MAX_NUM_FORMS': '1000',
|
||||
'checkinlist_set-0-name': 'Default',
|
||||
'checkinlist_set-0-all_products': 'on',
|
||||
})
|
||||
doc = self.post_doc('/control/event/ccc/30c3/subevents/bulk_edit', fields, follow=True)
|
||||
assert doc.select(".alert-success")
|
||||
with scopes_disabled():
|
||||
assert self.subevent1.checkinlist_set.get().name == "Default"
|
||||
assert self.subevent2.checkinlist_set.get().name == "Default"
|
||||
assert 'checkinlist_set-TOTAL_FORMS' not in fields
|
||||
+1
-3
@@ -7,9 +7,7 @@
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
},
|
||||
"paths": {},
|
||||
"strict": false,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
|
||||
+3
-6
@@ -25,9 +25,6 @@ export default defineConfig({
|
||||
// Pin shared deps to pretix's node_modules to prevent duplicate instances
|
||||
// across plugins whose node_modules live in sibling directories
|
||||
dedupe: [...SHARED_DEPS, '@vue/runtime-core', '@vue/reactivity', '@vue/shared'],
|
||||
alias: {
|
||||
'@': path.resolve(import.meta.dirname, 'src'),
|
||||
}
|
||||
},
|
||||
server: {
|
||||
fs: {
|
||||
@@ -40,12 +37,12 @@ export default defineConfig({
|
||||
},
|
||||
build: {
|
||||
manifest: true,
|
||||
outDir: path.resolve(import.meta.dirname, 'src/pretix/static.dist/vite/control'),
|
||||
outDir: path.resolve(__dirname, 'src/pretix/static.dist/vite/control'),
|
||||
rollupOptions: {
|
||||
preserveEntrySignatures: 'exports-only',
|
||||
input: {
|
||||
'webcheckin/main': path.resolve(import.meta.dirname, 'src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.ts'),
|
||||
'checkinrules/main': path.resolve(import.meta.dirname, 'src/pretix/static/pretixcontrol/js/ui/checkinrules/index.ts'),
|
||||
'webcheckin/main': path.resolve(__dirname, 'src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.ts'),
|
||||
'checkinrules/main': path.resolve(__dirname, 'src/pretix/static/pretixcontrol/js/ui/checkinrules/index.ts'),
|
||||
...Object.fromEntries(SHARED_DEPS.map(dep => [`_vendor/${dep}`, `virtual:vendor/${dep}`])),
|
||||
...pretixPluginEntries,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user