def create_new_file_type(event, editable_type, **data):
    file_type = EditingFileType(event=event, type=editable_type)
    file_type.populate_from_dict(data, keys=FILE_TYPE_ATTRS)
    db.session.flush()
    logger.info('File type %r for %s created by %r', file_type,
                editable_type.name, session.user)
    return file_type
Example #2
0
 def _clone_filetypes(self, new_event):
     attrs = get_simple_column_attrs(EditingFileType)
     del new_event.editing_file_types[:]
     db.session.flush()
     for old_filetype in self.old_event.editing_file_types:
         filetype = EditingFileType()
         filetype.populate_from_attrs(old_filetype, attrs)
         new_event.editing_file_types.append(filetype)
         db.session.flush()
         self._filetype_map[old_filetype.id] = filetype.id
Example #3
0
 def enabled(cls, event, cloning):
     from indico.modules.events.editing.models.file_types import EditingFileType
     if not EditingFileType.query.with_parent(event).filter_by(publishable=True).has_rows():
         ft = EditingFileType(name='PDF', extensions=['pdf'], publishable=True, required=True)
         event.editing_file_types.append(ft)
         if not cloning:
             flash(_("A default publishable PDF file type has been created; if you want to use other file types in "
                     "your event's editing workflow, please configure them accordingly."))
Example #4
0
    def enabled(cls, event, cloning):
        from indico.modules.events.editing.models.file_types import EditingFileType
        from indico.modules.events.editing.models.editable import EditableType
        types_with_filetypes = {type_ for type_, in db.session.query(EditingFileType.type).with_parent(event)}
        types_without_filetypes = set(EditableType) - types_with_filetypes
        for type_ in types_without_filetypes:
            ft = EditingFileType(name='PDF', extensions=['pdf'], publishable=True, required=True, type=type_)
            event.editing_file_types.append(ft)

        if types_without_filetypes and not cloning:
            flash(_("A default publishable PDF file type has been created; if you want to use other file types in "
                    "your event's editing workflow, please configure them accordingly."))