示例#1
0
 def _get_user_account(self, form):
     user = form.cleaned_data.get("user")
     user_accounts = gateway.user_accounts(user)
     if len(user_accounts):
         return user_accounts[0]
     else:
         return self._create_user_account(user=user)
示例#2
0
def get_imported_user_account(form):
    user = form.cleaned_data.get("user")
    user_accounts = gateway.user_accounts(user)
    if len(user_accounts):
        return user_accounts[0]
    else:
        return create_imported_user_account(user=user)
示例#3
0
def current_balance(user):
    if user.is_authenticated:
        user_accounts = gateway.user_accounts(user)
        total_balance = user_accounts.aggregate(Sum("balance")).get(
            "balance__sum", 0)
    else:
        total_balance = 0
    return total_balance
示例#4
0
文件: views.py 项目: naoufad/CEL2
    def get_context_data(self, **kwargs):
        ctx = super(ProfileView, self).get_context_data(**kwargs)
        ctx['profile_fields'] = self.get_profile_fields(self.request.user)

        ctx['user_accounts'] = gateway.user_accounts(self.request.user)
        #Ajout des comptes MpessaOnLine sur profile

        return ctx
    def get_context_data(self, **kwargs):
        ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)

        # Add variable to indicate if the user is blocked from paying with
        # accounts.
        ctx['is_blocked'] = security.is_blocked(self.request)

        form = forms.ValidAccountForm(self.request.user)
        ctx['account_form'] = form

        # Add accounts that are linked to this user
        if self.request.user.is_authenticated():
            ctx['user_accounts'] = gateway.user_accounts(self.request.user)

        # Add existing allocations to context
        allocations = self.get_account_allocations()
        ctx['account_allocations'] = allocations
        ctx['to_allocate'] = ctx['order_total_incl_tax'] - allocations.total

        return ctx
示例#6
0
文件: views.py 项目: SpivEgin/devenv
    def get_context_data(self, **kwargs):
        ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)

        # Add variable to indicate if the user is blocked from paying with
        # accounts.
        ctx['is_blocked'] = security.is_blocked(self.request)

        form = forms.ValidAccountForm(self.request.user)
        ctx['account_form'] = form

        # Add accounts that are linked to this user
        if self.request.user.is_authenticated():
            ctx['user_accounts'] = gateway.user_accounts(self.request.user)

        # Add existing allocations to context
        allocations = self.get_account_allocations()
        ctx['account_allocations'] = allocations
        ctx['to_allocate'] = ctx['order_total_incl_tax'] - allocations.total

        return ctx
示例#7
0
    def get_context_data(self, **kwargs):
        ctx = super().get_context_data(**kwargs)

        # Add variable to indicate if the user is blocked from paying with
        # accounts.
        ctx['is_blocked'] = security.is_blocked(self.request)

        form = forms.ValidAccountForm(self.request.user)
        ctx['account_form'] = form

        # Add accounts that are linked to this user
        if self.request.user.is_authenticated:
            ctx['user_accounts'] = gateway.user_accounts(self.request.user)

        # Add existing allocations to context
        allocations = self.get_account_allocations()
        ctx['account_allocations'] = allocations
        order_total = ctx['order_total']
        total_for_allocation = order_total.incl_tax if order_total.is_tax_known else order_total.excl_tax
        ctx['to_allocate'] = total_for_allocation - allocations.total

        return ctx
示例#8
0
    def get_context_data(self, **kwargs):
        ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
        ctx['paysource'] = self.get_paymethod()
        ctx['paymethod'] = self.paymentsource_name[self.get_paymethod()]
        if self.get_paymethod() == 'oscar_account':
            # Add variable to indicate if the user is blocked from paying with
            # accounts.
            ctx['is_blocked'] = security.is_blocked(self.request)

            form = forms.ValidAccountForm(self.request.user)
            ctx['account_form'] = form

            # Add accounts that are linked to this user
            if self.request.user.is_authenticated():
                ctx['user_accounts'] = gateway.user_accounts(
                    self.request.user)[0]
                code = ctx['user_accounts'].code
                balance = ctx['user_accounts'].balance
                order_total = ctx['order_total'].incl_tax if ctx[
                    'order_total'].is_tax_known else ctx['order_total'].excl_tax
                if balance < order_total:
                    self.store_allocation_in_session({
                        'code': code,
                        'amount': balance
                    })
                else:
                    self.store_allocation_in_session({
                        'code': code,
                        'amount': order_total
                    })
                ctx['allocation_form'] = forms.AllocationForm(
                    ctx['user_accounts'], self.request.basket,
                    ctx['shipping_charge'].incl_tax
                    if ctx['shipping_charge'].is_tax_known else
                    ctx['shipping_charge'].excl_tax, order_total,
                    self.get_account_allocations())

        return ctx
示例#9
0
 def get_context_data(self, **kwargs):
     ctx = super().get_context_data(**kwargs)
     # Add accounts that are linked to this user
     if self.request.user.is_authenticated:
         ctx["user_accounts"] = gateway.user_accounts(self.request.user)
     return ctx