예제 #1
0
파일: main.py 프로젝트: sglickman/WBOR
  def get(self):
    labels = Permission.PERMISSIONS
    try:
      seth = Dj.get_by_email("*****@*****.**")
    except NoSuchEntry:
      seth = Dj.new(fullname='Seth Glickman',
                    email='*****@*****.**', username='******',
                    password='******')
      seth.put()
      hchaps = Dj.new(fullname='Harrison Chapman',
                      email="*****@*****.**", username="******",
                      password="******")

      program = Program.new(
        title='Seth\'s Show', slug='seth',
        desc='This is the show where Seth plays his favorite music.',
        dj_list=[seth.key],
        page_html='a <b>BOLD</b> show!')
      program.put()
    for l in labels:
      try:
        permission = Permission.get_by_title(l)
      except NoSuchEntry:
        permission = Permission.new(l, [])
        permission.put()
      finally:
        if seth.key not in permission.dj_list:
          permission.add_dj(seth.key)
          permission.put()
    if not BlogPost.get_last(num=3):
      post1 = BlogPost.new(
        title="Blog's first post!",
        text="This is really just filler text on the first post.",
        slug="first-post", post_date=datetime.datetime.now())
      post1.put()
      time.sleep(2)
      post2 = BlogPost.new(
        title="Blog's second post!",
        text="More filler text, alas.",
        slug="second-post", post_date=datetime.datetime.now())
      post2.put()
      contactspage = BlogPost.new(
        title="Contacts Page",
        text="This is a dummy stub for the contacts page. Lorem ipsum whatnot",
        slug="contacts-page", post_date=datetime.datetime.now())
      contactspage.put()
    artists = [
      "Bear In Heaven",
      "Beck",
      "Arcade Fire",
      "Andrew Bird",
      "The Antlers",
      "Arcade Fire",
      "The Beach Boys",
      "Brian Wilson",
      "The Beatles",
      "Beethoven",
      "Beirut",
      "Belle & Sebastian",
      "Benji Hughes",
      "Club 8",
      "Crayon Fields",
      ]
    for a in artists:
      if not (ArtistName._RAW.query()
              .filter(ArtistName._RAW.artist_name == a)
              .fetch(1, keys_only=True)):
        ar = ArtistName.new(artist_name=a)
        ar.put()
    self.session.add_flash("Permissions set up, ArtistNames set up, "
                           "Blog posts set up, DJ Seth entered.")
    self.redirect('/')
예제 #2
0
파일: dj.py 프로젝트: hchapman/WBOR
  def post(self):
    if self.request.get("submit") != "Add DJ":
      self.session.add_flash("There was an error, please try again.")
      self.redirect("/dj/djs/")
    else:
      fullname = self.request.get("fullname")
      email = self.request.get("email")
      username = self.request.get("username")
      password = self.request.get("password")

      if not email:
        self.session.add_flash("Please enter a valid email address.")
        self.redirect("/dj/djs")
        return
      if not username:
        self.session.add_flash("Please enter a valid username.")
        self.redirect("/dj/djs")
        return
      if not fullname:
        self.session.add_flash("Please enter a valid full name.")
        self.redirect("/dj/djs")
        return
      if not password:
        self.session.add_flash("Please enter a valid password.")
        self.redirect("/dj/djs")
        return
      if not password == self.request.get("confirm"):
        self.session.add_flash("Passwords do not match.")
        self.redirect("/dj/djs")
        return

      try:
        dj = Dj.get_by_email(email)
      except NoSuchEmail:
        dj = None

      if dj is not None:
        self.session.add_flash(
          "A DJ with email address %s already exists: %s, username %s" %
          (dj.email, dj.fullname, dj.username))
        self.redirect("/dj/djs")
        return

      try:
        dj = Dj.get_by_username(username)
      except NoSuchUsername:
        dj = None

      if dj is not None:
        self.session.add_flash(
          "A DJ with username %s already exists: %s, email address %s" %
          (dj.username, dj.fullname, dj.email))
        self.redirect("/dj/djs")
        return

      # If both username and email address are new, then we can add them
      dj = Dj.new(fullname=fullname,
                  email=email,
                  username=username,
                  password=password)
      dj.put()

      self.session.add_flash(dj.fullname + " successfully added as a DJ.")
      self.redirect("/dj/djs/")