本文整理汇总了Python中shuup.apps.provides.get_provide_objects函数的典型用法代码示例。如果您正苦于以下问题:Python get_provide_objects函数的具体用法?Python get_provide_objects怎么用?Python get_provide_objects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_provide_objects函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_form_parts
def get_form_parts(self, object):
form_parts = super(ServiceEditView, self).get_form_parts(object)
if not object.pk:
return form_parts
for form in get_provide_objects(self.form_provide_key):
form_parts.append(self._get_behavior_form_part(form, object))
for form_class in get_provide_objects(self.form_part_provide_key):
form_parts.append(form_class(self.request, object))
return form_parts
开发者ID:suutari,项目名称:shoop,代码行数:9,代码来源:_edit.py
示例2: _get_mass_actions
def _get_mass_actions(self):
mass_actions = self.mass_actions[:] # copy
# add mass actions from the view mass action provider
if getattr(self, "mass_actions_provider_key", None):
for mass_action_provider in get_provide_objects(self.mass_actions_provider_key):
mass_actions.extend(list(mass_action_provider.get_mass_actions_for_view(self)))
# add mass actions from the global mass action provider
for mass_action_provider in get_provide_objects("admin_mass_actions_provider"):
mass_actions.extend(list(mass_action_provider.get_mass_actions_for_view(self)))
return mass_actions
开发者ID:ruqaiya,项目名称:shuup,代码行数:13,代码来源:picotable.py
示例3: for_view
def for_view(cls, view):
toolbar = cls()
# add buttons from the view toolbar button provider
if getattr(view, "toolbar_buttons_provider_key", None):
for toolbar_buttons_provider in get_provide_objects(view.toolbar_buttons_provider_key):
toolbar.extend(list(toolbar_buttons_provider.get_buttons_for_view(view)))
# add buttons from the global toolbar button provider
for admin_toolbar_button_provider in get_provide_objects("admin_toolbar_button_provider"):
toolbar.extend(list(admin_toolbar_button_provider.get_buttons_for_view(view)))
return toolbar
开发者ID:ruqaiya,项目名称:shuup,代码行数:13,代码来源:toolbar.py
示例4: get_form_parts
def get_form_parts(self, object):
form_parts = super(CampaignEditView, self).get_form_parts(object)
if not object.pk:
return form_parts
for form in get_provide_objects(self.condition_key):
form_parts.append(self._get_rules_form_part(form, object))
for provide_key, form_part_class in self.effects:
for form in get_provide_objects(provide_key):
form_parts.append(self._get_effects_form_part(form, object, form_part_class))
return form_parts
开发者ID:NamiStudio,项目名称:shuup,代码行数:13,代码来源:_edit.py
示例5: search_from_provided_contexts
def search_from_provided_contexts(self, object):
provide_object_key = "provided_columns_%s" % type(object).__name__
for provided_column_object in get_provide_objects(provide_object_key):
obj = provided_column_object()
display_callable = maybe_callable(self.display, context=obj)
if display_callable:
return display_callable(object)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:picotable.py
示例6: _build_provided_toolbar_buttons
def _build_provided_toolbar_buttons(self):
for button in get_provide_objects("admin_order_toolbar_button"):
warnings.warn(
"admin_order_toolbar_button provider is deprecated, use admin_order_toolbar_action_item instead",
DeprecationWarning,
)
self.append(button(self.order))
开发者ID:shawnadelic,项目名称:shuup,代码行数:7,代码来源:toolbar.py
示例7: get_context_data
def get_context_data(self, **kwargs):
context = super(ThemeConfigView, self).get_context_data(**kwargs)
context["theme_classes"] = sorted(
[t for t in get_provide_objects("xtheme") if t.identifier], key=lambda t: (t.name or t.identifier)
)
context["current_theme"] = get_current_theme()
return context
开发者ID:shawnadelic,项目名称:shuup,代码行数:7,代码来源:views.py
示例8: _build_existing_product
def _build_existing_product(self):
product = self.product
# :type product: shuup.core.models.Product
save_as_copy_button = JavaScriptActionButton(
onclick="saveAsACopy()",
text=_("Save as a copy"),
icon="fa fa-clone",
)
self.append(save_as_copy_button)
cross_sell_button = DropdownItem(
text=_("Manage Cross-Selling"),
icon="fa fa-random",
url=reverse("shuup_admin:shop_product.edit_cross_sell", kwargs={"pk": product.pk}),
)
menu_items = [
DropdownHeader(text=_("Cross-Selling")),
cross_sell_button
]
for item in self._get_variation_and_package_menu_items(product):
menu_items.append(item)
for button in get_provide_objects("admin_product_toolbar_action_item"):
if button.visible_for_object(product):
menu_items.append(button(product))
if menu_items:
self.append(DropdownActionButton(
menu_items,
icon="fa fa-star",
text=_(u"Actions"),
extra_css_class="btn-info",
))
开发者ID:gurch101,项目名称:shuup,代码行数:35,代码来源:toolbars.py
示例9: _postprocess
def _postprocess(self, context, content):
for inject_func in get_provide_objects("xtheme_resource_injection"):
if callable(inject_func):
inject_func(context, content)
add_edit_resources(context)
content = inject_resources(context, content)
return content
开发者ID:NamiStudio,项目名称:shuup,代码行数:7,代码来源:engine.py
示例10: 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)
)
unsaved_shipment = Shipment(order=order, supplier=form.cleaned_data["supplier"])
for extend_class in get_provide_objects(FORM_MODIFIER_PROVIDER_KEY):
extend_class().form_valid_hook(form, unsaved_shipment)
try:
shipment = order.create_shipment(
product_quantities=products_to_quantities,
shipment=unsaved_shipment
)
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:ahmadzai,项目名称:shuup,代码行数:29,代码来源:shipment.py
示例11: __init__
def __init__(self, *args, **kwargs):
self.request = kwargs.pop("request")
super(SnippetForm, self).__init__(*args, **kwargs)
themes_choices = [
(theme.identifier, theme.name)
for theme in get_provide_objects("xtheme")
if theme.identifier
]
self.fields["themes"] = forms.MultipleChoiceField(
choices=themes_choices,
required=False,
help_text=_(
"Select the themes that will have this snippet injected. Leave the field blank to inject in all themes."
)
)
from shuup.xtheme.resources import LOCATION_INFO
location_choices = [
(location_name, location["name"])
for location_name, location in LOCATION_INFO.items()
]
self.fields["location"] = forms.ChoiceField(
choices=location_choices,
help_text=_("Select the location of the page to inject the snippet.")
)
开发者ID:ruqaiya,项目名称:shuup,代码行数:26,代码来源:_snippet.py
示例12: get_matching_for_product
def get_matching_for_product(shop_product, provide_category, skippable_classes=None):
"""
Get matching ids for shop product based on provide category
For example:
matching_ids = get_matching_for_product(shop_product, "campaign_catalog_filter")
:param shop_product: A Shop Product
:type shop_product: shuup.core.models.ShopProduct
:param provide_category: Provide category name
:type provide_category: str
:param skip: Classes to skip
:type skip: None or list
:return: list of collected item ids
:rtype: list[int]
"""
collected = set()
matcher = ProductCampaignMatcher(shop_product)
for item in get_provide_objects(provide_category):
if skippable_classes:
objects = item._meta.model.objects.not_instance_of(*skippable_classes).all()
else:
objects = item._meta.model.objects.all()
for obj in objects:
if matcher.matches(obj):
collected.add(obj.pk)
return collected
开发者ID:ruqaiya,项目名称:shuup,代码行数:27,代码来源:matcher.py
示例13: process_payment_return_request
def process_payment_return_request(self, service, order, request):
if not order.is_paid():
stripe_chargers = get_provide_objects("stripe_charger")
for stripe_charger in stripe_chargers:
if stripe_charger.identifier == service.choice_identifier:
charger = stripe_charger(order=order, secret_key=self.secret_key)
charger.create_charge()
开发者ID:shuup,项目名称:shuup-stripe,代码行数:7,代码来源:models.py
示例14: model_url
def model_url(context, model, kind="detail", default=None, **kwargs):
"""
Get a model URL of the given kind for a model (instance or class).
:param context: Jinja rendering context
:type context: jinja2.runtime.Context
:param model: The model instance or class.
:type model: django.db.Model
:param kind: The URL kind to retrieve. See `get_model_url`.
:type kind: str
:param default: Default value to return if model URL retrieval fails.
:type default: str
:return: URL string.
:rtype: str
"""
user = context.get("user")
try:
request = context.get("request")
shop = get_shop(request) if request else None
admin_model_url_resolvers = get_provide_objects("admin_model_url_resolver")
for resolver in admin_model_url_resolvers:
url = resolver(model, kind=kind, user=user, shop=shop, **kwargs)
if url:
return url
except NoModelUrl:
return default
开发者ID:shuup,项目名称:shuup,代码行数:27,代码来源:shuup_admin.py
示例15: __init__
def __init__(self, *args, **kwargs):
super(EmailAuthenticationForm, self).__init__(*args, **kwargs)
self.fields['username'].label = _("Username or email address")
for provider_cls in get_provide_objects("front_auth_form_field_provider"):
provider = provider_cls()
for definition in provider.get_fields(request=self.request):
self.fields[definition.name] = definition.field
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:forms.py
示例16: get_form
def get_form(self, form_class=None):
form_classes = list(get_provide_objects(self.form_provide_key))
form_infos = _FormInfoMap(form_classes)
if self.object and self.object.pk:
return self._get_concrete_form(form_infos)
else:
return self._get_type_choice_form(form_infos)
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:_edit.py
示例17: get_context_data
def get_context_data(self, **kwargs):
context = super(ProductEditView, self).get_context_data(**kwargs)
orderability_errors = []
if self.object.pk:
for shop in Shop.objects.all():
try:
shop_product = self.object.get_shop_instance(shop)
orderability_errors.extend(
["%s: %s" % (shop.name, msg.message)
for msg in shop_product.get_orderability_errors(
supplier=None,
quantity=shop_product.minimum_purchase_quantity,
customer=None)])
except ObjectDoesNotExist:
orderability_errors.extend(["%s: %s" % (shop.name, _("Product is not available."))])
context["orderability_errors"] = orderability_errors
context["product_sections"] = []
context["tour_key"] = "product"
context["tour_complete"] = is_tour_complete("product")
product_sections_provides = sorted(get_provide_objects("admin_product_section"), key=lambda x: x.order)
for admin_product_section in product_sections_provides:
if admin_product_section.visible_for_object(self.object):
context["product_sections"].append(admin_product_section)
context[admin_product_section.identifier] = admin_product_section.get_context_data(self.object)
return context
开发者ID:gurch101,项目名称:shuup,代码行数:27,代码来源:edit.py
示例18: get_menu_items
def get_menu_items(self):
items = []
for cls in get_provide_objects("customer_dashboard_items"):
c = cls(self.request)
if c.show_on_menu():
items.append(c)
return items
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:dashboard.py
示例19: _add_provided_columns
def _add_provided_columns(self, columns, identifier, known_names, model):
provide_object_key = "provided_columns_%s" % model.__name__
for provided_column_object in get_provide_objects(provide_object_key):
obj = provided_column_object()
column = obj.get_column(model, known_names, identifier)
if column:
columns.append(column)
开发者ID:ruqaiya,项目名称:shuup,代码行数:7,代码来源:view_settings.py
示例20: _build_action_menu
def _build_action_menu(self, product):
# cross selling
cross_sell_button = DropdownItem(
text=_("Manage Cross-Selling"),
icon="fa fa-random",
url=reverse("shuup_admin:shop_product.edit_cross_sell", kwargs={"pk": product.pk})
)
menu_items = [menu_item for menu_item in self._get_header_items(
header=_("Cross-Selling"), divider=False, identifier=ProductActionCategory.CHILD_CROSS_SELL)]
menu_items.append(cross_sell_button)
# packages
for item in self._get_variation_and_package_menu_items(product):
menu_items.append(item)
provided_items = get_provide_objects("admin_product_toolbar_action_item")
if provided_items:
for item in self._get_header_items(header=_("Other"), identifier=ProductActionCategory.CHILD_OTHER):
menu_items.append(item)
for button in provided_items:
if button.visible_for_object(product):
menu_items.append(button(product))
# add the actual Action button
self.append(DropdownActionButton(
menu_items,
icon="fa fa-star",
text=_(u"Actions"),
extra_css_class="btn-inverse btn-actions",
identifier=ProductActionCategory.MAIN
))
开发者ID:ruqaiya,项目名称:shuup,代码行数:32,代码来源:toolbars.py
注:本文中的shuup.apps.provides.get_provide_objects函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论