class EditAttachmentFileForm(EditAttachmentFormBase): file = EditableFileField( _('File'), add_remove_links=False, get_metadata=_get_file_data, description=_( 'Already uploaded file. Replace it by adding a new file.'))
class AbstractForm(IndicoForm): title = StringField(_("Title"), [DataRequired()]) description = IndicoMarkdownField(_('Content'), editor=True, mathjax=True) submitted_contrib_type = QuerySelectField(_("Contribution type"), get_label='name', allow_blank=True, blank_text=_("No type selected")) person_links = AbstractPersonLinkListField( _("Authors"), [DataRequired()], default_author_type=AuthorType.primary) submission_comment = TextAreaField(_("Comments")) attachments = EditableFileField(_('Attachments'), multiple_files=True, lightweight=True) 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 _get_description_validators(self, description_settings): validators = [] if description_settings['is_required']: validators.append(DataRequired()) if description_settings['max_length']: validators.append( SoftLength(max=description_settings['max_length'])) if description_settings['max_words']: validators.append(WordCount(max=description_settings['max_words'])) return validators
class CategoryIconForm(IndicoForm): icon = EditableFileField("Icon", accepted_file_types='image/jpeg,image/jpg,image/png,image/gif', add_remove_links=False, handle_flashes=True, get_metadata=partial(get_image_data, 'icon'), description=_("Small icon that will show up next to category names in overview pages. " "Will be automatically resized to 16x16 pixels. This may involve loss of " "image quality, so try to upload images as close as possible to those " "dimensions."))
class UserPictureForm(IndicoForm): picture = EditableFileField( _('Profile picture'), accepted_file_types='image/jpeg,image/jpg,image/png,image/gif', add_remove_links=False, handle_flashes=True, get_metadata=get_picture_data)
class LogoForm(IndicoForm): logo = EditableFileField( 'Logo', accepted_file_types='image/jpeg,image/jpg,image/png,image/gif', add_remove_links=False, handle_flashes=True, get_metadata=get_logo_data, description=_("Logo to be displayed next to the event's title"))
class CategoryLogoForm(IndicoForm): logo = EditableFileField( 'Logo', accepted_file_types='image/jpeg,image/jpg,image/png,image/gif', add_remove_links=False, handle_flashes=True, get_metadata=partial(get_image_data, 'logo'), description=_( 'Logo that will show up next to the category description. Will be ' 'automatically resized to at most 200x200 pixels.'))
class CSSForm(IndicoForm): css_file = EditableFileField(_("Custom CSS file"), accepted_file_types='.css', add_remove_links=False, get_metadata=get_css_file_data, handle_flashes=True) def __init__(self, *args, **kwargs): super(CSSForm, self).__init__(*args, **kwargs) self.css_file.description = _("If you want to fully customize your conference page you can create your own " "stylesheet and upload it. An example stylesheet can be downloaded " "<a href='{base_url}/standard.css' target='_blank'>here</a>." .format(base_url=config.CONFERENCE_CSS_TEMPLATES_BASE_URL))
class PaperTemplateForm(IndicoForm): name = StringField(_("Name"), [DataRequired()]) description = TextAreaField(_("Description")) template = EditableFileField(_("Template"), add_remove_links=False, added_only=True, get_metadata=_get_template_data) 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)
class VCRoomPreloadForm(IndicoForm): slides = EditableFileField( _('slides'), lightweight=True, get_metadata=get_slides_metadata, multiple_files=True, # max_file_size=2, accepted_file_types= '.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.rtf,.odt,.ods,.odp,.odg,.odc,.odi,.jpg,.jpeg,.png', add_remove_links=True, handle_flashes=True)