示例#1
0
def reply():
    sid, msg_candidate = request.form["sid"], request.form["msg"]
    try:
        msg = msg_candidate.decode()
    except (UnicodeDecodeError, UnicodeEncodeError):
        flash("You have entered text that we could not parse. Please try again.", "notification")
        return render_template("col.html", sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()))
    crypto_util.encrypt(crypto_util.getkey(sid), msg, output=store.path(sid, "reply-%s.gpg" % uuid.uuid4()))
    return render_template("reply.html", sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()))
示例#2
0
def flag():
    def create_flag(sid):
        """Flags a SID by creating an empty _FLAG file in their collection directory"""
        flag_file = store.path(sid, '_FLAG')
        open(flag_file, 'a').close()
        return flag_file
    sid = request.form['sid']
    create_flag(sid)
    return render_template('flag.html', sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()))
示例#3
0
def bulk_delete(sid, docs_selected):
    confirm_delete = bool(request.form.get('confirm_delete', False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc['name'])
            store.secure_unlink(fn)
    return render_template(
        'delete.html', sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()),
        docs_selected=docs_selected, confirm_delete=confirm_delete)
示例#4
0
def bulk_download(sid, docs_selected):
    filenames = [store.path(sid, doc['name']) for doc in docs_selected]
    zip = store.get_bulk_archive(filenames)
    return send_file(
        zip.name,
        mimetype="application/zip",
        attachment_filename=db.display_id(sid, db.sqlalchemy_handle()) +
        ".zip",
        as_attachment=True)
示例#5
0
def bulk_download(sid, docs_selected):
    filenames = [store.path(sid, doc["name"]) for doc in docs_selected]
    zip = store.get_bulk_archive(filenames)
    return send_file(
        zip.name,
        mimetype="application/zip",
        attachment_filename=db.display_id(sid, db.sqlalchemy_handle()) + ".zip",
        as_attachment=True,
    )
示例#6
0
def col(sid):
    docs, flagged = get_docs(sid)
    haskey = crypto_util.getkey(sid)
    return render_template("col.html",
                           sid=sid,
                           codename=db.display_id(sid, db.sqlalchemy_handle()),
                           docs=docs,
                           haskey=haskey,
                           flagged=flagged)
示例#7
0
def reply():
    sid, msg_candidate = request.form['sid'], request.form['msg']
    try:
        msg = msg_candidate.decode()
    except (UnicodeDecodeError, UnicodeEncodeError):
        flash(
            "You have entered text that we could not parse. Please try again.",
            "notification")
        return render_template('col.html',
                               sid=sid,
                               codename=db.display_id(sid,
                                                      db.sqlalchemy_handle()))
    crypto_util.encrypt(crypto_util.getkey(sid),
                        msg,
                        output=store.path(sid, 'reply-%s.gpg' % uuid.uuid4()))
    return render_template('reply.html',
                           sid=sid,
                           codename=db.display_id(sid, db.sqlalchemy_handle()))
示例#8
0
def col(sid):
    docs, flagged = get_docs(sid)
    haskey = crypto_util.getkey(sid)
    return render_template(
        "col.html",
        sid=sid,
        codename=db.display_id(sid, db.sqlalchemy_handle()),
        docs=docs,
        haskey=haskey,
        flagged=flagged,
    )
示例#9
0
def bulk_delete(sid, docs_selected):
    confirm_delete = bool(request.form.get('confirm_delete', False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc['name'])
            store.secure_unlink(fn)
    return render_template('delete.html',
                           sid=sid,
                           codename=db.display_id(sid, db.sqlalchemy_handle()),
                           docs_selected=docs_selected,
                           confirm_delete=confirm_delete)
示例#10
0
def flag():
    def create_flag(sid):
        """Flags a SID by creating an empty _FLAG file in their collection directory"""
        flag_file = store.path(sid, '_FLAG')
        open(flag_file, 'a').close()
        return flag_file

    sid = request.form['sid']
    create_flag(sid)
    return render_template('flag.html',
                           sid=sid,
                           codename=db.display_id(sid, db.sqlalchemy_handle()))
示例#11
0
def bulk_delete(sid, docs_selected):
    confirm_delete = bool(request.form.get("confirm_delete", False))
    if confirm_delete:
        for doc in docs_selected:
            fn = store.path(sid, doc["name"])
            crypto_util.secureunlink(fn)
    return render_template(
        "delete.html",
        sid=sid,
        codename=db.display_id(sid, db.sqlalchemy_handle()),
        docs_selected=docs_selected,
        confirm_delete=confirm_delete,
    )
示例#12
0
def index():
    dirs = os.listdir(config.STORE_DIR)
    cols = []
    db_session = db.sqlalchemy_handle()
    for d in dirs:
        display_id = db.display_id(d, db_session)
        cols.append(
            dict(
                name=d, sid=display_id, date=str(datetime.fromtimestamp(os.stat(store.path(d)).st_mtime)).split(".")[0]
            )
        )
    db_session.close()
    cols.sort(key=lambda x: x["date"], reverse=True)
    return render_template("index.html", cols=cols)
示例#13
0
def index():
    dirs = os.listdir(config.STORE_DIR)
    cols = []
    db_session = db.sqlalchemy_handle()
    for source_id in dirs:
        display_id = db.display_id(source_id, db_session)
        cols.append(
            dict(sid=source_id,
                 name=display_id,
                 date=str(
                     datetime.fromtimestamp(
                         os.stat(
                             store.path(source_id)).st_mtime)).split('.')[0]))
    db_session.close()
    cols.sort(key=lambda x: x['date'], reverse=True)
    return render_template('index.html', cols=cols)
示例#14
0
def reply():
    sid, msg = request.form['sid'], request.form['msg']
    crypto_util.encrypt(crypto_util.getkey(sid), request.form['msg'], output=
                        store.path(sid, 'reply-%s.gpg' % uuid.uuid4()))
    return render_template('reply.html', sid=sid, codename=db.display_id(sid, db.sqlalchemy_handle()))