예제 #1
0
 def post(self, request, uuid):
     order = get_object(model_app['order'], {'unique_id': uuid})
     status = request.POST.get('status')
     if status:
         order.status = status
         order.save()
     return redirect(f'/order/{uuid}')
예제 #2
0
    def put(self, request, id):

        id = get_object(model_app['card_management'], {'id': id})
        return SerializeResponse(request.data,
                                 self.serializer,
                                 save=True,
                                 id=id)
예제 #3
0
    def post(self, request):

        serializer = self.serializer(data=request.data)

        # Check serializer is valid not
        if not serializer.is_valid():

            return ReturnResponse(data=serializer.errors)

        serializer.save()

        obj = get_object(auth_app['account'],
                         {'email': serializer.data.get('email')})

        serializer2 = self.detailserializer(obj)

        if serializer.data.get('account_type') == 'S':
            #send_otp(obj.otp, obj.phone)
            pass
        else:
            obj.verify = True
            obj.save()

        return ReturnResponse(message='Register successsfully',
                              data=serializer2.data,
                              status=True)
예제 #4
0
 def post(self, request, id):
     id = get_object(auth_app['hair_profile'], {'id': id})
     return SerializeResponse(request.data,
                              self.serializer,
                              save=True,
                              id=id,
                              partial=True)
예제 #5
0
    def post(self, request):

        serializer = self.serializer(data=request.data)

        if not serializer.is_valid():

            return ReturnResponse(data=serializer.errors, status=False)

        code = request.data.get('code', '0')
        email = request.data.get('email', '')

        obj = get_object(model=self.model,
                         query={
                             'email': email,
                             'forgot_otp': code
                         })

        # OTP match
        if obj:

            # OTP expiration-
            if check_otp_expire(obj.forgot_time):
                return ReturnResponse(message='OTP is expired', status=False)
            # Set password
            obj.set_password(serializer.data.get('password'))
            obj.save()

            return ReturnResponse(message='Password changed successfully',
                                  status=True)

        return ReturnResponse(message='Invalid OTP', status=False)
예제 #6
0
    def post(self, request, id):

        id = get_object(model_app['order'], {'id': id})

        return SerializeResponse(request.data,
                                 self.serializer,
                                 save=True,
                                 id=id)
예제 #7
0
    def get(self, request):

        data = get_object(
            model_app['card_management'],
            {
                'user__id': request.user.id,
                'default': True
            },
        )

        return FetchSerializeResponse(data, self.serializer)
예제 #8
0
    def post(self, request, id):

        order = get_object(model_app['order'], {
            'id': id,
            'book_by': request.user
        })
        if order:
            status = request.data.get('status')
            order.status = status
            order.save()

        return FetchSerializeResponse(order, self.serializer)
예제 #9
0
    def post(self, request):

        email = request.data.get('email')
        obj = get_object(model=self.model, query={'email': email})

        # Account exist
        if obj:
            obj.otp = generate_otp()
            obj.send_time = datetime.now()
            send_otp(obj.otp, obj.phone)
            obj.save()
            return ReturnResponse(
                message='OTP send on mobile to change password', status=True)
        return ReturnResponse(
            message='Account with this email is not register', status=False)
예제 #10
0
    def post(self, request, id):

        data = filter_query('card_management', {
            'user__id': request.user.id
        }).update(default=False)

        id = get_object(model_app['payment'], {
            'id': id,
            'user__id': request.user.id
        })
        id.default = True
        id.save()

        return SerializeResponse(request.data,
                                 self.serializer,
                                 save=True,
                                 id=id,
                                 partial=True)
예제 #11
0
    def post(self, request, id):

        data = self.payment_api().post(request)

        order = get_object(model_app['order'], {'id': id})
        order.pk = None
        order.is_reorder = True
        order.unique_id = str(uuid.uuid4())
        order.status = 'CONFIRM'
        order.save()

        book_services = filter_query('book_service', {'order__id': id})

        for service in book_services:
            obj = service
            obj.order = order
            obj.pk = None
            obj.save()

        return FetchSerializeResponse(order, self.serializer)
예제 #12
0
    def post(self, request):

        code = request.data.get('code', '0')
        email = request.data.get('email', '')
        obj = get_object(model=self.model, query={'email': email, 'otp': code})

        # ----OTP match----
        if obj:

            # ----Check already verified----
            if obj.verify:
                return ReturnResponse(
                    message='This account is already verified', status=False)

            # ----OTP expiration----
            if check_otp_expire(obj.send_time):
                return ReturnResponse(message='OTP is expired', status=False)
            obj.verify = True
            obj.save()
            return ReturnResponse(message='Account verified successfully',
                                  status=True)
        return ReturnResponse(message='Invalid OTP', status=False)
예제 #13
0
    def get(self, request, id):

        id = get_object(model_app['order'], {'id': id})

        return FetchSerializeResponse(id, self.serializer)
예제 #14
0
    def get(self, request, uuid):
        order = get_object(model_app['order'], {'unique_id': uuid})

        return render(request, self.template, context={"order": order})
예제 #15
0
    def get(self, request, id):

        data = get_object(model_app['card_management'], {'id': id})
        return FetchSerializeResponse(data, self.serializer)
예제 #16
0
    def post(self, request):

        serializer = self.serializer(data=request.data)

        if serializer.is_valid():
            email = serializer.data.get('email')
            password = serializer.data.get('password')
            account_type = serializer.data.get('account_type')
            social_id = serializer.data.get('social_id')

            if account_type == 'A' or account_type == 'F':

                user_exist = filter_query('account',
                                          query={
                                              'email': email,
                                              "account_type": account_type
                                          }).exists()

                if not user_exist:

                    return ReturnResponse(
                        message='User is not register with this account',
                        code=ResponseStatus.HTTP_202_ACCEPTED)

                obj = get_object(model=self.model,
                                 query={
                                     'email': email,
                                     'social_id': social_id
                                 })

                if obj:

                    return ReturnResponse(message='Login successfully',
                                          data=self.userserializer(obj).data,
                                          status=True)
                else:

                    return ReturnResponse(
                        message='User is not register with this account')

            auth = authenticate(email=email, password=password)

            # ----check user is authenticated or not----
            if auth is not None:

                # ----check user in verified or not----
                if not auth.verify:
                    return ReturnResponse(message='This account is unverified',
                                          code=ResponseStatus.HTTP_201_CREATED,
                                          data=self.unverified_user(auth).data)

                login(request, auth)

                return ReturnResponse(message='Login successfully',
                                      data=self.userserializer(auth).data,
                                      status=True)

            else:
                return ReturnResponse(message='Invalid email or password',
                                      data=serializer.errors)

        return ReturnResponse(data=serializer.errors)