Пример #1
0
def load_shopping_cart_company(request, cart):
    if check_all_sessions(request):

        cart = EC_ShoppingCart.objects.get(pk=cart)
        cart_context = {}
        template = "ecommerce/company_cart_items.html"

        if cart.market.company.pk == request.session['ms']:
            items = EC_ShoppingCartItems.objects.filter(cart=cart.pk)
            quantity = 0
            total = 0

            if items is not None:
                for item in items:
                    quantity += item.quantity
                    total += item.total

            cart_context["cart"] = cart
            cart_context["items"] = items
            cart_context["quantity"] = quantity
            cart_context["total"] = total
            cart_context["currency"] = cart.market.company.get_currency()
            cart_context["user"] = User.objects.get(pk=cart.market.user.pk)
            cart_context["market"] = EC_MarketAccess.objects.get(
                pk=cart.market.pk)

            return render(request, template, cart_context)
        else:
            return HttpResponse("Not Owner")
    else:
        return HttpResponse("MS and Admin Required")
Пример #2
0
    def get(self, request):
        if check_all_sessions(request):
            ecommerce_context = {}
            ecommerce_context.update(csrf(request))
            text = "If set to <b>False</b>, users and your customers cannot be able to buy online nor access your macket "
            text += "but if set to <b>True</b>, your customers can be able to order online."
            ecommerce_set = EC_CompanySettings.objects.get(
                company=request.session['ms'])

            ecommerce_context["setting"] = ecommerce_set
            ecommerce_context["text"] = text

            return render_to_response(self.template, ecommerce_context)
        else:
            return HttpResponse("MS and Admin Sessions Required")
Пример #3
0
    def get(self, request):
        if check_all_sessions(request):
            ecommerce_context = {}
            ecommerce_context.update(csrf(request))
            text = "Set it to <b>True</b> then add your paypal email or other so that "
            text += "you may receive your poayment on paypal."

            ecommerce_set = EC_CompanySettings.objects.get(
                company=request.session['ms'])

            ecommerce_context["setting"] = ecommerce_set
            ecommerce_context["text"] = text

            return render_to_response(self.template, ecommerce_context)
        else:
            return HttpResponse("MS and Admin Sessions Required")
Пример #4
0
def load_shopping_cart_json(request, cart):
    cart = EC_ShoppingCart.objects.get(pk=cart)
    if 'username' in request.session:
        if cart.market.user.pk == request.session['user']:
            return HttpResponse(
                json.dumps(cart.get_shopping_cart_json(), default=str))
        else:
            return HttpResponse("Not Owner")
    elif check_all_sessions(request):
        if cart.market.company.pk == request.session['ms']:
            return HttpResponse(
                json.dumps(cart.get_shopping_cart_json(), default=str))
        else:
            return HttpResponse("Not Owner")
    else:
        return HttpResponse("User or Company Session Required")
Пример #5
0
 def post(self, request):
     if check_all_sessions(request):
         if request.method == "POST":
             setting = request.POST.get('setting', '')
             password = request.POST.get('password', '')
             ecommerce_set = EC_CompanySettings.objects.get(
                 company=request.session['ms'])
             if check_ms_password(request, password) is not None:
                 ecommerce_set.mobile = setting
                 ecommerce_set.save()
                 return HttpResponse('ok')
             else:
                 return HttpResponse("Wrong MS Password !!!")
         else:
             return HttpResponse("Bad Request")
     else:
         return HttpResponse("MS and Admin Sessions Required")
Пример #6
0
    def get(self, request):
        if check_all_sessions(request):
            ecommerce_context = {}
            ecommerce_context.update(csrf(request))

            text = "If set to <b>True</b>, you will be able to receive the payment "
            text += " through mobile money. You must add numbers in MS Settings"

            ecommerce_set = EC_CompanySettings.objects.get(
                company=request.session['ms'])

            ecommerce_context["setting"] = ecommerce_set
            ecommerce_context["text"] = text

            return render_to_response(self.template, ecommerce_context)
        else:
            return HttpResponse("MS and Admin Sessions Required")
Пример #7
0
def company_allow_user_access_market(request, key):
    if check_all_sessions(request):
        market_access = EC_MarketAccess.objects.get(key=key)
        settings = MS_Settings.objects.get(company=request.session['ms'])
        status = request.GET.get('status')
        if market_access is not None and market_access.company.pk == request.session[
                'ms']:
            if market_access.status == "vip":
                return HttpResponse(
                    json.dumps(market_access.get_access_market_json(),
                               default=str))
            elif market_access.status == "bloked":
                return HttpResponse("bloked")
            else:
                if status == "allow":
                    market_access.status = "allowed"
                    if settings.access_market == True:
                        market_access.access_time = settings.time_market_access
                        market_access.time_from = datetime.now()
                        market_access.time_to = datetime.now() + timedelta(
                            minutes=int(settings.time_market_access))
                        market_access.save()
                        return HttpResponse(
                            json.dumps(market_access.get_access_market_json(),
                                       default=str))
                    else:
                        market_access.save()
                        return HttpResponse(
                            json.dumps(market_access.get_access_market_json(),
                                       default=str))
                elif status == "vip":
                    market_access.status = "vip"
                    market_access.save()
                    return HttpResponse(
                        json.dumps(market_access.get_access_market_json(),
                                   default=str))
                else:
                    return HttpResponse("missing status")
        else:
            return HttpResponse("error")
    else:
        return HttpResponse("session")
Пример #8
0
 def add_paypal_account(self, request):
     if check_all_sessions(request):
         if request.method == "POST":
             account = request.POST.get('account', '')
             password = request.POST.get('password', '')
             ecommerce_set = EC_CompanySettings.objects.get(
                 company=request.session['ms'])
             if email_check(account) is not False:
                 if ecommerce_set.use_paypal is True:
                     ecommerce_set.paypal = account
                     ecommerce_set.save()
                     return HttpResponse('ok')
                 else:
                     return HttpResponse(
                         "Set Use E-Comerce PayPal To True !!!")
             else:
                 return HttpResponse("Enter A Right Email !!!")
         else:
             return HttpResponse("Bad Request")
     else:
         return HttpResponse("MS and Admin Sessions Required")
Пример #9
0
def load_company_ecommerse_settings(request):
    if check_all_sessions(request):
        template = "managment/mssettings/ecommerce_set.html"
        company = MS_CompanyAdministrator.objects.get(pk=request.session['ms'])
        ecommerce_set = EC_CompanySettings.objects.filter(
            company=company.pk).first()

        ecommerce_context = {}

        if ecommerce_set is not None:
            ecommerce_context["settings"] = ecommerce_set
        else:
            ecommerce_set = EC_CompanySettings(
                company=MS_CompanyAdministrator.objects.get(
                    company=company.pk))
            ecommerce_set.save()
            ecommerce_context["settings"] = ecommerce_set

        return render(request, template, ecommerce_context)
    else:
        return HttpResponse("Session Company & Admin Required")