def get(self): content_part = (self.request.matchdict.get("keyword") or self.request.matchdict.get("content_type") or self.request.matchdict.get("name") or self.request.matchdict.get("citation")) if self.request.matchdict.get("sort"): content_pieces = ContentView.bulk_retrieve( sort=self.request.matchdict.get("sort"), page_num=self.request.data["page_num"]) elif content_part: content_pieces = ContentView.bulk_retrieve( sort=self.request.matchdict.get("sort"), content_part=content_part, page_num=self.request.data["page_num"]) elif self.request.matchdict.get("q"): content_pieces = ContentView.search( query=self.request.matchdict["q"], page_num=self.request.data["page_num"], ) else: content_pieces = ContentView.bulk_retrieve( page_num=self.request.data["page_num"]) return { "data": content_pieces, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Content pieces retrieved successfully." }
def __acl__(self): edit = EditView(self.vote["edit_id"], validation_status="validating") content = ContentView(content_id=edit.edit["content_id"]) if content.authors is not None: author_list = [(Allow, format_identifier(user["user_id"]), (VIEW, AUTHOR)) for user in content.authors] else: author_list = [] return [(Allow, ADMIN, VIEW)] + author_list
def get_keywords(self): if self.request.matchdict.get("complete"): keywords = ContentView.autocomplete( "keyword", self.request.matchdict["complete"]) response = { "message": "Keyword completions retrieved successfully." } else: keywords = ContentView.get_parts( content_part="keyword", page_num=self.request.data["page_num"]) response = {"message": "Keywords retrieved successfully."} response.update({ "data": keywords, "links": { "came_from": self.came_from, "url": self.url, }, }) return response
def get_content_types(self): content_types = ContentView.get_parts(content_part="content_type") return { "data": content_types, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Content types retrieved successfully." }
def get_names(self): names = ContentView.autocomplete("name", self.request.matchdict["complete"]) return { "data": names, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Name completions retrieved successfully." }
def get_content(self): page_num = self.request.data["page_num"] or 0 user_content = ContentView.user_content(user_id=self.user.user_id, page_num=page_num) return { "data": user_content, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Authored content metadata retrieved successfully." }
def get_recent_activity(self): page_num = self.request.data["page_num"] or 1 activity_data = ContentView.recent_activity(user_id=self.user.user_id, page_num=page_num) return { "data": activity_data, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Recent activity metadata retrieved successfully." }
def get_edit_activity(self): edit_activity = ContentView.validation_data( self.request.authenticated_userid, self.request.data["content_id"], self.request.data["validating_page_num"], self.request.data["closed_page_num"], ) return { "data": edit_activity, "links": { "came_from": self.came_from, "url": self.url, }, "message": "Edit activity successfully retrieved." }