class UserDashboardAnnouncementForm(AsssignPortalMixin, forms.ModelForm): class Meta(object): model = UserDashboardAnnouncement fields = [ 'is_active', 'valid_from', 'valid_till', 'title', 'category', 'type', 'text', 'raw_html', 'image', 'url', ] valid_from = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='00:00')) valid_till = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='23:59')) def __init__(self, *args, **kwargs): super(UserDashboardAnnouncementForm, self).__init__(*args, **kwargs) self.fields[ 'text'].initial = "# Enter your\n# Big Headline here\n\nDear Community,\n\nExample text.\n\n## Secondary Headline\n\nMore text" self.fields['raw_html'].initial = """
class ConferenceParticipationManagement(forms.ModelForm): if hasattr(settings, 'COSINNUS_CONFERENCE_PARTICIPATION_OPTIONS'): application_options = forms.MultipleChoiceField( choices=settings.COSINNUS_CONFERENCE_PARTICIPATION_OPTIONS, required=False) application_start = forms.SplitDateTimeField( required=False, widget=SplitHiddenDateWidget(default_time='00:00')) application_end = forms.SplitDateTimeField( required=False, widget=SplitHiddenDateWidget(default_time='23:59')) application_conditions_upload = forms.FileField( required=False, widget=ConferenceFileUploadWidget, validators=[validate_file_infection]) class Meta: model = ParticipationManagement exclude = ['conference'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if not hasattr(settings, 'COSINNUS_CONFERENCE_PARTICIPATION_OPTIONS'): del self.fields['application_options'] for field in list(self.fields.values()): if type(field.widget) is SelectMultiple: field.widget = Select2MultipleWidget(choices=field.choices) def clean_application_options(self): if self.cleaned_data['application_options'] and len( self.cleaned_data) > 0: return [ int(option) for option in self.cleaned_data['application_options'] ] def clean(self): cleaned_data = super().clean() application_start = cleaned_data.get('application_start') application_end = cleaned_data.get('application_end') if application_end and application_end: if application_end <= application_start: msg = _('End date must be before start date') self.add_error('application_end', msg) elif application_end and not application_start: msg = _('Please also provide a start date') self.add_error('application_start', msg) elif application_start and not application_end: msg = _('Please also provide a end date') self.add_error('application_end', msg) return cleaned_data
class _ConferenceEventWorkshopForm(_ConferenceEventBaseForm): from_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='00:00')) to_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='23:59')) class Meta(object): model = ConferenceEvent fields = ('title', 'is_break', 'note', 'from_date', 'to_date', 'presenters', 'presentation_file')
class SuggestionForm(forms.ModelForm): class Meta(object): model = Suggestion fields = ( 'from_date', 'to_date', ) from_date = forms.SplitDateTimeField( required=False, widget=SplitHiddenDateWidget(default_time='00:00')) to_date = forms.SplitDateTimeField( required=False, widget=SplitHiddenDateWidget(default_time='00:00'))
class _ConferenceEventStageForm(_ConferenceEventBaseForm): url = forms.URLField(widget=forms.TextInput, required=False) from_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='00:00')) to_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='23:59')) class Meta(object): model = ConferenceEvent fields = ('title', 'is_break', 'note', 'from_date', 'to_date', 'presenters', 'url', 'raw_html')
class _CosinnusConferenceForm(CleanAppSettingsMixin, AsssignPortalMixin, CosinnusBaseGroupForm): """ Specific form implementation for CosinnusConference objects (used through `registration.group_models`) """ from_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget(default_time='00:00')) to_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget(default_time='23:59')) membership_mode = forms.ChoiceField( initial=(CosinnusConference.MEMBERSHIP_MODE_APPLICATION if settings.COSINNUS_CONFERENCES_USE_APPLICATIONS_CHOICE_DEFAULT else CosinnusConference.MEMBERSHIP_MODE_REQUEST), choices=CosinnusConference.MEMBERSHIP_MODE_CHOICES, required=False ) extra_forms_setting = 'COSINNUS_CONFERENCE_ADDITIONAL_FORMS' class Meta(object): fields = CosinnusBaseGroupForm.Meta.fields + [ 'conference_theme_color', 'from_date', 'to_date', ] model = CosinnusConference
class _EventForm(GroupKwargModelFormMixin, UserKwargModelFormMixin, FormAttachableMixin, BaseTaggableObjectForm): url = forms.URLField(widget=forms.TextInput, required=False) from_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='00:00')) to_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='23:59')) class Meta(object): model = Event fields = ('title', 'suggestion', 'from_date', 'to_date', 'note', 'street', 'zipcode', 'city', 'public', 'image', 'url') def __init__(self, *args, **kwargs): super(_EventForm, self).__init__(*args, **kwargs) instance = kwargs.get('instance') if instance: self.fields['suggestion'].queryset = Suggestion.objects.filter( event=instance) else: del self.fields['suggestion']
class SimpleStatisticsForm(forms.Form): from_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='00:00')) to_date = forms.SplitDateTimeField(widget=SplitHiddenDateWidget( default_time='23:59'))