Exemple #1
0
def profile():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    email = form.email.data
    if email and not user_db.is_email_available(email, user_db.key):
      form.email.errors.append('This email is already taken.')

    if not form.errors:
      send_verification = not user_db.token or user_db.email != email
      form.populate_obj(user_db)
      if send_verification:
        user_db.verified = False
        task.verify_email_notification(user_db)
      user_db.put()
      return flask.redirect(flask.url_for('welcome'))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title=user_db.name,
      html_class='profile',
      form=form,
      user_db=user_db,
      has_json=True,
    )
Exemple #2
0
def profile_update():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    email = form.email.data
    if email and not user_db.is_email_available(email, user_db.key):
      form.email.errors.append('This email is already taken.')

    if not form.errors:
      send_verification = not user_db.token or user_db.email != email
      form.populate_obj(user_db)
      if send_verification:
        user_db.verified = False
        task.verify_email_notification(user_db)
      user_db.put()
      return flask.redirect(flask.url_for('profile'))

  return flask.render_template(
      'profile/profile_update.html',
      title=user_db.name,
      html_class='profile-update',
      form=form,
      user_db=user_db,
    )
Exemple #3
0
def profile():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    send_verification = not user_db.token or user_db.email != form.email.data
    form.populate_obj(user_db)
    if send_verification:
      user_db.verified = False
      task.verify_email_notification(user_db)
    user_db.put()
    return flask.redirect(flask.url_for(
        'set_locale', locale=user_db.locale, next=flask.url_for('welcome')
      ))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title=user_db.name,
      html_class='profile',
      form=form,
      user_db=user_db,
      has_json=True,
    )
Exemple #4
0
def profile_update():
    user_db = auth.current_user_db()
    form = ProfileUpdateForm(obj=user_db)

    if form.validate_on_submit():
        email = form.email.data
        if email and not user_db.is_email_available(email, user_db.key):
            form.email.errors.append('This email is already taken.')

        if not form.errors:
            send_verification = not user_db.token or user_db.email != email
            form.populate_obj(user_db)
            if send_verification:
                user_db.verified = False
                task.verify_email_notification(user_db)
            user_db.put()
            return flask.redirect(flask.url_for('profile'))

    return flask.render_template(
        'profile/profile_update.html',
        title=user_db.name,
        html_class='profile-update',
        form=form,
        user_db=user_db,
    )
Exemple #5
0
def profile_update():
    user_db = auth.current_user_db()
    form = ProfileUpdateForm(obj=user_db)

    currency_dbs, currency_cursor = model.Currency.get_dbs(limit=-1)
    form.currency_key.choices = [(c.key.urlsafe(), c.name)
                                 for c in currency_dbs]
    if flask.request.method == 'GET' and not form.errors:
        form.currency_key.data = user_db.currency_key.urlsafe(
        ) if user_db.currency_key else None

    if form.validate_on_submit():
        email = form.email.data
        if email and not user_db.is_email_available(email, user_db.key):
            form.email.errors.append(_('This email is already taken.'))

        if not form.errors:
            send_verification = not user_db.token or user_db.email != email
            form.currency_key.data = ndb.Key(
                urlsafe=form.currency_key.data
            ) if form.currency_key.data else None
            form.populate_obj(user_db)
            if send_verification:
                user_db.verified = False
                task.verify_email_notification(user_db)
            user_db.put()
            return flask.redirect(
                flask.url_for('set_locale',
                              locale=user_db.locale,
                              next=flask.url_for('profile')))

    return flask.render_template(
        'profile/profile_update.html',
        title=user_db.name,
        html_class='profile-update',
        form=form,
        user_db=user_db,
    )