def get_forum(id): forum = get(Forum, id) forum_posts_json = [] original_post = False for forum_post in forum.forum_posts: user = forum_post.user.name forum_post = forum_post.__dict__ if (forum_post['is_original_post'] == True): original_post = ForumPostDTO( forum_post['id'], forum_post['body'], forum_post['date'].isoformat(), forum_post['is_original_post'], user, forum_post['approved'], ).__dict__ else: forum_posts_json.append( ForumPostDTO( forum_post['id'], forum_post['body'], forum_post['date'].isoformat(), forum_post['is_original_post'], user, forum_post['approved'], ).__dict__) forum.forum_posts = list(reversed(forum.forum_posts)) forum = forum.__dict__ return ForumDTO(forum['id'], forum['title'], forum_posts_json, original_post).__dict__
def get_post(id): post = get(Post, id) author = AuthorDTO(post.author.id, post.author.name, post.author.biography).__dict__ post = post.__dict__ return PostDTO( post['id'], post['title'], post['body'], post['date'].isoformat(), post['img'], post['requires_login'], author, post['publish_date'].isoformat() ).__dict__
def get_author(id): author = get(Author, id) author = author.__dict__ return AuthorDTO(author['id'], author['name'], author['biography']).__dict__
def get_video_category(id): video_category = get(VideoCategory, id) video_category = video_category.__dict__ return VideoCategoryDTO(video_category['id'], video_category['name']).__dict__
def get_user(uid): user = get(User, uid) user = user.__dict__ return UserDTO(user['uid'], user['name'], user['document'], user['phone'], user['business_name'], user['is_admin'], user['email']).__dict__
def get_ad(id): ad = get(Ad, id) ad = ad.__dict__ return AdDTO(ad['id'], ad['text'], ad['img'], ad['url']).__dict__
def get_symbol_subcategory(id): symbol_subcategory = get(SymbolSubcategory, id) symbol_subcategory = symbol_subcategory.__dict__ return SymbolSubcategoryDTO(symbol_subcategory['id'], symbol_subcategory['name'], symbol_subcategory['category_id']).__dict__
def get_video(id): video = get(Video, id) video = video.__dict__ return VideoDTO(video['id'], video['title'], video['date'].isoformat(), video['youtube_url'], video['subcategory_id']).__dict__
def get_symbol(id): symbol = get(Symbol, id) symbol = symbol.__dict__ return SymbolDTO(symbol['id'], symbol['title'], symbol['body'], symbol['img'], symbol['subcategory_id']).__dict__