def save(self): client = get_object_or_404(Client, id=self.cleaned_data.get('clientId')) manager = get_object_or_404(User, username=self.cleaned_data.get('manager')) user = get_object_or_404(User, username = self.cleaned_data.get('author')) contactPerson = get_object_or_404(Persons, id=self.cleaned_data.get('contactPersonId')) order = Order( client = client, status = self.cleaned_data.get('status'), call_on = self.cleaned_data.get('call_on'), call_or_email = self.cleaned_data.get('call_or_email'), contactPerson = contactPerson, manager = manager, author = user, ) order.save() #create order_process order_process = Order_process(order = order, step = 1, step_description = self.cleaned_data.get('step_description'), manager = manager, ) order_process.save() return order
def save(self): client = get_object_or_404(Client, id=self.cleaned_data.get('clientId')) manager = get_object_or_404(User, username=self.cleaned_data.get('manager')) user = get_object_or_404(User, username=self.cleaned_data.get('author')) contactPerson = get_object_or_404( Persons, id=self.cleaned_data.get('contactPersonId')) order = Order( client=client, status=self.cleaned_data.get('status'), call_on=self.cleaned_data.get('call_on'), call_or_email=self.cleaned_data.get('call_or_email'), contactPerson=contactPerson, manager=manager, author=user, ) order.save() #create order_process order_process = Order_process( order=order, step=1, step_description=self.cleaned_data.get('step_description'), manager=manager, ) order_process.save() return order
def save(self, **kwargs): user = get_object_or_404(User, username=self.cleaned_data.get('author')) client = Client(author=user) client.save() person = Persons( client=client, firstName=self.cleaned_data.get('firstName'), telephoneNum1=self.cleaned_data.get('telephoneNum1'), email1=self.cleaned_data.get('email1'), author=user, ) person.save() manager = get_object_or_404(User, username=self.cleaned_data.get('manager')) order = Order( client=client, status=self.cleaned_data.get('status'), call_on=self.cleaned_data.get('call_on'), call_or_email=self.cleaned_data.get('call_or_email'), manager=manager, contactPerson=person, author=user, ) order.save() #create order_process order_process = Order_process( order=order, step=1, step_description=self.cleaned_data.get('step_description'), manager=manager, ) order_process.save() if self.cleaned_data.get('city'): legal_details = Legal_details( client=client, city=self.cleaned_data.get('city'), author=user, ) legal_details.save() return client
def add_to_cart(request): try: id = request.POST.get('good_id') cart = Order.get_order(request) cart.add_good(id) res = {'res': True, 'count': cart.goods_count()} except: res = {'res': False} return HttpResponse(json.dumps(res), content_type='application/json')
def login(request): order_anon = Order.get_order(request) email = request.POST.get('email') password = request.POST.get('password') user = auth.authenticate(username=email, password=password) if user is not None and user.is_active: auth.login(request, user) order = Order.get_order(request) if order.goods_count() == 0: order.delete() order_anon.user = user order_anon.save() else: order_anon.delete() del request.session['order'] return HttpResponse(json.dumps({'res': True}), content_type="application/json") else: return HttpResponse(json.dumps({'res': False}), content_type="application/json")
def post(self, request, **kwargs): if request.user.is_anonymous(): return redirect('register') self.object_list = self.get_queryset() context = self.get_context_data() order = Order.get_order(request) order.close() context['closed']=True return render(request, self.template_name, context)
def save(self, **kwargs): user = get_object_or_404(User, username = self.cleaned_data.get('author')) client = Client(author=user) client.save() person = Persons(client=client, firstName=self.cleaned_data.get('firstName'), telephoneNum1=self.cleaned_data.get('telephoneNum1'), email1=self.cleaned_data.get('email1'), author=user, ) person.save() manager = get_object_or_404(User, username=self.cleaned_data.get('manager')) order = Order( client = client, status = self.cleaned_data.get('status'), call_on = self.cleaned_data.get('call_on'), call_or_email = self.cleaned_data.get('call_or_email'), manager = manager, contactPerson = person, author = user, ) order.save() #create order_process order_process = Order_process(order = order, step = 1, step_description = self.cleaned_data.get('step_description'), manager = manager, ) order_process.save() if self.cleaned_data.get('city'): legal_details = Legal_details( client = client, city = self.cleaned_data.get('city'), author = user, ) legal_details.save() return client
def change_count(request): order_good = OrderGood.objects.get(id=int(request.POST.get('id'))) price = 0 try: count = int(request.POST.get('count', 1)) order_good.count = count order_good.save() price = order_good.good.price * count except: return HttpResponse(json.dumps({'res': False}), content_type='application/json') order = Order.get_order(request) total = order.get_total() return HttpResponse(json.dumps({'res': True, 'total': total, 'price': price}), content_type='application/json')
def get_queryset(self, queryset=None): order = Order.get_order(self.request) return OrderGood.objects.filter(order=order).distinct()
def render_user_menu(context): user = context.request.user order = Order.get_order(context.request) return {"auth": user.is_authenticated(), "user": user, "order": order}