Ejemplo n.º 1
0
class OrderList(View):
    @method_decorator(validate_form(OrderListForm))
    def get(self, request, cleaned_data):
        total, orders = orderservice.get_order_list(**cleaned_data)
        return dict(total=total, orders=wrap_order(orders))

    @method_decorator(validate_form(AddOrderForm))
    def post(self, request, cleaned_data):
        operator_id = request.user.id
        order_id = orderservice.add_order(operator_id, **cleaned_data)
        return dict(id=order_id)
Ejemplo n.º 2
0
class Video(View):
    @method_decorator(validate_form(VideoListForm))
    def get(self, request, cleaned_data):
        total, videos = videoservice.get_video_list(**cleaned_data)
        return dict(total=total,
                    videos=[wrap_videos(video) for video in videos])

    @method_decorator(validate_form(AddVideoForm))
    def post(self, request, cleaned_data):
        uploader_id = request.user.id
        video_id = videoservice.add_video(**cleaned_data,
                                          uploader_id=uploader_id)
        return dict(id=video_id)
Ejemplo n.º 3
0
class FeedbackView(View):
    @method_decorator(require_login)
    @method_decorator(validate_form(GetFeedbacksForm))
    def get(self, request, cleaned_data):
        user_id = request.user_id
        feedbacks = feedbackservice.get_feedback_history(user_id, **cleaned_data, is_read=True)
        return dict(history=wrap_feedback(feedbacks))

    @method_decorator(require_login)
    @method_decorator(validate_form(PostFeedbacksForm))
    def post(self, request, cleaned_data):
        user_id = request.user_id
        feedback_id = feedbackservice.add_feedback(user_id, **cleaned_data)
        return dict(id=feedback_id)
Ejemplo n.º 4
0
class FeedbackHistoryView(View):
    @method_decorator(validate_form(GetFeedbackHistoryForm))
    def get(self, request, user_id, cleaned_data):
        user_id = int(user_id)
        feedbacks = feedbackservice.get_feedback_history(
            user_id, **cleaned_data)
        return dict(history=wrap_feedback(feedbacks))
Ejemplo n.º 5
0
class PaywaysView(View):
    def get(self, request):
        pay_ways = payservice.get_pay_ways()
        return dict(pay_ways=wrap_pay_way(pay_ways))

    @method_decorator(validate_form(AddPaywayForm))
    def post(self, requset, cleaned_data):
        pay_id = payservice.add_pay_way(**cleaned_data)
        return dict(id=pay_id)
Ejemplo n.º 6
0
class VideoDetail(View):
    def get(self, request, video_id):
        video = videoservice.get_video_by_id(int(video_id))
        return wrap_videos(video)

    @method_decorator(validate_form(UpdateVideoForm))
    def put(self, request, video_id, cleaned_data):
        videoservice.update_video(int(video_id), **cleaned_data)
        return dict(id=1)

    def delete(self, request, video_id):
        return dict(id=videoservice.delete_video(int(video_id)))
Ejemplo n.º 7
0
class PaywaysDetailView(View):
    def get(self, request, way_id):
        pay_way = payservice.get_pay_way_by_id(way_id)
        return wrap_pay_way(pay_way)

    @method_decorator(validate_form(UpdatePaywayForm))
    def put(self, requset, way_id, cleaned_data):
        payservice.update_pay_way(way_id, **cleaned_data)
        return dict(id=1)

    def delete(self, request, way_id):
        payservice.delete_pay_way(way_id)

        return dict(id=1)
Ejemplo n.º 8
0
class FeedbackView(View):
    @method_decorator(validate_form(GetFeedbacksForm))
    def get(self, request, cleaned_data):
        total, feedbacks = feedbackservice.get_feedback_list(**cleaned_data)
        return dict(total=total, history=wrap_feedback(feedbacks))
Ejemplo n.º 9
0
class UserList(View):
    @method_decorator(validate_form(UserListForm))
    def get(self, request, cleaned_data):
        total, users = userservice.get_user_list(**cleaned_data)
        return dict(total=total, users=users)