Changes in the event model to take the event source

This commit is contained in:
Vivek
2025-12-20 04:05:07 +05:30
parent 2cd2c763f6
commit 8488df7c14
4 changed files with 49 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ class EventForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Set source to 'official' only and hide the field
self.fields['source'].initial = 'official'
self.fields['source'].widget = forms.HiddenInput()
# Check if all_year_event is True (from instance or initial data)
all_year_event = False
if self.instance and self.instance.pk:
@@ -54,6 +58,9 @@ class EventForm(forms.ModelForm):
cleaned_data = super().clean()
all_year_event = cleaned_data.get('all_year_event', False)
# Force source to be 'official' only
cleaned_data['source'] = 'official'
# If all_year_event is True, clear date/time fields
if all_year_event:
cleaned_data['start_date'] = None