Example #1
0
 def patch(self, request, *wargs, **kwargs):
     s = EventSettingsSerializer(instance=request.event.settings, data=request.data, partial=True,
                                 event=request.event)
     s.is_valid(raise_exception=True)
     with transaction.atomic():
         s.save()
         self.request.event.log_action(
             'pretix.event.settings', user=self.request.user, auth=self.request.auth, data={
                 k: v for k, v in s.validated_data.items()
             }
         )
     s = EventSettingsSerializer(instance=request.event.settings, event=request.event)
     return Response(s.data)
Example #2
0
 def get(self, request, *args, **kwargs):
     if isinstance(request.auth, Device):
         s = DeviceEventSettingsSerializer(instance=request.event.settings, event=request.event)
     elif 'can_change_event_settings' in request.eventpermset:
         s = EventSettingsSerializer(instance=request.event.settings, event=request.event)
     else:
         raise PermissionDenied()
     if 'explain' in request.GET:
         return Response({
             fname: {
                 'value': s.data[fname],
                 'label': getattr(field, '_label', fname),
                 'help_text': getattr(field, '_help_text', None)
             } for fname, field in s.fields.items()
         })
     return Response(s.data)
Example #3
0
 def patch(self, request, *wargs, **kwargs):
     s = EventSettingsSerializer(instance=request.event.settings, data=request.data, partial=True,
                                 event=request.event, context={'request': request})
     s.is_valid(raise_exception=True)
     with transaction.atomic():
         s.save()
         self.request.event.log_action(
             'pretix.event.settings', user=self.request.user, auth=self.request.auth, data={
                 k: v for k, v in s.validated_data.items()
             }
         )
     if any(p in s.changed_data for p in SETTINGS_AFFECTING_CSS):
         regenerate_css.apply_async(args=(request.event.pk,))
     s = EventSettingsSerializer(
         instance=request.event.settings, event=request.event, context={
             'request': request
         })
     return Response(s.data)