예제 #1
0
파일: api.py 프로젝트: abettadapur/Planr
class PlanGenerateResource(Resource):
    def __init__(self):
        self.plan_repository = PlanRepository()
        self.category_repository = YelpCategoryRepository()

    @authenticate
    def post(self, **kwargs):
        user = kwargs['user']
        json = request.json

        if 'categories' not in json or len(json['categories']) == 0:
            on_error(error_message="Categories were not provided")

        if 'plan' not in json:
            on_error(error_message="Plan details were not provided")

        categories = self.category_repository.get_from_list(json['categories'])
        plan = json['plan']

        plan = Plan.from_json(plan, user)
        self.plan_repository.expunge(plan)
        result, failed_categories = populate_sample_plan(plan, categories)

        if not result:
            return failed_categories, 400

        polyline = get_polyline(plan)
        plan_dict = plan.as_dict()
        plan_dict['polylines'] = polyline
        return plan_dict
예제 #2
0
파일: api.py 프로젝트: abettadapur/Planr
class CategoryResource(Resource):
    def __init__(self):
        self.category_repository = YelpCategoryRepository()
        super(CategoryResource, self).__init__()

    @authenticate
    def get(self, **kwargs):
        categories = self.category_repository.get()
        return categories
예제 #3
0
파일: api.py 프로젝트: abettadapur/Planr
 def __init__(self):
     self.category_repository = YelpCategoryRepository()
     super(CategoryResource, self).__init__()
예제 #4
0
파일: api.py 프로젝트: abettadapur/Planr
 def __init__(self):
     self.plan_repository = PlanRepository()
     self.category_repository = YelpCategoryRepository()
예제 #5
0
 def get_default():
     from funtimes.repositories.yelpCategoryRepository import YelpCategoryRepository
     category_repository = YelpCategoryRepository()
     return category_repository.get(name="Other")