def get(self, article_group_id=None, decorator_data=None):
     #TODO: pass app_user_id to the user role decorator once it is created
     if article_group_id is None:
         article_group_list = ArticleGroupDataAccess(
         ).get_all_article_groups()
         return [
             ArticleGroupModel._construct(n) for n in article_group_list
         ]
     else:
         article_group = ArticleGroupDataAccess().get_article_group(
             article_group_id)
         return ArticleGroupModel._construct(article_group)
Beispiel #2
0
 def put(self, article_id):
     article_data = request.get_json()
     result = ArticleDataAccess().edit_article(article_id, article_data)
     user = AppUserDataAccess().get_user_by_id(result.app_user_id)
     article_group = ArticleGroupDataAccess().get_article_group(
         result.article_group_id
     ) if result.article_group_id is not None else None
     return ArticleModel._construct_for_output(result, user, article_group)
 def delete(self, article_group_id):
     if ArticleGroupDataAccess().delete_article_group(article_group_id):
         return '', 204
     else:
         return 'Article Group ID {} not found'.format(
             article_group_id), 410
 def post(self):
     article_group_data = request.get_json()
     article_group = ArticleGroupModel(**article_group_data)
     result = ArticleGroupDataAccess().create_article_group(article_group)
     return ArticleGroupModel._construct(result)
 def put(self, article_group_id):
     article_group_data = request.get_json()
     article_group = ArticleGroupModel(**article_group_data)
     result = ArticleGroupDataAccess().edit_article_group(
         article_group_id, article_group)
     return ArticleGroupModel._construct(result)
 def get(self, article_group_id):
     user_list = ArticleGroupDataAccess().get_articles_by_article_group(
         article_group_id)
     return [AppUserModel._construct(n) for n in user_list]