Remove RequiredAction model (#2078)

This commit is contained in:
Raphael Michel
2021-05-17 17:41:59 +02:00
committed by GitHub
parent 04dd2a6cf0
commit f19a74990f
21 changed files with 23 additions and 310 deletions

View File

@@ -0,0 +1,16 @@
# Generated by Django 3.2.2 on 2021-05-13 18:20
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0187_normalize_salutation'),
]
operations = [
migrations.DeleteModel(
name='RequiredAction',
),
]

View File

@@ -27,7 +27,7 @@ from .customers import Customer
from .devices import Device, Gate
from .event import (
Event, Event_SettingsStore, EventLock, EventMetaProperty, EventMetaValue,
RequiredAction, SubEvent, SubEventMetaValue, generate_invite_token,
SubEvent, SubEventMetaValue, generate_invite_token,
)
from .giftcards import GiftCard, GiftCardAcceptance, GiftCardTransaction
from .invoices import Invoice, InvoiceLine, invoice_filename

View File

@@ -1389,60 +1389,6 @@ class EventLock(models.Model):
token = models.UUIDField(default=uuid.uuid4)
class RequiredAction(models.Model):
"""
Represents an action that is to be done by an admin. The admin will be
displayed a list of actions to do.
:param datatime: The timestamp of the required action
:type datetime: datetime
:param user: The user that performed the action
:type user: User
:param done: If this action has been completed or dismissed
:type done: bool
:param action_type: The type of action that has to be performed. This is
used to look up the renderer used to describe the action in a human-
readable way. This should be some namespaced value using dotted
notation to avoid duplicates, e.g.
``"pretix.plugins.banktransfer.incoming_transfer"``.
:type action_type: str
:param data: Arbitrary data that can be used by the log action renderer
:type data: str
"""
datetime = models.DateTimeField(auto_now_add=True, db_index=True)
done = models.BooleanField(default=False)
user = models.ForeignKey('User', null=True, blank=True, on_delete=models.PROTECT)
event = models.ForeignKey('Event', null=True, blank=True, on_delete=models.CASCADE)
action_type = models.CharField(max_length=255)
data = models.TextField(default='{}')
class Meta:
ordering = ('datetime',)
def display(self, request):
from ..signals import requiredaction_display
for receiver, response in requiredaction_display.send(self.event, action=self, request=request):
if response:
return response
return self.action_type
def save(self, *args, **kwargs):
created = not self.pk
super().save(*args, **kwargs)
if created:
from ..services.notifications import notify
from .log import LogEntry
logentry = LogEntry.objects.create(
content_object=self,
action_type='pretix.event.action_required',
event=self.event,
visible=False
)
notify.apply_async(args=(logentry.pk,))
class EventMetaProperty(LoggedModel):
"""
An organizer account can have EventMetaProperty objects attached to define meta information fields

View File

@@ -150,31 +150,6 @@ def get_all_notification_types(event=None):
return types
class ActionRequiredNotificationType(NotificationType):
required_permission = "can_change_orders"
action_type = "pretix.event.action_required"
verbose_name = _("Administrative action required")
def build_notification(self, logentry: LogEntry):
control_url = build_absolute_uri(
'control:event.requiredactions',
kwargs={
'organizer': logentry.event.organizer.slug,
'event': logentry.event.slug,
}
)
n = Notification(
event=logentry.event,
title=_('Administrative action required'),
detail=_('Something happened in your event that our system cannot handle automatically, e.g. an external '
'refund. You need to resolve it manually or choose to ignore it, depending on the issue at hand.'),
url=control_url
)
n.add_action(_('View all unresolved problems'), control_url)
return n
class ParametrizedOrderNotificationType(NotificationType):
required_permission = "can_view_orders"
@@ -324,7 +299,4 @@ def register_default_notification_types(sender, **kwargs):
_('Refund requested'),
_('You have been requested to issue a refund for {order.code}.')
),
ActionRequiredNotificationType(
sender,
)
)

View File

@@ -502,16 +502,7 @@ As with all event-plugin signals, the ``sender`` keyword argument will contain t
requiredaction_display = EventPluginSignal()
"""
Arguments: ``action``, ``request``
To display an instance of the ``RequiredAction`` model to a human user,
``pretix.base.signals.requiredaction_display`` will be sent out with a ``action`` argument.
You will also get the current ``request`` in a different argument.
The first received response that is not ``None`` will be used to display the log entry
to the user. The receivers are expected to return HTML code.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
**DEPRECATED**, will no longer be called.
"""
event_copy_data = EventPluginSignal()