Ejemplo n.º 1
0
    def bulk():
        action = request.form['action']

        doc_names_selected = request.form.getlist('doc_names_selected')
        selected_docs = [
            doc for doc in g.source.collection
            if doc.filename in doc_names_selected
        ]
        if selected_docs == []:
            if action == 'download':
                flash(gettext("No collections selected for download."),
                      "error")
            elif action in ('delete', 'confirm_delete'):
                flash(gettext("No collections selected for deletion."),
                      "error")
            return redirect(url_for('col.col', filesystem_id=g.filesystem_id))

        if action == 'download':
            source = get_source(g.filesystem_id)
            return download(source.journalist_filename, selected_docs)
        elif action == 'delete':
            return bulk_delete(g.filesystem_id, selected_docs)
        elif action == 'confirm_delete':
            return confirm_bulk_delete(g.filesystem_id, selected_docs)
        else:
            abort(400)
Ejemplo n.º 2
0
 def download_unread_filesystem_id(filesystem_id: str) -> werkzeug.Response:
     id = Source.query.filter(Source.filesystem_id == filesystem_id) \
                      .filter_by(deleted_at=None).one().id
     submissions = Submission.query.filter(Submission.source_id == id).all()
     unseen_submissions = [s for s in submissions if not s.seen]
     if unseen_submissions == []:
         flash(gettext("No unread submissions for this source."))
         return redirect(url_for('col.col', filesystem_id=filesystem_id))
     source = get_source(filesystem_id)
     return download(source.journalist_filename, unseen_submissions)
Ejemplo n.º 3
0
 def download_unread_filesystem_id(filesystem_id):
     id = Source.query.filter(Source.filesystem_id == filesystem_id) \
         .one().id
     submissions = Submission.query.filter(
         Submission.source_id == id,
         Submission.downloaded == false()).all()
     if submissions == []:
         flash(gettext("No unread submissions for this source."))
         return redirect(url_for('col.col', filesystem_id=filesystem_id))
     source = get_source(filesystem_id)
     return download(source.journalist_filename, submissions)
Ejemplo n.º 4
0
 def download_unread_filesystem_id(filesystem_id):
     id = Source.query.filter(Source.filesystem_id == filesystem_id) \
         .one().id
     submissions = Submission.query.filter(
         Submission.source_id == id,
         Submission.downloaded == false()).all()
     if submissions == []:
         flash(gettext("No unread submissions for this source."))
         return redirect(url_for('col.col', filesystem_id=filesystem_id))
     source = get_source(filesystem_id)
     return download(source.journalist_filename, submissions)
Ejemplo n.º 5
0
 def download_unread_filesystem_id(filesystem_id: str) -> werkzeug.Response:
     unseen_submissions = (Submission.query.join(Source).filter(
         Source.deleted_at.is_(None),
         Source.filesystem_id == filesystem_id).filter(
             ~Submission.seen_files.any(),
             ~Submission.seen_messages.any()).all())
     if len(unseen_submissions) == 0:
         flash(gettext("No unread submissions for this source."), "error")
         return redirect(url_for("col.col", filesystem_id=filesystem_id))
     source = get_source(filesystem_id)
     return download(source.journalist_filename, unseen_submissions)
Ejemplo n.º 6
0
    def bulk() -> Union[str, werkzeug.Response]:
        action = request.form["action"]
        error_redirect = url_for("col.col", filesystem_id=g.filesystem_id)
        doc_names_selected = request.form.getlist("doc_names_selected")
        selected_docs = [
            doc for doc in g.source.collection
            if doc.filename in doc_names_selected
        ]
        if selected_docs == []:
            if action == "download":
                flash(
                    Markup("<b>{}</b> {}".format(
                        # Translators: Error shown when a user has not selected items to act on.
                        escape(gettext("Nothing Selected")),
                        escape(
                            gettext(
                                "You must select one or more items for download"
                            )),
                    )),
                    "error",
                )
            elif action == "delete":
                flash(
                    Markup("<b>{}</b> {}".format(
                        # Translators: Error shown when a user has not selected items to act on.
                        escape(gettext("Nothing Selected")),
                        escape(
                            gettext(
                                "You must select one or more items for deletion"
                            )),
                    )),
                    "error",
                )
            else:
                abort(400)

            return redirect(error_redirect)

        if action == "download":
            source = get_source(g.filesystem_id)
            return download(source.journalist_filename,
                            selected_docs,
                            on_error_redirect=error_redirect)
        elif action == "delete":
            return bulk_delete(g.filesystem_id, selected_docs)
        else:
            abort(400)
Ejemplo n.º 7
0
    def bulk():
        action = request.form['action']

        doc_names_selected = request.form.getlist('doc_names_selected')
        selected_docs = [doc for doc in g.source.collection
                         if doc.filename in doc_names_selected]
        if selected_docs == []:
            if action == 'download':
                flash(gettext("No collections selected for download."),
                      "error")
            elif action in ('delete', 'confirm_delete'):
                flash(gettext("No collections selected for deletion."),
                      "error")
            return redirect(url_for('col.col', filesystem_id=g.filesystem_id))

        if action == 'download':
            source = get_source(g.filesystem_id)
            return download(source.journalist_filename, selected_docs)
        elif action == 'delete':
            return bulk_delete(g.filesystem_id, selected_docs)
        elif action == 'confirm_delete':
            return confirm_bulk_delete(g.filesystem_id, selected_docs)
        else:
            abort(400)