def move(): old_bucket_name = flask.request.args.get("old_bucket_name") new_bucket_name = flask.request.args.get("new_bucket_name") if old_bucket_name not in helpers.BUCKETS or new_bucket_name not in helpers.BUCKETS: flask.flash("Bad value for one of the buckets.") return flask.redirect(flask.url_for('rotation.show_portal')) elif old_bucket_name == new_bucket_name: flask.flash("Buckets must be distinct.") return flask.redirect(flask.url_for('rotation.show_portal')) else: old_bucket_prefrosh = helpers.get_prefrosh_by_bucket(old_bucket_name) new_bucket_prefrosh = helpers.get_prefrosh_by_bucket(new_bucket_name) return flask.render_template('move.html', old_bucket=old_bucket_prefrosh, new_bucket=new_bucket_prefrosh, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name, vote_tuples=helpers.VOTE_TUPLES)
def move(): """The move up / move down interface.""" old_bucket_name = flask.request.args.get("old_bucket_name") new_bucket_name = flask.request.args.get("new_bucket_name") if old_bucket_name not in helpers.BUCKETS or new_bucket_name not in helpers.BUCKETS: flask.flash("Bad value for one of the buckets.") return flask.redirect(flask.url_for('rotation.show_portal')) elif old_bucket_name == new_bucket_name: flask.flash("Buckets must be distinct.") return flask.redirect(flask.url_for('rotation.show_portal')) else: old_bucket_prefrosh = helpers.get_prefrosh_by_bucket(old_bucket_name) new_bucket_prefrosh = helpers.get_prefrosh_by_bucket(new_bucket_name) return flask.render_template('move.html', old_bucket=old_bucket_prefrosh, new_bucket=new_bucket_prefrosh, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name, vote_tuples=helpers.VOTE_TUPLES)
def change_bucket(prefrosh_id): new_bucket_name = flask.request.form.get("newBucket") old_bucket_name = flask.request.form.get("oldBucket") if old_bucket_name not in helpers.BUCKETS or new_bucket_name not in helpers.BUCKETS: flask.flash("Bad value for one of the buckets.") elif old_bucket_name == new_bucket_name: flask.flash("Buckets must be distinct.") old_bucket_prefrosh = helpers.get_prefrosh_by_bucket(old_bucket_name) prefrosh, prev_id, next_id = helpers.get_prefrosh_and_adjacent(prefrosh_id, old_bucket_prefrosh) helpers.change_bucket(prefrosh_id, new_bucket_name) if prev_id: return flask.redirect(flask.url_for("rotation.move", _anchor=prev_id, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name)) else: return flask.redirect(flask.url_for("rotation.move", _anchor=next_id, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name))
def change_bucket(prefrosh_id): """Submission endpoint for moving prefrosh between buckets.""" new_bucket_name = flask.request.form.get("newBucket") old_bucket_name = flask.request.form.get("oldBucket") if old_bucket_name not in helpers.BUCKETS or new_bucket_name not in helpers.BUCKETS: flask.flash("Bad value for one of the buckets.") elif old_bucket_name == new_bucket_name: flask.flash("Buckets must be distinct.") old_bucket_prefrosh = helpers.get_prefrosh_by_bucket(old_bucket_name) prefrosh, prev_id, next_id = helpers.get_prefrosh_and_adjacent(prefrosh_id, old_bucket_prefrosh) helpers.change_bucket(prefrosh_id, new_bucket_name) if prev_id: return flask.redirect(flask.url_for("rotation.move", _anchor=prev_id, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name)) else: return flask.redirect(flask.url_for("rotation.move", _anchor=next_id, old_bucket_name=old_bucket_name, new_bucket_name=new_bucket_name))