• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python urls.get_model_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: get_context_data

 def get_context_data(self, **kwargs):
     context = super(EditScriptContentView, self).get_context_data(**kwargs)
     context["title"] = get_create_or_change_title(self.request, self.object)
     context["action_infos"] = Action.get_ui_info_map()
     context["condition_infos"] = Condition.get_ui_info_map()
     context["cond_op_names"] = get_enum_choices_dict(StepConditionOperator)
     context["step_next_names"] = get_enum_choices_dict(StepNext)
     context["toolbar"] = Toolbar([
         JavaScriptActionButton(
             text="Save", icon="fa fa-save", extra_css_class="btn-success",
             onclick="ScriptEditor.save();return false"
         ),
         get_discard_button(get_model_url(self.object, "edit"))
     ])
     return context
开发者ID:sebad78,项目名称:shoop,代码行数:15,代码来源:editor.py


示例17: for_model

    def for_model(cls, model, **kwargs):
        """
        Generate a NewActionButton for a model, auto-wiring the URL.

        :param model: Model class
        :rtype: shoop.admin.toolbar.NewActionButton|None
        """

        if "url" not in kwargs:
            try:
                url = get_model_url(model, kind="new")
            except NoModelUrl:
                return None
            kwargs["url"] = url
        kwargs.setdefault("text", _("New %(model)s") % {"model": model._meta.verbose_name})
        return cls(**kwargs)
开发者ID:Carolina061,项目名称:shoop,代码行数:16,代码来源:toolbar.py


示例18: get_toolbar

    def get_toolbar(self):
        save_form_id = self.get_save_form_id()
        object = self.get_object()
        delete_url = reverse_lazy("shoop_admin:service_provider.delete", kwargs={"pk": object.pk})
        toolbar = get_default_edit_toolbar(self, save_form_id, delete_url=delete_url)
        if self.object.pk:
            toolbar.append(URLActionButton(
                text=_("Create {service_name}").format(
                    service_name=self.object.service_model._meta.verbose_name),
                icon="fa fa-plus",
                url="{model_url}?provider={id}".format(
                    model_url=get_model_url(self.object.service_model, "new"),
                    id=self.object.id),
                extra_css_class="btn-info"
            ))

        return toolbar
开发者ID:00WhengWheng,项目名称:shuup,代码行数:17,代码来源:_edit.py


示例19: render_text

    def render_text(self, obj):
        url = getattr(obj, "url", None)
        text = self.empty_text
        if obj:
            text = force_text(obj)
            if not url:
                try:
                    url = get_model_url(obj)
                except NoModelUrl:
                    pass
        if not url:
            url = "#"

        return mark_safe("<a class=\"browse-text\" href=\"%(url)s\" target=\"_blank\">%(text)s</a>&nbsp;" % {
            "text": escape(text),
            "url": escape(url),
        })
开发者ID:taedori81,项目名称:shoop,代码行数:17,代码来源:widgets.py


示例20: handle_create

 def handle_create(self, request):
     try:
         state = json.loads(request.body.decode("utf-8"))["state"]
         order = create_order_from_state(state, creator=request.user)
         messages.success(request, _("Order %(identifier)s created.") % vars(order))
         return JsonResponse({
             "success": True,
             "orderIdentifier": order.identifier,
             "url": get_model_url(order)
         })
     except Exception as exc:
         tb = traceback.format_exc()
         message = _("Could not create order:")
         if isinstance(exc, ValidationError):  # pragma: no branch
             message += "\n" + "\n".join(force_text(err) for err in exc.messages)
         else:
             message += " " + tb  # pragma: no cover
         return JsonResponse({"success": False, "errorMessage": message}, status=400)
开发者ID:hitchhooker,项目名称:shoop,代码行数:18,代码来源:create.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python provides.get_provide_objects函数代码示例发布时间:2022-05-27
下一篇:
Python urls.derive_model_url函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap