Compare commits

..
Author SHA1 Message Date
Raphael Michel f4289632e9 Remove unussed LockModel 2026-11-22 16:20:39 +01:00
15 changed files with 63 additions and 664 deletions

No files matched your search

-195
View File
@@ -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.
+1 -8
View File
@@ -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
-1
View File
@@ -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)
+10 -35
View File
@@ -92,9 +92,9 @@ from pretix.base.services.invoices import (
regenerate_invoice, transmit_invoice,
)
from pretix.base.services.orders import (
OrderChangeManager, OrderError, _attendee_mail_send_helper,
_order_placed_email, approve_order, cancel_order, deny_order, extend_order,
mark_order_expired, mark_order_refunded, reactivate_order,
OrderChangeManager, OrderError, _order_placed_email,
_order_placed_email_attendee, approve_order, cancel_order, deny_order,
extend_order, mark_order_expired, mark_order_refunded, reactivate_order,
)
from pretix.base.services.pricing import get_price
from pretix.base.services.tickets import generate
@@ -805,42 +805,17 @@ class EventOrderViewSet(OrderViewSetMixin, viewsets.ModelViewSet):
log_entry, invoice, [payment] if payment else [], is_free=free_flow
)
if email_attendees:
ev = request.event
# todo re note: order_placed_email for attendees (formerly services/orders _order_placed_email_attendee)
_attendee_mail_send_helper(
event=ev,
order=order,
positions=order.positions.all(),
template=email_attendees_template,
subject=subject_attendees_template,
log_entry_type=log_entry,
attach_tickets=True,
attach_ical=ev.settings.mail_attach_ical and (
not ev.settings.mail_attach_ical_paid_only or
free_flow or
order.valid_if_pending
),
attach_other_files=[a for a in [
ev.settings.get('mail_attachment_new_order', as_type=str, default='')[len('file://'):]
] if a],
)
for p in order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
_order_placed_email_attendee(request.event, order, p, email_attendees_template, subject_attendees_template,
log_entry, is_free=free_flow)
if not free_flow and order.status == Order.STATUS_PAID and payment:
payment._send_paid_mail(invoice, None, '')
if self.request.event.settings.mail_send_order_paid_attendee:
ev = request.event
# todo re note: paid_mail for attendees (formerly models/orders _send_paid_mail_attendee)
_attendee_mail_send_helper(
event=ev,
order=order,
positions=order.positions.all(),
template=ev.settings.mail_text_order_paid_attendee,
subject=ev.settings.mail_subject_order_paid_attendee,
log_entry_type='pretix.event.order.email.order_paid',
invoices=[],
attach_tickets=True,
attach_ical=ev.settings.mail_attach_ical
)
for p in order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
payment._send_paid_mail_attendee(p, None)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
+4 -50
View File
@@ -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'
-47
View File
@@ -24,7 +24,6 @@ import uuid
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.signals import post_delete
from django.dispatch import receiver
from django.urls import reverse
@@ -245,49 +244,3 @@ class LoggedModel(models.Model, LoggingMixin):
return LogEntry.objects.filter(
content_type=self.logs_content_type, object_id=self.pk
).select_related('user', 'event', 'event__organizer', 'oauth_application', 'api_token', 'device')
class LockModel:
def refresh_for_update(self, fields=None, using=None, **kwargs):
"""
Like refresh_from_db(), but with select_for_update().
See also https://code.djangoproject.com/ticket/28344
"""
if fields is not None:
if not fields:
return
if any(LOOKUP_SEP in f for f in fields):
raise ValueError(
'Found "%s" in fields argument. Relations and transforms '
'are not allowed in fields.' % LOOKUP_SEP)
hints = {'instance': self}
db_instance_qs = self.__class__._base_manager.db_manager(using, hints=hints).filter(pk=self.pk).select_for_update(**kwargs)
# Use provided fields, if not set then reload all non-deferred fields.
deferred_fields = self.get_deferred_fields()
if fields is not None:
fields = list(fields)
db_instance_qs = db_instance_qs.only(*fields)
elif deferred_fields:
fields = [f.attname for f in self._meta.concrete_fields
if f.attname not in deferred_fields]
db_instance_qs = db_instance_qs.only(*fields)
db_instance = db_instance_qs.get()
non_loaded_fields = db_instance.get_deferred_fields()
for field in self._meta.concrete_fields:
if field.attname in non_loaded_fields:
# This field wasn't refreshed - skip ahead.
continue
setattr(self, field.attname, getattr(db_instance, field.attname))
# Clear cached foreign keys.
if field.is_relation and field.is_cached(self):
field.delete_cached_value(self)
# Clear cached relations.
for field in self._meta.related_objects:
if field.is_cached(self):
field.delete_cached_value(self)
self._state.db = db_instance._state.db
+5 -19
View File
@@ -93,7 +93,7 @@ from ...testutils.middleware import debugflags_var
from ._transactions import (
_fail, _transactions_mark_order_clean, _transactions_mark_order_dirty,
)
from .base import LockModel, LoggedModel
from .base import LoggedModel
from .event import Event, SubEvent
from .items import Item, ItemVariation, Question, QuestionOption, Quota
@@ -136,7 +136,7 @@ class OrderQuerySet(models.QuerySet):
return order
class Order(LockModel, LoggedModel):
class Order(LoggedModel):
"""
An order is created when a user clicks 'buy' on his cart. It holds
several OrderPositions and is connected to a user. It has an
@@ -2002,23 +2002,9 @@ class OrderPayment(models.Model):
if send_mail and self.order.sales_channel.identifier in self.order.event.settings.mail_sales_channel_placed_paid:
self._send_paid_mail(invoice if transmit_invoice_mail else None, user, mail_text)
if self.order.event.settings.mail_send_order_paid_attendee:
# todo re note: paid_mail for attendees (formerly models/orders _send_paid_mail_attendee)
from pretix.base.services.orders import (
_attendee_mail_send_helper,
)
_attendee_mail_send_helper(
event=self.order.event,
order=self.order,
positions=self.order.positions.all(),
template=self.order.event.settings.mail_text_order_paid_attendee,
subject=self.order.event.settings.mail_subject_order_paid_attendee,
log_entry_type='pretix.event.order.email.order_paid',
user=user,
invoices=[],
attach_tickets=True,
attach_ical=self.order.event.settings.mail_attach_ical,
)
for p in self.order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != self.order.email:
self._send_paid_mail_attendee(p, user)
if invoice and not transmit_invoice_mail:
transmit_invoice.apply_async(args=(self.order.event_id, invoice.pk, False))
+21 -28
View File
@@ -39,8 +39,7 @@ from pretix.base.models import (
from pretix.base.services.locking import LockTimeoutException
from pretix.base.services.mail import mail
from pretix.base.services.orders import (
OrderChangeManager, OrderError, _attendee_mail_send_helper, _cancel_order,
_try_auto_refund,
OrderChangeManager, OrderError, _cancel_order, _try_auto_refund,
)
from pretix.base.services.tasks import ProfiledEventTask
from pretix.base.services.tax import split_fee_for_taxes
@@ -65,7 +64,7 @@ def _send_wle_mail(wle: WaitingListEntry, subject: LazyI18nString, message: Lazy
def _send_mail(order: Order, subject: LazyI18nString, message: LazyI18nString, subevent: SubEvent,
refund_amount: Decimal, user: User, positions: list, send_attendees: bool = True):
refund_amount: Decimal, user: User, positions: list):
with language(order.locale, order.event.settings.region):
try:
ia = order.invoice_address
@@ -80,32 +79,33 @@ def _send_mail(order: Order, subject: LazyI18nString, message: LazyI18nString, s
user,
)
# send_attendees defaults to true, for backwards compatibility (we used to send to everyone)
if send_attendees:
_attendee_mail_send_helper(
event=order.event,
order=order,
positions=positions,
template=message,
subject=subject,
log_entry_type='pretix.event.order.email.event_canceled',
user=user,
subevent=subevent,
)
for p in positions:
if subevent and p.subevent_id != subevent.id:
continue
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
email_context = get_email_context(event_or_subevent=p.subevent or order.event,
event=order.event,
refund_amount=refund_amount,
position_or_address=p,
order=order, position=p)
order.send_mail(
subject, message, email_context,
'pretix.event.order.email.event_canceled',
position=p,
user=user
)
@app.task(base=ProfiledEventTask, bind=True, max_retries=5, default_retry_delay=1, throws=(OrderError,))
def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
keep_fee_fixed: str, keep_fee_per_ticket: str, keep_fee_percentage: str, keep_fees: list=None,
manual_refund: bool = False, send: bool = False, send_subject: dict = None, send_message: dict = None,
send_attendees: bool = False, send_subject_attendees: dict = None, send_message_attendees: dict = None,
manual_refund: bool=False, send: bool=False, send_subject: dict=None, send_message: dict=None,
send_waitinglist: bool=False, send_waitinglist_subject: dict={}, send_waitinglist_message: dict={},
user: int=None, refund_as_giftcard: bool=False, giftcard_expires=None, giftcard_conditions=None,
subevents_from: str=None, subevents_to: str=None, dry_run=False):
send_subject = LazyI18nString(send_subject)
send_message = LazyI18nString(send_message)
send_subject_attendees = LazyI18nString(send_subject)
send_message_attendees = LazyI18nString(send_message)
send_waitinglist_subject = LazyI18nString(send_waitinglist_subject)
send_waitinglist_message = LazyI18nString(send_waitinglist_message)
if user:
@@ -166,9 +166,6 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
"send": send,
"send_subject": send_subject,
"send_message": send_message,
"send_attendees": send_attendees,
"send_subject_attendees": send_subject_attendees,
"send_message_attendees": send_message_attendees,
"send_waitinglist": send_waitinglist,
"send_waitinglist_subject": send_waitinglist_subject,
"send_waitinglist_message": send_waitinglist_message,
@@ -201,9 +198,6 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
"send": send,
"send_subject": send_subject,
"send_message": send_message,
"send_attendees": send_attendees,
"send_subject_attendees": send_subject_attendees,
"send_message_attendees": send_message_attendees,
"send_waitinglist": send_waitinglist,
"send_waitinglist_subject": send_waitinglist_subject,
"send_waitinglist_message": send_waitinglist_message,
@@ -272,8 +266,7 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
comment=gettext('Event canceled'))
finally:
if send:
_send_mail(o, send_subject, send_message, subevent, refund_amount, user, o.positions.all(),
send_attendees)
_send_mail(o, send_subject, send_message, subevent, refund_amount, user, o.positions.all())
counter += 1
if not self.request.called_directly and counter % max(10, total // 100) == 0:
@@ -359,7 +352,7 @@ def cancel_event(self, event: Event, subevent: int, auto_refund: bool,
comment=gettext('Event canceled'))
if send:
_send_mail(o, send_subject, send_message, subevent, refund_amount, user, positions, send_attendees)
_send_mail(o, send_subject, send_message, subevent, refund_amount, user, positions)
counter += 1
if not self.request.called_directly and counter % max(10, total // 100) == 0:
+21 -116
View File
@@ -114,76 +114,6 @@ from pretix.presale.productlist import prepare_item_list_for_shop
from pretix.testutils.middleware import debugflags_var
# todo before pr ready: (aka note to myself)
# think about placing this helper function somewhere better
# also: check those mail send functions, instead of replacing
# maybe we still want to use them here instead of generic send_mail
# and/or maybe we want to generalize this thing to also include order mails
# (let's maybe not rewrite the whole mail logic?!)
# but also, remember to write tests - a whole bunch of tests
def _attendee_mail_send_helper(
event: Event,
order: Order,
positions: list,
template,
subject,
user,
invoices: list = None,
log_entry_type: str = 'pretix.event.order.email.sent',
attach_tickets: bool = False,
attach_ical: bool = False,
attach_other_files: list = None,
subevent: SubEvent = None,
):
parent_op = None
sent_to_positions = set()
for p in positions:
if subevent and p.subevent_id != subevent.id:
continue
if p.addon_to_id is None:
# this op might have matching add-ons, so save for later
parent_op = p
elif not parent_op or p.addon_to_id != parent_op.id:
# this op is an add-on, but not to the current parent_op
# something got mixed up as add-ons should always come directly after their parent
logger.warning(f"Add-ons are mixed up for position #{p.positionid} in order {order.full_code}")
continue
if p.addon_to_id and (
not p.attendee_email or p.attendee_email == parent_op.attendee_email
):
# if op is addon and either has no mail or the same as parent => send to parent
p = parent_op
if p.pk in sent_to_positions:
# this position already got an email
continue
if not p.attendee_email or p.attendee_email == order.email:
# no email or same as order
continue
email_ctx = get_email_context(event=order.event, order=order, position=p)
p.send_mail(
subject=subject,
template=template,
context=email_ctx,
log_entry_type=log_entry_type,
user=user if user else None,
invoices=invoices,
attach_tickets=attach_tickets,
attach_ical=attach_ical,
attach_other_files=attach_other_files,
# possible, as of yet unused here, parameters:
# headers: dict=None,
# sender: str=None,
# auth=None,
)
sent_to_positions.add(p.pk)
class OrderError(Exception):
def __init__(self, *args):
msg = args[0]
@@ -532,21 +462,14 @@ def approve_order(order, user=None, send_mail: bool=True, auth=None, force=False
)
if email_attendees:
_attendee_mail_send_helper(
event=order.event,
order=order,
positions=order.positions.all(),
template=email_attendee_template,
subject=email_attendee_subject,
log_entry_type='pretix.event.order.email.order_approved',
user=user,
attach_tickets=True,
attach_ical=order.event.settings.mail_attach_ical and (
not order.event.settings.mail_attach_ical_paid_only or
order.total == Decimal('0.00') or
order.valid_if_pending
),
)
for p in order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
email_attendee_context = get_email_context(event=order.event, order=order, position=p)
p.send_mail(
email_attendee_subject, email_attendee_template, email_attendee_context,
'pretix.event.order.email.order_approved', user,
attach_tickets=True,
)
return order.pk
@@ -1477,20 +1400,10 @@ def _perform_order(event: Event, payment_requests: List[dict], position_ids: Lis
is_free=free_order_flow
)
if email_attendees:
# todo re note: order_placed_email for attendees (formerly services/orders _order_placed_email_attendee)
_attendee_mail_send_helper(
event=event,
order=order,
positions=order.positions.all(),
template=email_attendees_template,
subject=subject_attendees_template,
log_entry_type=log_entry,
attach_ical=event.settings.mail_attach_ical and (
not event.settings.mail_attach_ical_paid_only or
free_order_flow or
order.valid_if_pending
),
)
for p in order.positions.all():
if p.addon_to_id is None and p.attendee_email and p.attendee_email != order.email:
_order_placed_email_attendee(event, order, p, email_attendees_template, subject_attendees_template, log_entry,
is_free=free_order_flow)
if not any_payment_failed:
for p in payment_objs:
@@ -1689,7 +1602,6 @@ def send_download_reminders(sender, **kwargs):
)
if event.settings.mail_send_download_reminder_attendee:
send_to_positions = []
for p in positions:
if p.subevent_id:
reminder_date = (p.subevent.date_from - timedelta(days=event.reminder_days)).replace(
@@ -1697,22 +1609,15 @@ def send_download_reminders(sender, **kwargs):
)
if now() < reminder_date:
continue
else:
send_to_positions.append(p)
# todo before pr ready (aka note to myself):
# order's send_mail used before, check if there was a good reason to not
# use postion's send_mail
# if not, look for a way to not use double iteration over positions (see above)
# otherwise: rewrite this without this helper function anyway
_attendee_mail_send_helper(
event=event,
order=o,
positions=send_to_positions,
email_template=event.settings.mail_text_download_reminder_attendee,
email_subject=event.settings.mail_subject_download_reminder_attendee,
log_entry_type='pretix.event.order.email.download_reminder_sent',
attach_tickets=True,
)
if p.addon_to_id is None and p.attendee_email and p.attendee_email != o.email:
email_template = event.settings.mail_text_download_reminder_attendee
email_subject = event.settings.mail_subject_download_reminder_attendee
email_context = get_email_context(event=event, order=o, position=p)
o.send_mail(
email_subject, email_template, email_context,
'pretix.event.order.email.download_reminder_sent',
attach_tickets=True, position=p
)
def notify_user_changed_order(order, user=None, auth=None, invoices=[]):
-37
View File
@@ -942,9 +942,6 @@ class EventCancelForm(FormPlaceholderMixin, forms.Form):
)
send_subject = forms.CharField()
send_message = forms.CharField()
send_attendees = forms.BooleanField()
send_subject_attendees = forms.CharField()
send_message_attendees = forms.CharField()
send_waitinglist = forms.BooleanField(
label=_("Send information to waiting list"),
required=False
@@ -979,45 +976,11 @@ class EventCancelForm(FormPlaceholderMixin, forms.Form):
'Your {event} team'
))
)
self.fields['send_attendees'] = forms.BooleanField(
label=_("Send an email to attendees"),
help_text=_('If the order contains attendees with email addresses different from the person who orders the '
'tickets, the following email will be sent out to the attendees.'),
required=False,
initial=True,
)
self.fields['send_subject_attendees'] = I18nFormField(
label=_("Subject sent to attendees"),
required=True,
widget_kwargs={'attrs': {'data-display-dependency': '#id_send_attendees'}},
initial=LazyI18nString.from_gettext(gettext_noop('Canceled: {event}')),
widget=I18nTextInput,
locales=self.event.settings.get('locales'),
)
self.fields['send_message_attendees'] = I18nFormField(
label=_("Text sent to attendees"),
required=True,
widget=I18nMarkdownTextarea,
widget_kwargs={'attrs': {'data-display-dependency': '#id_send_attendees'}},
locales=self.event.settings.get('locales'),
initial=LazyI18nString.from_gettext(gettext_noop(
'Hello,\n\n'
'with this email, we regret to inform you that {event} has been canceled.\n\n'
'You can view the current state of your order here:\n\n{url}\n\nBest regards, \n\n'
'Your {event} team'
))
)
self._set_field_placeholders('send_subject', ['event_or_subevent', 'refund_amount', 'position_or_address',
'order', 'event'])
self._set_field_placeholders('send_message', ['event_or_subevent', 'refund_amount', 'position_or_address',
'order', 'event'], rich=True)
self._set_field_placeholders('send_subject_attendees',
['event_or_subevent', 'refund_amount', 'position_or_address',
'order', 'event'])
self._set_field_placeholders('send_message_attendees',
['event_or_subevent', 'refund_amount', 'position_or_address',
'order', 'event'], rich=True)
self.fields['send_waitinglist_subject'] = I18nFormField(
label=_("Subject"),
required=True,
@@ -50,11 +50,6 @@
{% bootstrap_field form.send layout="control" %}
{% bootstrap_field form.send_subject layout="horizontal" %}
{% bootstrap_field form.send_message layout="horizontal" %}
<div data-display-dependency="#id_send">
{% bootstrap_field form.send_attendees layout="control" %}
{% bootstrap_field form.send_subject_attendees layout="horizontal" %}
{% bootstrap_field form.send_message_attendees layout="horizontal" %}
</div>
<div class="alert alert-info" data-display-dependency="#id_refund_as_giftcard">
{% blocktrans trimmed %}
Since you are refunding your customers orders to gift cards, you should explain to them how to
-3
View File
@@ -3117,9 +3117,6 @@ class EventCancel(EventPermissionRequiredMixin, AsyncAction, FormView):
send=form.cleaned_data.get('send'),
send_subject=form.cleaned_data.get('send_subject').data,
send_message=form.cleaned_data.get('send_message').data,
send_attendees=form.cleaned_data.get('send'),
send_subject_attendees=form.cleaned_data.get('send_subject').data,
send_message_attendees=form.cleaned_data.get('send_message').data,
send_waitinglist=form.cleaned_data.get('send_waitinglist'),
send_waitinglist_subject=form.cleaned_data.get('send_waitinglist_subject').data,
send_waitinglist_message=form.cleaned_data.get('send_waitinglist_message').data,
+1 -11
View File
@@ -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')
-96
View File
@@ -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
-13
View File
@@ -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'))