当前位置: 首页>>代码示例>>Python>>正文


Python Account.user方法代码示例

本文整理汇总了Python中accounts.models.Account.user方法的典型用法代码示例。如果您正苦于以下问题:Python Account.user方法的具体用法?Python Account.user怎么用?Python Account.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在accounts.models.Account的用法示例。


在下文中一共展示了Account.user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
def register(request):
    if request.method == "POST":
        nextPage = request.POST.get("next", "/")
        form = RegisterForm(request.POST)
        if form.is_valid():
            try:
                form.save()
            except:
                print "Unable to save form..."
                return render_to_response("registration/registration.html", {'form': form, 'next': nextPage}, context_instance=RequestContext(request))
            user = authenticate(username=request.POST.get("username"), password=request.POST.get("password1"))
            login(request, user)
            account = Account()
            account.user = User.objects.get(pk=user.id)
            account.created_by = user
            account.save()
            return redirect(nextPage)
        else:
            print "errors in registration"
            print form.errors
    else:
        form = RegisterForm()
        nextPage = request.GET.get("next", "/")
    # return render_to_response("registration/login.html", {}, context_instance=RequestContext(request))
    return redirect("ig.api.connectInstagram")
开发者ID:JasonTsao,项目名称:Fashion,代码行数:27,代码来源:views.py

示例2: test_get_samples

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
	def test_get_samples(self):
		acc = Account()
		acc.user = self.user
		fake_task_id = str(uuid4())
		run = ScanRun.objects.create_pending_scan_run(self.inert, fake_task_id)
		sample = acc.get_samples()
		# sample = [<FileSample: 4>]
		self.assertTrue(isinstance(sample[0], FileSample),
		                msg='Sample object is not instance of FileSample: {0}'.format(sample[0]))
开发者ID:MarlonNakouzi,项目名称:phagescan,代码行数:11,代码来源:tests.py

示例3: test_get_pending_scans_not_empty

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
	def test_get_pending_scans_not_empty(self):
		acc = Account()
		acc.user = self.user

		fake_task_id = str(uuid4())
		run = ScanRun.objects.create_pending_scan_run(self.inert, fake_task_id)
		pending = acc.get_pending_scans()
		#  pending == ['<ScanRun: 3 2013-08-19 14:37:56.165701+00:00>']
		self.assertTrue(isinstance(pending[0], ScanRun),
		                msg='Pending scan object is not of instance of ScanRun: {0}'.format(pending[0]))
开发者ID:MarlonNakouzi,项目名称:phagescan,代码行数:12,代码来源:tests.py

示例4: create_account

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
def create_account(user):
    try:
        account = Account.objects.get(user=user)
        # print "Account already exists"
    except:
        account = Account()
        account.user = User.objects.get(pk=user.id)
        account.created_by = user
        try:
            account.save()
            return True
        except Exception as e:
            print "Unable to save account..."
            print e
            return False
    return True
开发者ID:JasonTsao,项目名称:Fashion,代码行数:18,代码来源:views.py

示例5: checkout

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
def checkout(request, cart, order):
    """Handle checkout process - if the order is completed, show the success
       page, otherwise show the checkout form.
    """

    # if the cart is already linked with an order, show that order
    if not order and cart.order_obj:
        return redirect(cart.order_obj)

    if order and order.status >= Order.STATUS_PAID:
        if cart.order_obj == order:
            cart.clear()
        return {
            "template": "success",
            "order": order,
        }

    if request.user.is_authenticated():
        account = Account.objects.for_user(request.user)
        get_user_form = lambda *a: None
    else:
        account = Account()
        get_user_form = partial(CheckoutUserForm)

    if order:
        get_form = partial(OrderForm, instance=order)
        get_gift_form = partial(GiftRecipientForm, prefix='gift',
                                instance=order.get_gift_recipient())
        def sanity_check():
            return 0

        new_order = False
    else:
        # set initial data from the user's account, the shipping
        # options, and any saved session data
        initial = {}
        if account.pk and not initial:
            initial.update(account.as_dict())

        shipping_module = get_shipping_module()
        if shipping_module:
            initial.update(shipping_module.get_session(request))

        initial.update(request.session.get(CHECKOUT_SESSION_KEY, {}))

        get_form = partial(OrderForm, initial=initial)
        get_gift_form = partial(GiftRecipientForm, prefix='gift')
        sanity_check = lambda: cart.subtotal
        new_order = True

    # Add in any custom cart verification here
    cart_errors = []

    if request.method == 'POST':
        form = get_form(request.POST, sanity_check=sanity_check())

        user_form = get_user_form(request.POST)
        save_details = not account.pk and request.POST.get('save-details')
        if save_details and user_form:
            # if creating a new user, the email needs to be unused
            form.require_unique_email = True
            user_form_valid = user_form.is_valid()
        else:
            user_form_valid = True

        gift_form = get_gift_form(request.POST)
        is_gift = request.POST.get('is_gift')
        gift_form_valid = gift_form.is_valid() if is_gift else True

        if form.is_valid() and (order or not cart.empty()) and \
           user_form_valid and gift_form_valid and not len(cart_errors):
            # save the order obj to the db...
            order = form.save(commit=False)
            order.currency = cart.currency

            # save details to account if requested
            if save_details:
                account.from_obj(order)
                if user_form:
                    user = user_form.save(email=order.email, name=order.name)
                    account.user = user
                    auth_user = authenticate(
                        username=user.email,
                        password=user_form.cleaned_data['password1'])
                    login(request, auth_user)
                account.save()

            if account.pk:
                order.account = account

            order.save()

            if is_gift:
                recipient = gift_form.save(commit=False)
                recipient.order = order
                recipient.save()
            elif gift_form.instance and gift_form.instance.pk:
                gift_form.instance.delete()

            # save any cart lines to the order, overwriting existing lines, but
#.........这里部分代码省略.........
开发者ID:brendonjohn,项目名称:django-shoptools,代码行数:103,代码来源:views.py

示例6: test_get_pending_scans_empty

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
	def test_get_pending_scans_empty(self):
		acc = Account()
		acc.user = self.user
		pending = acc.get_pending_scans()
		self.assertQuerysetEqual(pending, [])
开发者ID:MarlonNakouzi,项目名称:phagescan,代码行数:7,代码来源:tests.py

示例7: test_api_key

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import user [as 别名]
	def test_api_key(self):
		acc = Account()
		acc.user = self.user
		key = acc.get_api_key()
		self.assertIsNotNone(key, msg="API key is none.")
开发者ID:MarlonNakouzi,项目名称:phagescan,代码行数:7,代码来源:tests.py


注:本文中的accounts.models.Account.user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。