Ejemplo n.º 1
0
 def _process(self):
     defaults = FormDefaults(self.folder, protected=self.folder.is_protected)
     form = AttachmentFolderForm(obj=defaults, linked_object=self.object)
     if form.validate_on_submit():
         form.populate_obj(self.folder, skip={'acl'})
         if self.folder.is_protected:
             self.folder.acl = form.acl.data
         logger.info('Folder {} edited by {}'.format(self.folder, session.user))
         signals.attachments.folder_updated.send(self.folder, user=session.user)
         flash(_("Folder \"{name}\" updated").format(name=self.folder.title), 'success')
         return jsonify_data(attachment_list=_render_attachment_list(self.object))
     return jsonify_template('attachments/create_folder.html', form=form,
                             protection_message=_render_protection_message(self.object))
Ejemplo n.º 2
0
 def _process(self):
     form = AttachmentFolderForm(obj=FormDefaults(is_always_visible=True), linked_object=self.object)
     if form.validate_on_submit():
         folder = AttachmentFolder(object=self.object)
         form.populate_obj(folder, skip={'acl'})
         if folder.is_self_protected:
             folder.acl = form.acl.data
         db.session.add(folder)
         logger.info('Folder %s created by %s', folder, session.user)
         signals.attachments.folder_created.send(folder, user=session.user)
         flash(_("Folder \"{name}\" created").format(name=folder.title), 'success')
         return jsonify_data(attachment_list=_render_attachment_list(self.object))
     return jsonify_template('attachments/create_folder.html', form=form,
                             protection_message=_render_protection_message(self.object))
Ejemplo n.º 3
0
 def _process(self):
     defaults = FormDefaults(self.folder, protected=self.folder.is_self_protected)
     form = AttachmentFolderForm(obj=defaults, linked_object=self.object)
     if form.validate_on_submit():
         form.populate_obj(self.folder, skip={'acl'})
         if self.folder.is_self_protected:
             # can't use `=` because of https://bitbucket.org/zzzeek/sqlalchemy/issues/3583
             self.folder.acl |= form.acl.data
             self.folder.acl &= form.acl.data
         logger.info('Folder %s edited by %s', self.folder, session.user)
         signals.attachments.folder_updated.send(self.folder, user=session.user)
         flash(_("Folder \"{name}\" updated").format(name=self.folder.title), 'success')
         return jsonify_data(attachment_list=_render_attachment_list(self.object))
     return jsonify_template('attachments/create_folder.html', form=form,
                             protection_message=_render_protection_message(self.object))