def view_news(self, request): layout = NewsLayout(self, request) years = self.years try: year = int(request.params["year"]) except (ValueError, KeyError): year = years and years[0] or None query = self.news_query if year: start = replace_timezone(datetime(year, 1, 1), "UTC") query = query.filter(Page.created >= start) query = query.filter(Page.created < start.replace(year=year + 1)) if request.is_logged_in: layout.editbar_links = list(self.get_editbar_links(request)) children = query.all() else: children = request.exclude_invisible(query.all()) return { "layout": layout, "title": self.title, "name": self.trait_messages[self.trait]["name"], "page": self, "children": children, "years": years, "current_year": year, }
def view_news(self, request): layout = NewsLayout(self, request) if request.is_logged_in: layout.editbar_links = list(self.get_editbar_links(request)) children = self.news_query.all() else: children = request.exclude_invisible(self.news_query.all()) return { 'layout': layout, 'title': self.title, 'name': self.trait_messages[self.trait]['name'], 'page': self, 'children': children, }