def post(self): if (self.request.get("submit") != "Add Program"): self.session.add_flash( "There was an error processing your request. Please try again.") else: slug = self.request.get("slug") program = Program.get(slug=slug) if program: self.session.add_flash(("Program \"%s\" already exists with slug %s."% (program.title, slug))) self.redirect("/dj/programs/") return # Set up the program entry, and then put it in the DB program = Program.new(title=self.request.get("title"), slug=self.request.get("slug"), desc=self.request.get("desc"), dj_list=self.request.get_all("djkey"), page_html=self.request.get("page_html"), current=bool(self.request.get("current"))) program.put() self.session.add_flash( "%s was successfully created associated a program. " "Click <a href='/dj/programs/%s'>here</a> " "to edit it (you probably want to do " "this as there are no DJs on it currently)."% (program.title, str(program.key))) self.redirect('/dj/programs/')
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('/')