zenodo_accessrequests/views/settings.py
def accessrequest(request_id):
    """Accept/reject access request."""
    r = AccessRequest.get_by_receiver(request_id, current_user)
    if not r or r.status != RequestStatus.PENDING:
        abort(404)

    form = ApprovalForm(request.form)

    if form.validate_on_submit():
        if form.accept.data:
            r.accept(message=form.data['message'],
                     expires_at=form.expires_at.data)
            db.session.commit()
            flash(_("Request accepted."))
            return redirect(url_for(".index"))
        elif form.reject.data:
            r.reject(message=form.data['message'])
            db.session.commit()
            flash(_("Request rejected."))
            return redirect(url_for(".index"))

    pid, record = get_record(r.recid)
    return render_template(
        "zenodo_accessrequests/settings/request.html",
        accessrequest=r,
        record=record,
        form=form,
    )
def accessrequest(request_id):
    """Accept/reject access request."""
    r = AccessRequest.get_by_receiver(request_id, current_user)
    if not r or r.status != RequestStatus.PENDING:
        abort(404)

    form = ApprovalForm(request.form)

    if form.validate_on_submit():
        if form.accept.data:
            r.accept(message=form.data['message'],
                     expires_at=form.expires_at.data)
            db.session.commit()
            flash(_("Request accepted."))
            return redirect(url_for(".index"))
        elif form.reject.data:
            r.reject(message=form.data['message'])
            db.session.commit()
            flash(_("Request rejected."))
            return redirect(url_for(".index"))

    pid, record = get_record(r.recid)
    return render_template(
        "zenodo_accessrequests/settings/request.html",
        accessrequest=r,
        record=record,
        form=form,
    )
Accept/reject access request.