mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
* MKBDIGI-185: Added update/create to events * MKBDIGI-185: Added validation for 'slug, 'live' on event endpoint * MKBDIGI-185: Code formatting * MKBDIGI-185: Added 'plugins' to 'event' endpoint * MKBDIGI-185: Merge migrations * MKBDIGI-185: Cleaned up static methods * EBILL-5: Added delete endpoint for event * EBILL-5: Merge migrations * EBILL-5: Fixed imports * EBILL-5: Changed plugins to only list plugins enabled for the event * EBILL-5: Added clone event endpoint * EBILL-5: Removed permissions check API test for events * EBILL-5: Merged master, updated migrations * EBILL-5: Updated api permissions check for CRUD on events * EBILL-5: Removed 'unique_together' constraint on event model * EBILL-5: Removed call to changed static methods in test * EBILL-5: Changed Event 'has_paid_things' to a property for consistency * EBILL-5: Fixed created response code in documentation * EBILL-6: Documentation fixes * EBILL-6: Fixed typo * EBILL-6: Fixed permissions * EBILL-6: Added note on copying settings to documentation * EBILL-6: Created model method for deleting sub objects on event before delete * EBILL-6: Fixed typo * EBILL-6: Re-added meta_data as read-only * EBILL-6: Fixed permissions test * EBILL-6: Added plugins issues check before live. Moved issues property from form to Event model. * EBILL-6: Upped version number in documentation * Add write support for MetaDataField * EBILL-6: Expanded documentation for the clone endpoint, made behaviour of 'is_public' similar to 'plugins' for consistency * EBILL-6: Re-added EventCRUDPermission * EBILL-16: Updated documentation with permission model for the API * EBILL-16: Added 'has_subevents' validation to ensure it cannot be changed once event is created. * EBILL-16: Fixed event clone not differentiating between "not set" and "deliberately set to False" * EBILL-16: Fixed event live validation * EBILL-16: Added logging of live activated/deactivated * EBILL-16: Fixed create event bug when no 'meta_data' supplied * EBILL-16: Typo fixed * EBILL-16: Added log display for "event created" * EBILL-16: Enabling a plugin now calls 'installed' if applicable and log entries are added * EBILL-16: Updated tests for events * Do not allow enabling restricted plugins via the API * Remove unused code
This commit is contained in:
committed by
Raphael Michel
parent
1a0e2031d2
commit
7bb18f6fad
@@ -30,13 +30,13 @@ from pytz import timezone
|
||||
|
||||
from pretix.base.i18n import LazyCurrencyNumber
|
||||
from pretix.base.models import (
|
||||
CachedCombinedTicket, CachedTicket, Event, Item, ItemVariation, LogEntry,
|
||||
Order, RequiredAction, TaxRule, Voucher,
|
||||
CachedCombinedTicket, CachedTicket, Event, LogEntry, Order, RequiredAction,
|
||||
TaxRule, Voucher,
|
||||
)
|
||||
from pretix.base.models.event import EventMetaValue
|
||||
from pretix.base.services import tickets
|
||||
from pretix.base.services.invoices import build_preview_invoice_pdf
|
||||
from pretix.base.signals import event_live_issues, register_ticket_outputs
|
||||
from pretix.base.signals import register_ticket_outputs
|
||||
from pretix.base.templatetags.money import money_filter
|
||||
from pretix.control.forms.event import (
|
||||
CommentForm, DisplaySettingsForm, EventDeleteForm, EventMetaValueForm,
|
||||
@@ -200,34 +200,29 @@ class EventPlugins(EventSettingsViewMixin, EventPermissionRequiredMixin, Templat
|
||||
|
||||
self.object = self.get_object()
|
||||
|
||||
plugins_active = self.object.get_plugins()
|
||||
plugins_available = {
|
||||
p.module: p for p in get_all_plugins()
|
||||
if not p.name.startswith('.') and getattr(p, 'visible', True)
|
||||
}
|
||||
|
||||
with transaction.atomic():
|
||||
allow_restricted = request.user.has_active_staff_session(request.session.session_key)
|
||||
|
||||
for key, value in request.POST.items():
|
||||
if key.startswith("plugin:"):
|
||||
module = key.split(":")[1]
|
||||
if value == "enable" and module in plugins_available:
|
||||
if getattr(plugins_available[module], 'restricted', False):
|
||||
if not request.user.has_active_staff_session(request.session.session_key):
|
||||
if not allow_restricted:
|
||||
continue
|
||||
|
||||
if hasattr(plugins_available[module].app, 'installed'):
|
||||
getattr(plugins_available[module].app, 'installed')(self.request.event)
|
||||
|
||||
self.request.event.log_action('pretix.event.plugins.enabled', user=self.request.user,
|
||||
data={'plugin': module})
|
||||
if module not in plugins_active:
|
||||
plugins_active.append(module)
|
||||
self.object.enable_plugin(module, allow_restricted=allow_restricted)
|
||||
else:
|
||||
self.request.event.log_action('pretix.event.plugins.disabled', user=self.request.user,
|
||||
data={'plugin': module})
|
||||
if module in plugins_active:
|
||||
plugins_active.remove(module)
|
||||
self.object.plugins = ",".join(plugins_active)
|
||||
self.object.disable_plugin(module)
|
||||
self.object.save()
|
||||
messages.success(self.request, _('Your changes have been saved.'))
|
||||
return redirect(self.get_success_url())
|
||||
@@ -749,38 +744,11 @@ class EventLive(EventPermissionRequiredMixin, TemplateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['issues'] = self.issues
|
||||
ctx['issues'] = self.request.event.live_issues
|
||||
return ctx
|
||||
|
||||
@cached_property
|
||||
def issues(self):
|
||||
issues = []
|
||||
has_paid_things = (
|
||||
Item.objects.filter(event=self.request.event, default_price__gt=0).exists()
|
||||
or ItemVariation.objects.filter(item__event=self.request.event, default_price__gt=0).exists()
|
||||
)
|
||||
|
||||
has_payment_provider = False
|
||||
for provider in self.request.event.get_payment_providers().values():
|
||||
if provider.is_enabled and provider.identifier != 'free':
|
||||
has_payment_provider = True
|
||||
break
|
||||
|
||||
if has_paid_things and not has_payment_provider:
|
||||
issues.append(_('You have configured at least one paid product but have not enabled any payment methods.'))
|
||||
|
||||
if not self.request.event.quotas.exists():
|
||||
issues.append(_('You need to configure at least one quota to sell anything.'))
|
||||
|
||||
responses = event_live_issues.send(self.request.event)
|
||||
for receiver, response in sorted(responses, key=lambda r: str(r[0])):
|
||||
if response:
|
||||
issues.append(response)
|
||||
|
||||
return issues
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if request.POST.get("live") == "true" and not self.issues:
|
||||
if request.POST.get("live") == "true" and not self.request.event.live_issues:
|
||||
request.event.live = True
|
||||
request.event.save()
|
||||
self.request.event.log_action(
|
||||
@@ -831,8 +799,7 @@ class EventDelete(EventPermissionRequiredMixin, FormView):
|
||||
'logentries': list(self.request.event.logentry_set.values_list('pk', flat=True))
|
||||
}
|
||||
)
|
||||
self.request.event.items.all().delete()
|
||||
self.request.event.subevents.all().delete()
|
||||
self.request.event.delete_sub_objects()
|
||||
self.request.event.delete()
|
||||
messages.success(self.request, _('The event has been deleted.'))
|
||||
return redirect(self.get_success_url())
|
||||
|
||||
Reference in New Issue
Block a user