Ejemplo n.º 1
0
  def post(self):
    if self.request.get("submit") != "Register":
      self.session.add_flash(
        "There was an error processing your request.  Please try again.",
        level="error")
      self.redirect(")/signup?token=%s"%token)
      return

    elif self.request.get("submit") == "Register":
      token_str = self.request.get("token")
      fullname = self.request.get("fullname")
      email = self.request.get("email")
      username = self.request.get("username")
      password = self.request.get("password")

      # Assert that the DJ Registration code is valid and available
      token = DjRegistrationToken.get(token_str)
      if not token:
        self.session.add_flash(
          "The secret registration token you have entered is either "
          "invalid, or has already been used up. Double check that "
          "it is correct. If it is not, <a>contact Ruben</a>.",
          level="error")
        self.redirect("/signup?token=%s"%token_str)
        return

      required_fields = [fullname, email, username, password]
      if "" in [field.strip() for field in required_fields]:
        self.session.add_flash("None of the fields may be empty")
        self.redirect("/signup?token=%s"%token_str)
        return

      if password is not None and password != self.request.get("confirm"):
        self.session.add_flash("Passwords do not match.")
        self.redirect("/signup?token=%s"%token_str)
        return

      dj = Dj(fullname=fullname,
              email=email,
              username=username,
              password=password)

      # Putting the DJ with the token will transactionally update the token
      dj.put(token=token)

      self.session.add_flash("%s, you have successfully registered as a DJ."
                             "You may now log in" % dj.fullname,
                             level="success")

    self.redirect("/")
Ejemplo n.º 2
0
Archivo: dj.py Proyecto: hchapman/WBOR
  def post(self, dj_key):
    dj = Dj.get(dj_key)
    if (dj is None) or (self.request.get("submit") != "Edit DJ" and
                        self.request.get("submit") != "Delete DJ"):
      self.session.add_flash(
          "There was an error processing your request.  Please try again.")

    elif self.request.get("submit") == "Edit DJ":
      fullname = self.request.get("fullname")
      email = self.request.get("email")
      username = self.request.get("username")
      password = self.request.get("password")

      if password is not None:
        if not password == self.request.get("confirm"):
          self.session.add_flash("New passwords do not match.")
          self.redirect("/dj/djs")
          return

      # Edit the dj
      dj = Dj.put(fullname=fullname,
                  email=email,
                  username=username,
                  password=password,)

      self.session.add_flash(fullname + " has been successfully edited.")
    elif self.request.get("submit") == "Delete DJ":
      dj.delete()
      self.session.add_flash(fullname + " has been successfully deleted.")
    self.redirect("/dj/djs/")