def GET_edit(self): if not (c.liveupdate_permissions.allow("settings") or c.liveupdate_permissions.allow("close")): abort(403) return pages.LiveUpdateEventPage( content=pages.LiveUpdateEventConfiguration(), ).render()
def GET_happening_now(self): """ Get some basic information about the currently featured live thread. Returns an empty 204 response for api requests if no thread is currently featured. See also: [/api/live/*thread*/about](#GET_api_live_{thread}_about). """ if not is_api() or not feature.is_enabled('live_happening_now'): self.abort404() event_id = NamedGlobals.get(HAPPENING_NOW_KEY, None) if not event_id: response.status_code = 204 return try: event = LiveUpdateEvent._byID(event_id) except NotFound: response.status_code = 204 return else: c.liveupdate_event = event content = Wrapped(event) return pages.LiveUpdateEventPage(content).render()
def GET_about(self): """Get some basic information about the live thread. See also: [/api/live/*thread*/edit](#POST_api_live_{thread}_edit). """ if not is_api(): self.abort404() content = Wrapped(c.liveupdate_event) return pages.LiveUpdateEventPage(content=content).render()
def GET_discussions(self, num, after, reverse, count): """Get a list of reddit submissions linking to this thread.""" show_hidden = c.liveupdate_permissions.allow("discussions") builder = get_discussions(c.liveupdate_event, limit=50, show_hidden=show_hidden) listing = LinkListing(builder).listing() listing.render_class = pages.LiveUpdateDiscussionsListing listing.submit_url = pages.make_submit_url(c.liveupdate_event) return pages.LiveUpdateEventPage(content=listing, ).render()
def GET_discussions(self, num, after, reverse, count): """Get a list of reddit submissions linking to this thread.""" builder = url_links_builder( url="/live/" + c.liveupdate_event._id, num=num, after=after, reverse=reverse, count=count, ) listing = LinkListing(builder).listing() return pages.LiveUpdateEventPage(content=listing, ).render()
def GET_about(self): """Get some basic information about the live thread. See also: [/api/live/*thread*/edit](#POST_api_live_{thread}_edit). """ if not is_api(): self.abort404() content = Wrapped(c.liveupdate_event) if c.liveupdate_event._date >= g.liveupdate_min_date_viewcounts: view_counts = ViewCountsQuery.execute( [c.liveupdate_event._fullname]) content.total_views = view_counts.get(c.liveupdate_event._fullname) return pages.LiveUpdateEventPage(content=content).render()
def GET_happening_now(self): """ Get some basic information about the currently featured live thread. Returns an empty 204 response for api requests if no thread is currently featured. See also: [/api/live/*thread*/about](#GET_api_live_{thread}_about). """ if not is_api(): self.abort404() featured_event = get_featured_event() if not featured_event: response.status_code = 204 return c.liveupdate_event = featured_event content = Wrapped(featured_event) return pages.LiveUpdateEventPage(content).render()
def GET_contributors(self): """Get a list of users that contribute to this thread. See also: [/api/live/*thread*/invite_contributor] (#POST_api_live_{thread}_invite_contributor), and [/api/live/*thread*/rm_contributor] (#POST_api_live_{thread}_rm_contributor). """ editable = c.liveupdate_permissions.allow("manage") content = [pages.LinkBackToLiveUpdate()] contributors = c.liveupdate_event.contributors invites = LiveUpdateContributorInvitesByEvent.get_all(c.liveupdate_event) contributor_builder = LiveUpdateContributorBuilder( c.liveupdate_event, contributors, editable) contributor_listing = pages.LiveUpdateContributorListing( c.liveupdate_event, contributor_builder, has_invite=c.user_is_loggedin and c.user._id in invites, is_contributor=c.user_is_loggedin and c.user._id in contributors, ).listing() content.append(contributor_listing) if editable: invite_builder = LiveUpdateInvitedContributorBuilder( c.liveupdate_event, invites, editable) invite_listing = pages.LiveUpdateInvitedContributorListing( c.liveupdate_event, invite_builder, editable=editable, ).listing() content.append(invite_listing) return pages.LiveUpdateEventPage( content=PaneStack(content), ).render()
def GET_edit(self): return pages.LiveUpdateEventPage( content=pages.LiveUpdateEventConfiguration(), ).render()