Exemple #1
0
 def _process(self):
     form = AddAttachmentLinkForm(linked_object=self.object)
     if form.validate_on_submit():
         add_attachment_link(form.data, self.object)
         flash(_("The link has been added"), 'success')
         return jsonify_data(attachment_list=_render_attachment_list(self.object))
     return jsonify_template('attachments/add_link.html', form=form,
                             protection_message=_render_protection_message(self.object),
                             folders_protection_info=_get_folders_protection_info(self.object))
Exemple #2
0
    def _process(self):
        form = AddAttachmentLinkForm(linked_object=self.object)
        if form.validate_on_submit():
            folder = form.folder.data or AttachmentFolder.get_or_create_default(linked_object=self.object)
            link = Attachment(user=session.user, type=AttachmentType.link)
            form.populate_obj(link, skip={'acl'})
            if link.is_protected:
                link.acl = form.acl.data
            link.folder = folder

            db.session.flush()
            logger.info('Attachment {} added by {}'.format(link, session.user))
            signals.attachments.attachment_created.send(link, user=session.user)
            flash(_("The link has been added"), 'success')
            return jsonify_data(attachment_list=_render_attachment_list(self.object))
        return jsonify_template('attachments/add_link.html', form=form,
                                protection_message=_render_protection_message(self.object),
                                folders_protection_info=_get_folders_protection_info(self.object))
Exemple #3
0
    def _process(self):
        form = AddAttachmentLinkForm(linked_object=self.object)
        if form.validate_on_submit():
            folder = form.folder.data or AttachmentFolder.get_or_create_default(
                linked_object=self.object)
            link = Attachment(user=session.user, type=AttachmentType.link)
            form.populate_obj(link, skip={'acl'})
            if link.is_protected:
                link.acl = form.acl.data
            link.folder = folder

            db.session.flush()
            logger.info('Attachment {} added by {}'.format(link, session.user))
            signals.attachments.attachment_created.send(link,
                                                        user=session.user)
            flash(_("The link has been added"), 'success')
            return jsonify_data(
                attachment_list=_render_attachment_list(self.object))
        return jsonify_template(
            'attachments/add_link.html',
            form=form,
            protection_message=_render_protection_message(self.object),
            folders_protection_info=_get_folders_protection_info(self.object))