Files
goodtimes/manage_notifications/forms.py

26 lines
833 B
Python
Raw Permalink Normal View History

2024-03-13 18:25:54 +05:30
from django import forms
2024-03-14 13:48:41 +05:30
from .models import NotificationCategoryChoices, PushNotification
2024-03-13 18:25:54 +05:30
class PushNotificationForm(forms.ModelForm):
class Meta:
model = PushNotification
fields = [
"title",
"notification_category",
2024-03-15 15:57:09 +05:30
# "banner_image",
2024-03-13 18:25:54 +05:30
"principal_type",
"message",
]
widgets = {
"message": forms.Textarea(attrs={"rows": 4}),
}
2024-03-14 13:48:41 +05:30
def __init__(self, *args, **kwargs):
super(PushNotificationForm, self).__init__(*args, **kwargs)
# Limit choices for notification_category to GENERAL and PROMOTIONS only
self.fields["notification_category"].choices = [
(NotificationCategoryChoices.GENERAL, "General"),
(NotificationCategoryChoices.PROMOTIONS, "Promotions"),
]