def _add_contrib_type_hidden_unless(cls): # In the bulk form we need to hide/disable the contrib type selector unless we want to # override the type specified in the abstract. However, multiple HiddenUnless validators # are not supported in the client-side JS so we only add it to this form - it removes # inactive fields on the server side so it still works (the JavaScript picks up the last # HiddenUnless validator) inject_validators(BulkAbstractJudgmentForm, 'accepted_contrib_type', [HiddenUnless('override_contrib_type')])
def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.abstract = kwargs.pop('abstract', None) management = kwargs.pop('management', False) description_settings = abstracts_settings.get(self.event, 'description_settings') description_validators = self._get_description_validators(description_settings) if description_validators: inject_validators(self, 'description', description_validators) if abstracts_settings.get(self.event, 'contrib_type_required'): inject_validators(self, 'submitted_contrib_type', [DataRequired()]) super(AbstractForm, self).__init__(*args, **kwargs) if management: self.submitted_contrib_type.query = (self.event.contribution_types .order_by(db.func.lower(ContributionType.name))) else: criteria = [~ContributionType.is_private] if self.abstract and self.abstract.submitted_contrib_type: criteria.append(ContributionType.id == self.abstract.submitted_contrib_type.id) self.submitted_contrib_type.query = (self.event.contribution_types .filter(db.or_(*criteria)) .order_by(db.func.lower(ContributionType.name))) if not self.submitted_contrib_type.query.count(): del self.submitted_contrib_type if not self.event.cfa.allow_attachments: del self.attachments if not description_settings['is_active']: del self.description self.person_links.require_speaker_author = abstracts_settings.get(self.event, 'speakers_required') self.person_links.allow_speakers = abstracts_settings.get(self.event, 'allow_speakers')
def __init__(self, *args, **kwargs): event = kwargs['event'] self.track_field_disabled = (kwargs.get('abstract') and kwargs['abstract'].edit_track_mode != EditTrackMode.both) if abstracts_settings.get(event, 'tracks_required') and not self.track_field_disabled: inject_validators(self, 'submitted_for_tracks', [DataRequired()]) super(MultiTrackMixin, self).__init__(*args, **kwargs) self.submitted_for_tracks.query = Track.query.with_parent(event).order_by(Track.position)
def __init__(self, *args, **kwargs): if config.LOCAL_IDENTITIES: for field in ('username', 'password', 'confirm_password'): inject_validators(self, field, [HiddenUnless('create_identity')], early=True) super(AdminAccountRegistrationForm, self).__init__(*args, **kwargs) del self.comment if not config.LOCAL_IDENTITIES: del self.username del self.password del self.confirm_password del self.create_identity
def __init__(self, *args, **kwargs): event = kwargs['event'] self.track_field_disabled = ( kwargs.get('abstract') and kwargs['abstract'].edit_track_mode != EditTrackMode.both) if abstracts_settings.get( event, 'tracks_required') and not self.track_field_disabled: inject_validators(self, 'submitted_for_tracks', [DataRequired()]) super().__init__(*args, **kwargs) self.submitted_for_tracks.query = Track.query.with_parent( event).order_by(Track.position)
def __init__(self, *args, **kwargs): event = kwargs['event'] self.track_field_disabled = ( kwargs.get('abstract') and kwargs['abstract'].edit_track_mode != EditTrackMode.both) if abstracts_settings.get( event, 'tracks_required') and not self.track_field_disabled: inject_validators(self, 'submitted_for_tracks', [DataRequired()]) super(SingleTrackMixin, self).__init__(*args, **kwargs) if not abstracts_settings.get(event, 'tracks_required'): self.submitted_for_tracks.blank_text = _('No track selected') self.submitted_for_tracks.query = Track.query.with_parent( event).order_by(Track.title)
def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.abstract = kwargs.pop('abstract', None) description_settings = abstracts_settings.get(self.event, 'description_settings') description_validators = self._get_description_validators(description_settings) if description_validators: inject_validators(self, 'description', description_validators) if abstracts_settings.get(self.event, 'contrib_type_required'): inject_validators(self, 'submitted_contrib_type', [DataRequired()]) super(AbstractForm, self).__init__(*args, **kwargs) self.submitted_contrib_type.query = self.event.contribution_types if not self.submitted_contrib_type.query.count(): del self.submitted_contrib_type if not self.event.cfa.allow_attachments: del self.attachments if not description_settings['is_active']: del self.description self.person_links.require_speaker_author = abstracts_settings.get(self.event, 'speakers_required') self.person_links.allow_speakers = abstracts_settings.get(self.event, 'allow_speakers')
def __init__(self, *args, **kwargs): defaults = kwargs['obj'] if defaults.host_user is None and defaults.host is not None: host = principal_from_identifier(defaults.host) defaults.host_choice = 'myself' if host == session.user else 'someone_else' defaults.host_user = None if host == session.user else host allow_webinars = current_plugin.settings.get('allow_webinars') if allow_webinars: for field_name in { 'mute_audio', 'mute_participant_video', 'waiting_room' }: inject_validators(self, field_name, [HiddenUnless('meeting_type', 'regular')]) super().__init__(*args, **kwargs) if not allow_webinars: del self.meeting_type
def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.abstract = kwargs.pop('abstract', None) is_invited = kwargs.pop('invited', False) management = kwargs.pop('management', False) description_settings = abstracts_settings.get(self.event, 'description_settings') description_validators = self._get_description_validators(description_settings, invited=is_invited) if description_validators: inject_validators(self, 'description', description_validators) if not is_invited: inject_validators(self, 'person_links', [DataRequired()]) if abstracts_settings.get(self.event, 'contrib_type_required'): inject_validators(self, 'submitted_contrib_type', [DataRequired()]) super().__init__(*args, **kwargs) if management: self.submitted_contrib_type.query = (self.event.contribution_types .order_by(db.func.lower(ContributionType.name))) else: criteria = [~ContributionType.is_private] if self.abstract and self.abstract.submitted_contrib_type: criteria.append(ContributionType.id == self.abstract.submitted_contrib_type.id) self.submitted_contrib_type.query = (self.event.contribution_types .filter(db.or_(*criteria)) .order_by(db.func.lower(ContributionType.name))) if not self.submitted_contrib_type.query.count(): del self.submitted_contrib_type if not self.event.cfa.allow_attachments: del self.attachments if not description_settings['is_active']: del self.description if not is_invited: self.person_links.allow_speakers = abstracts_settings.get(self.event, 'allow_speakers') self.person_links.require_speaker = abstracts_settings.get(self.event, 'speakers_required') else: self.person_links.require_primary_author = False
def __init__(self, *args, **kwargs): self.event = kwargs.pop('event') self.abstract = kwargs.pop('abstract', None) description_settings = abstracts_settings.get(self.event, 'description_settings') description_validators = self._get_description_validators( description_settings) if description_validators: inject_validators(self, 'description', description_validators) if abstracts_settings.get(self.event, 'contrib_type_required'): inject_validators(self, 'submitted_contrib_type', [DataRequired()]) super(AbstractForm, self).__init__(*args, **kwargs) self.submitted_contrib_type.query = self.event.contribution_types if not self.submitted_contrib_type.query.count(): del self.submitted_contrib_type if not self.event.cfa.allow_attachments: del self.attachments if not description_settings['is_active']: del self.description self.person_links.require_speaker_author = abstracts_settings.get( self.event, 'speakers_required') self.person_links.allow_speakers = abstracts_settings.get( self.event, 'allow_speakers')
def _add_fields_hidden_unless(cls): for field_name in ('birth_date', 'nationality', 'birth_place'): inject_validators(RegistrationFormPersonalDataForm, field_name, [UsedIf(lambda form, field: form.request_cern_access.data)], early=True)
def __init__(self, *args, **kwargs): template = kwargs.pop('template', None) if template is None: inject_validators(self, 'template', [DataRequired()]) super(PaperTemplateForm, self).__init__(*args, **kwargs)