Esempio n. 1
0
def show_prefrosh(prefrosh_id):
  dinner_prefrosh = helpers.get_dinner_prefrosh_by_prefrosh_id(prefrosh_id)
  prefrosh, prev_id, next_id = helpers.get_prefrosh_and_adjacent(prefrosh_id, dinner_prefrosh)
  full_name = helpers.format_name(
    prefrosh['first_name'], prefrosh['last_name'], prefrosh['preferred_name'])

  return flask.render_template('prefrosh.html', full_name=full_name, prefrosh=prefrosh,
            prev_id=prev_id, next_id=next_id, vote_tuples=helpers.VOTE_TUPLES)
Esempio n. 2
0
def show_prefrosh(prefrosh_id):
  """Shows a particular prefrosh, their votes, and comments."""
  dinner_prefrosh = helpers.get_dinner_prefrosh_by_prefrosh_id(prefrosh_id)
  prefrosh, prev_id, next_id = helpers.get_prefrosh_and_adjacent(prefrosh_id, dinner_prefrosh)
  full_name = helpers.format_name(
    prefrosh['first_name'], prefrosh['last_name'], prefrosh['preferred_name'])

  return flask.render_template('prefrosh.html', full_name=full_name, prefrosh=prefrosh,
            prev_id=prev_id, next_id=next_id, vote_tuples=helpers.VOTE_TUPLES)
Esempio n. 3
0
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))
Esempio n. 4
0
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))