示例#1
0
文件: dj.py 项目: hchapman/WBOR
 def post(self):
   errors = ""
   title = self.request.get("title")
   text = self.request.get("text")
   post_date = datetime.datetime.now();
   slug = self.request.get("slug")
   post = BlogPost.new(
     title=title,
     text=text,
     post_date=post_date,
     slug=slug)
   posts = BlogPost.get_last(num=2)
   if BlogPost.get_by_slug(slug, post_date=post_date):
     errors = ("Error: this post has a duplicate slug to another post from "
               "the same day.  This probably shouldn't happen often.")
   template_values = {
     'session': self.session,
     'flash': self.flashes,
     'errors': errors,
     'post': post,
     'posts': posts,
   }
   if errors:
     self.response.out.write(
         template.render(get_path("dj_createpost.html"), template_values))
   else:
     post.put()
     self.session.add_flash("Post \"%s\" successfully added." % title)
     self.redirect("/")
示例#2
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('/')