Files
pretix_original/src/pretix/base/models/notifications.py
Raphael Michel af23d6e4bf Upgrade to Django 3.0 and other dependencies (#1568)
* Upgrade Django to 3.0 and other dependencies to recent versions

* Fix otp version contsraint

* Remove six dependency

* Resolve some warnings

* Fix failing tests

* Update django-countries

* Resolve all RemovedInDjango31Warnings in test suite

* Run isort

* Fix import

* Update PostgreSQL version on travis
2020-03-23 15:02:20 +01:00

37 lines
1.4 KiB
Python

from django.db import models
from django.utils.translation import gettext_lazy as _
class NotificationSetting(models.Model):
"""
Stores that a user wants to get notifications of a certain type via a certain
method for a certain event. If event is None, the notification shall be sent
for all events the user has access to.
:param user: The user to nofify.
:type user: User
:param action_type: The type of action to notify for.
:type action_type: str
:param event: The event to notify for.
:type event: Event
:param method: The method to notify with.
:type method: str
:param enabled: Indicates whether the specified notification is enabled. If no
event is set, this must always be true. If no event is set, setting
this to false is equivalent to deleting the object.
:type enabled: bool
"""
CHANNELS = (
('mail', _('E-mail')),
)
user = models.ForeignKey('User', on_delete=models.CASCADE,
related_name='notification_settings')
action_type = models.CharField(max_length=255)
event = models.ForeignKey('Event', null=True, blank=True, on_delete=models.CASCADE,
related_name='notification_settings')
method = models.CharField(max_length=255, choices=CHANNELS)
enabled = models.BooleanField(default=True)
class Meta:
unique_together = ('user', 'action_type', 'event', 'method')