def review_new(): if (current_user.name == "") or (current_user.name == "None") or (current_user.name is None): flash("No username specified. To start a review username is required.", "error") return redirect(url_for('user_preferences')) logger.info("Requested URL /review [POST]") refresh_heads() revision = repo.revision(request.form['node']) rev_status = get_revision_status(repo, revision) if rev_status != "new": flash("Revision {0} is {1} and cannot be inspected. Refresh list of revisions.".format(revision.node, rev_status), "error") logger.info("Revision {0} is {1} and cannot be inspected.".format(revision.node, rev_status)) return redirect(url_for('changes_new')) #TODO: Multiple bookmarks review = Review(owner=current_user.name, owner_email=current_user.email, title=revision.title, bookmark=el(revision.bookmarks), status="ACTIVE") targets = repo.hg_targets(revision.rev, app.config['PRODUCT_BRANCHES']) review.add_targets(targets) #TODO: Multiple bookmarks changeset = Changeset(revision.name, revision.email, revision.title, revision.node, el(revision.bookmarks), "ACTIVE") review.changesets.append(changeset) db.session.add(review) Head.query.filter(Head.node == revision.node).delete() db.session.commit() return redirect(url_for('changeset_info', cs_id=changeset.id))
def review_rework(review_id): logger.info("Requested URL /review/%d [POST]", review_id) review = Review.query.filter(Review.id == review_id).first() if review is None: flash("Review {0} doesn't exist".format(review_id), "error") logger.error("Review %d doesn't exist", review_id) return redirect(url_for("index")) refresh_heads() revision = repo.revision(request.form["node"]) rev_status = get_revision_status(repo, revision) if rev_status != "rework": flash("Revision {0} is {1} and cannot be inspected. Refresh list of revisions.".format(revision.node, rev_status), "error") logger.info("Revision {0} is {1} and cannot be inspected.".format(revision.node, rev_status)) return redirect(url_for('review_info', review_id=review.id)) #TODO: Multiple bookmarks changeset = Changeset(revision.name, revision.email, revision.title, revision.node, el(revision.bookmarks), "ACTIVE") review.status = "ACTIVE" changeset.review_id = review.id db.session.add(changeset) Head.query.filter(Head.node == revision.node).delete() Head.query.filter(Head.review_id == review.id).update({'review_id': None}) db.session.commit() flash("Changeset '{title}' (SHA1: {sha1}) has been marked as rework".format(title=changeset.title, sha1=changeset.sha1), "notice") return redirect(url_for('changeset_info', cs_id=changeset.id))
def revision_abandon(node): logger.info("Requested URL /revision/%s/abandon [POST]", node) refresh_heads() revision = repo.revision(node) rev_status = get_revision_status(repo, revision) if rev_status != "new" and rev_status != "rework": flash("Revision {0} is {1} and cannot be abandoned. Refresh list of revisions.".format(revision.node, rev_status), "error") logger.info("Revision {0} is {1} and cannot be abandoned".format(revision.node, rev_status)) if is_safe_url(request.referrer): return redirect(request.referrer) return redirect(url_for('index')) #TODO: Multiple bookmarks changeset = Changeset(revision.name, revision.email, revision.title, revision.node, el(revision.bookmarks), "ABANDONED") db.session.add(changeset) Head.query.filter(Head.node == revision.node).delete() db.session.commit() repo.hg_close_branch(revision.node) if is_safe_url(request.referrer): return redirect(request.referrer) return redirect(url_for("index"))