def get(self, event_key): event = models.Event.get(event_key) if not event: self.session.add_flash( "Unable to find the requested event. Please try again.") self.redirect("/dj/") return day = event.event_date.strftime("%m/%d/%Y") hour = event.event_date.strftime("%H") minute = event.event_date.strftime("%M") posts = BlogPost.get_last(num=2) template_values = { 'session': self.session, 'flash': self.flashes, 'editing': True, 'event': event, 'day': day, 'hour': hour, 'minute': minute, 'hours': [str(i).rjust(2, "0") for i in range(24)], 'minutes': [str(i).rjust(2, "0") for i in range(0, 60, 15)], 'posts': posts, } self.response.out.write( template.render(get_path("dj_create_event.html"), template_values))
def get(self): ## Album list disabled until it is further optimized. #album_list = [] album_list = Album.get_new(num=36) start = datetime.date.today() - datetime.timedelta(days=6) end = datetime.date.today() + datetime.timedelta(days=1) song_num = 10 album_num = 10 logging.debug("Calling get top") top_songs, top_albums = Play.get_top(start, end, song_num, album_num) posts = BlogPost.get_last(num=3) events = Event.get_upcoming(num=3) template_values = { 'news_selected': True, 'flash': self.flashes, 'session': self.session, 'album_list': album_list, 'top_songs': top_songs, 'top_albums': top_albums, 'posts': posts, 'events': events, } self.response.out.write(template.render(get_path("index.html"), template_values))
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("/")
def get(self): template_values = { 'token': self.request.get("token"), 'session': self.session, 'flash': self.flashes, 'posts': BlogPost.get_last(num=3), } self.response.out.write( template.render(get_path("signup.html"), template_values))
def get(self): posts = BlogPost.get_last(2) template_values = { 'session': self.session, 'flash': self.flashes, 'posts': posts, } self.response.out.write( template.render(get_path("dj_createpost.html"), template_values))
def get(self): program = cache.getProgram(self.program_key) template_values = { 'session': self.session, 'flash': self.flashes, 'program': program, 'posts': BlogPost.get_last(2), } self.response.out.write( template.render(get_path("dj_myshow.html"), template_values))
def get(self): dj = Dj.get(self.dj_key) template_values = { 'session': self.session, 'flash': self.flashes, 'dj': dj, 'posts': BlogPost.get_last(1), } self.response.out.write( template.render(get_path("dj_self.html"), template_values))
def get(self): dj_list = [] #Dj.getAll() # This is TERRIBLE PRACTICE template_values = { 'dj_list': dj_list, 'session': self.session, 'flash': self.flashes, 'posts': BlogPost.get_last(num=3), } self.response.out.write(template.render(get_path("dj_manage_djs.html"), template_values))
def get(self): posts = BlogPost.get_last(num=2) template_values = { 'session': self.session, 'flash': self.flashes, 'editing': False, 'hours': [str(i).rjust(2, "0") for i in range(24)], 'minutes': [str(i).rjust(2, "0") for i in range(0, 60, 15)], 'posts': posts, } self.response.out.write( template.render(get_path("dj_create_event.html"), template_values))
def get(self): permissions = Permission.get_all() template_values = { 'permissions': [{ 'key': p.key, 'title': p.title, 'dj_list': [Dj.get(d) for d in p.dj_list], } for p in permissions], 'session': self.session, 'flash': self.flashes, 'posts': BlogPost.get_last(num=2), } self.response.out.write( template.render(get_path("dj_permissions.html"), template_values))
def get(self): program_list = Program.get_by_dj(dj=self.dj_key) if len(program_list) <= 1: self.session.add_flash( "You don't have more than one radio program to choose between.") self.redirect("/dj/") return template_values = { 'program_list': program_list, 'session': self.session, 'flash': self.flashes, 'posts': BlogPost.get_last(num=1) } self.response.out.write(template.render(get_path("dj_selectprogram.html"), template_values))
def post(self, date_string, slug): errors = "" title = self.request.get("title") text = self.request.get("text") slug = self.request.get("slug") post_key = ndb.Key(urlsafe=self.request.get("post_key")) post = BlogPost.get(post_key) if not post: self.session.add_flash( "The post you're looking for does not exist. " "Something strange has occurred.") # this shouldn't happen unless people are fiddling around with # POST values by hand I think self.redirect("/") return if self.request.get("submit") == "Delete Post": post.delete() self.session.add_flash("Post deleted.") self.redirect("/") return duplicate = BlogPost.get_by_slug(slug, post_date=post.post_date) old_slug = post.slug post.slug = slug if duplicate: if duplicate.key != post_key: errors = ("This post has a duplicate slug to another post " "from the same day. Please rename the slug.") post.slug = old_slug post.title = title post.text = text posts = BlogPost.get_last(num=2) template_values = { 'session': self.session, 'flash': self.flashes, 'errors': errors, 'post': post, 'editing': True, 'posts': posts, } if errors: self.response.out.write( template.render(get_path("dj_createpost.html"), template_values)) else: post.put() self.session.add_flash("Successfully altered post %s" % post.title) self.redirect("/")
def get(self, date_string, slug): post_date = datetime.datetime.strptime(date_string, "%Y-%m-%d") post = BlogPost.get_by_slug(slug, post_date=post_date) if not post: self.session.add_flash( "The post you're looking for does not exist. " "But you can look at actual posts below :)") self.redirect("/") return posts = BlogPost.get_last(num=2) template_values = { 'session': self.session, 'flash': self.flashes, 'post': post, 'editing': True, 'posts': posts, } self.response.out.write( template.render(get_path("dj_createpost.html"), template_values))
def get(self, dj_key): dj = Dj.get(dj_key) # TODO: CRITICAL: CRITICAL: Don't show every goddamn DJ dj_list = [] # Seriously screw this crap #dj_list = cache.getAllDjs() if not dj: self.session.add_flash( "The DJ specified (" + dj_key + ") does not exist. Please try again.") self.redirect("/dj/djs/") else: template_values = { 'dj_list': dj_list, 'dj': dj, 'session': self.session, 'flash': self.flashes, 'posts': BlogPost.get_last(num=3), } self.response.out.write( template.render(get_path("dj_manage_djs.html"), template_values))
def get(self): djkey = self.dj_key template_values = { 'session': self.session, 'flashes': self.session.get_flashes(), 'posts': BlogPost.get_last(3), } permissions = { 'djs': Permission.DJ_EDIT, 'programs': Permission.PROGRAM_EDIT, 'albums': Permission.ALBUM_EDIT, 'permissions': Permission.PERMISSION_EDIT, 'genres': Permission.GENRE_EDIT, 'blogs': Permission.BLOG_EDIT, 'events': Permission.EVENT_EDIT,} permissions_dict = dict(('manage_%s'%key, Permission.get_by_title(perm).has_dj(djkey)) for (key, perm) in permissions.iteritems()) template_values.update(permissions_dict) self.response.out.write( template.render(get_path("dj_main.html"), template_values))
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('/')