Example #1
0
    def get(cls, last_fetch=None):

        user = get_jwt_identity()
        if user:
            return {
                "categories": [category.json() for category in CategoryModel.find_all_existing()]
            }

        last_fetch = last_fetch if last_fetch is not None else cls.parser.parse_args()[
            "last_fetch"]

        if DEBUG:
            return {"new": [category.json() for category in CategoryModel.find_new(last_fetch)],
                    "deleted": [category.json() for category in CategoryModel.find_deleted(last_fetch)],
                    "updated": [category.json() for category in CategoryModel.find_updated(last_fetch)],
                    "all": [category.json() for category in CategoryModel.find_all()]
                    }
        return {"new": [category.json() for category in CategoryModel.find_new(last_fetch)],
                "deleted": [category.json() for category in CategoryModel.find_deleted(last_fetch)],
                "updated": [category.json() for category in CategoryModel.find_updated(last_fetch)]
                }
Example #2
0
 def get(self):
     categories = CategoryModel.find_all()
     if categories:
         return [category.json() for category in categories]
     return {'message': 'no categories for user'}, 404
Example #3
0
 def get(self):
     return {'categorys': [x.json() for x in CategoryModel.find_all()]}
Example #4
0
 def get(self):
     return {
         'categories':
         [category.json() for category in CategoryModel.find_all()]
     }, 200