Files
goodtimes/manage_notifications/forms.py
rizwanisready cb66539513 15-03-2024
2024-03-15 15:57:09 +05:30

26 lines
833 B
Python

from django import forms
from .models import NotificationCategoryChoices, PushNotification
class PushNotificationForm(forms.ModelForm):
class Meta:
model = PushNotification
fields = [
"title",
"notification_category",
# "banner_image",
"principal_type",
"message",
]
widgets = {
"message": forms.Textarea(attrs={"rows": 4}),
}
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"),
]