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


Python urls.get_model_url函数代码示例

本文整理汇总了Python中shoop.admin.utils.urls.get_model_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_model_url函数的具体用法?Python get_model_url怎么用?Python get_model_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_model_url

def test_model_url():
    with admin_only_urls():
        with pytest.raises(NoModelUrl):
            get_model_url(Counter)  # That's silly!
        p = Product()
        p.pk = 3
        assert get_model_url(p)
开发者ID:charn,项目名称:shoop,代码行数:7,代码来源:test_urls.py

示例2: _get_parent_and_sibling_items

 def _get_parent_and_sibling_items(self, parent, siblings):
     yield DropdownItem(
         text=_("Parent: %s") % parent,
         icon="fa fa-eye",
         url=get_model_url(parent),
     )
     for sib in siblings:
         yield DropdownItem(
             text=_("Sibling: %s") % sib,
             icon="fa fa-eye",
             url=get_model_url(sib),
         )
开发者ID:00WhengWheng,项目名称:shuup,代码行数:12,代码来源:toolbars.py

示例3: form_valid

 def form_valid(self, form):
     product_ids_to_quantities = dict(
         (int(key.replace("q_", "")), value)
         for (key, value)
         in six.iteritems(form.cleaned_data)
         if key.startswith("q_") and value > 0
     )
     order = self.object
     product_map = Product.objects.in_bulk(set(product_ids_to_quantities.keys()))
     products_to_quantities = dict(
         (product_map[product_id], quantity)
         for (product_id, quantity)
         in six.iteritems(product_ids_to_quantities)
     )
     try:
         shipment = order.create_shipment(
             supplier=form.cleaned_data["supplier"],
             product_quantities=products_to_quantities
         )
     except NoProductsToShipException:
         messages.error(self.request, _("No products to ship."))
         return self.form_invalid(form)
     else:
         messages.success(self.request, _("Shipment %s created.") % shipment.id)
         return HttpResponseRedirect(get_model_url(order))
开发者ID:jaywink,项目名称:shoop,代码行数:25,代码来源:shipment.py

示例4: _get_children_items

 def _get_children_items(self, children):
     for child in children:
         yield DropdownItem(
             text=_("Child: %s") % child,
             icon="fa fa-eye",
             url=get_model_url(child),
         )
开发者ID:00WhengWheng,项目名称:shuup,代码行数:7,代码来源:toolbars.py

示例5: get_breadcrumb_parents

 def get_breadcrumb_parents(self):
     return [
         MenuEntry(
             text=self.object,
             url=get_model_url(self.object)
         )
     ]
开发者ID:taedori81,项目名称:shoop,代码行数:7,代码来源:edit_variation.py

示例6: check_for_delete

def check_for_delete(view, request, object):
    can_delete = object.can_delete()
    delete_url = get_model_url(object, "delete")
    response = view(request, pk=object.pk)
    if hasattr(response, "render"):
        response.render()
    assert response.status_code in [200, 302]
    assert bool(delete_url in force_text(response.content)) == can_delete
开发者ID:MIKNOTAURO,项目名称:shoop,代码行数:8,代码来源:test_services.py

示例7: get_toolbar

 def get_toolbar(self):
     toolbar = get_default_edit_toolbar(
         self,
         "change_password_form",
         discard_url=get_model_url(self.object),
         with_split_save=False
     )
     return toolbar
开发者ID:Carolina061,项目名称:shoop,代码行数:8,代码来源:password.py

示例8: get_toolbar

 def get_toolbar(self):
     toolbar = get_default_edit_toolbar(
         self,
         self.get_save_form_id(),
         discard_url=(get_model_url(self.object) if self.object.pk else None)
     )
     # TODO: Add extensibility
     return toolbar
开发者ID:00WhengWheng,项目名称:shuup,代码行数:8,代码来源:edit.py

示例9: get_toolbar

    def get_toolbar(self):
        try:
            new_url = get_model_url(self.model, kind="new")
        except NoModelUrl:
            new_url = None

        if new_url:
            return Toolbar([NewActionButton(new_url)])
开发者ID:charn,项目名称:shoop,代码行数:8,代码来源:views.py

示例10: get_search_results

 def get_search_results(self, request, query):
     minimum_query_length = 3
     if len(query) >= minimum_query_length:
         users = get_user_model().objects.filter(Q(username__icontains=query) | Q(email=query))
         for i, user in enumerate(users[:10]):
             relevance = 100 - i
             yield SearchResult(
                 text=six.text_type(user), url=get_model_url(user), category=self.category, relevance=relevance
             )
开发者ID:DemOneEh,项目名称:shoop,代码行数:9,代码来源:__init__.py

示例11: test_product_module_search

def test_product_module_search(rf, admin_user):
    get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)

    with replace_modules([ProductModule]):
        with admin_only_urls():
            default_product = get_default_product()
            model_url = get_model_url(default_product)
            sku = default_product.sku
            assert any(sr.url == model_url for sr in get_search_results(request, query=sku))  # Queries work
            assert any(sr.is_action for sr in get_search_results(request, query=sku[:5]))  # Actions work
            assert empty_iterable(get_search_results(request, query=sku[:2]))  # Short queries don't
开发者ID:charn,项目名称:shoop,代码行数:12,代码来源:test_product_module.py

示例12: post

    def post(self, request, *args, **kwargs):
        order = self.object = self.get_object()
        new_status = OrderStatus.objects.get(pk=int(request.POST["status"]))
        if new_status.role == OrderStatusRole.COMPLETE and not order.can_set_complete():
            raise Problem(_("Unable to set order as completed at this point"))
        old_status = order.status
        order.status = new_status
        order.save(update_fields=("status",))
        message = _("Order status changed: %s \u2192 %s") % (old_status, new_status)
        order.add_log_entry(message, user=request.user, identifier="status_change")
        messages.success(self.request, message)

        return HttpResponseRedirect(get_model_url(self.get_object()))
开发者ID:charn,项目名称:shoop,代码行数:13,代码来源:detail.py

示例13: form_valid

 def form_valid(self, form):
     order = self.object
     amount = Money(form.cleaned_data["amount"], order.currency)
     if amount.value == 0:
         messages.error(self.request, _("Payment amount cannot be 0"))
         return self.form_invalid(form)
     try:
         payment = order.create_payment(amount, description="Manual payment")
         messages.success(self.request, _("Payment %s created.") % payment.payment_identifier)
     except NoPaymentToCreateException:
         messages.error(self.request, _("Order has already been paid"))
         return self.form_invalid(form)
     else:
         return HttpResponseRedirect(get_model_url(order))
开发者ID:00WhengWheng,项目名称:shuup,代码行数:14,代码来源:payment.py

示例14: get_search_results

 def get_search_results(self, request, query):
     minimum_query_length = 3
     if len(query) >= minimum_query_length:
         categories = Category.objects.filter(
             Q(translations__name__icontains=query) |
             Q(identifier__icontains=query)
         ).distinct().order_by("tree_id", "lft")
         for i, category in enumerate(categories[:10]):
             relevance = 100 - i
             yield SearchResult(
                 text=six.text_type(category),
                 url=get_model_url(category),
                 category=self.category,
                 relevance=relevance
             )
开发者ID:00WhengWheng,项目名称:shuup,代码行数:15,代码来源:__init__.py

示例15: get_search_results

    def get_search_results(self, request, query):
        minimum_query_length = 3
        if len(query) >= minimum_query_length:
            orders = Order.objects.filter(
                Q(identifier__istartswith=query)
                | Q(reference_number__istartswith=query)
                | Q(email__icontains=query)
                | Q(phone__icontains=query)
            ).order_by("-id")[:15]

            for i, order in enumerate(orders):
                relevance = 100 - i
                yield SearchResult(
                    text=six.text_type(order), url=get_model_url(order), category=_("Orders"), relevance=relevance
                )
开发者ID:taedori81,项目名称:shoop,代码行数:15,代码来源:__init__.py


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