shoop.admin package

Subpackages

Submodules

shoop.admin.base module

class shoop.admin.base.AdminModule[source]

Bases: object

name = '_Base_'
breadcrumbs_menu_entry = None
get_urls()[source]
Return type:list[django.core.urlresolvers.RegexURLPattern]
get_menu_category_icons()[source]
Return type:dict[str,str]
get_menu_entries(request)[source]
Return type:list[shoop.admin.base.MenuEntry]
get_search_results(request, query)[source]
Return type:list[shoop.admin.base.SearchResult]
get_dashboard_blocks(request)[source]
Return type:list[shoop.admin.dashboard.DashboardBlock]
get_required_permissions()[source]
Return type:list[str]
get_notifications(request)[source]
Return type:list[shoop.admin.base.Notification]
get_activity(request, cutoff)[source]
Parameters:
  • cutoff (datetime.datetime) – Cutoff datetime
  • request (django.http.request.HttpRequest) – Request
Returns:

list[shoop.admin.base.Activity]

get_model_url(object, kind)[source]

Retrieve an admin URL for the given object of the kind kind.

A falsy value must be returned if the module does not know how to reverse the given object.

Parameters:
  • object (django.db.models.Model) – A object instance (or object class).
  • kind (str) – URL kind. Currently “detail”, “list” or “new”.
Returns:

The reversed URL or none.

Return type:

str|None

class shoop.admin.base.Resolvable[source]

Bases: object

url

Resolve this object’s _url to an actual URL.

Returns:URL or no URL.
Return type:str|None
original_url
class shoop.admin.base.MenuEntry(text, url, icon=None, category=None, aliases=())[source]

Bases: shoop.admin.base.Resolvable

get_search_query_texts()[source]
class shoop.admin.base.SearchResult(text, url, icon=None, category=None, is_action=False, relevance=100, target=None)[source]

Bases: shoop.admin.base.Resolvable

to_json()[source]
class shoop.admin.base.Notification(text, title=None, url=None, kind='info', dismissal_url=None, datetime=None)[source]

Bases: shoop.admin.base.Resolvable

Parameters:
  • text (str) – The notification’s text.
  • title (str|None) – An optional title for the notification.
  • url (str|None) – The optional main URL for the notification.
  • kind (str) – The kind of the notification (see KINDS)
  • dismissal_url (str|None) – An optional dismissal URL for the notification. The admin framework will add a button that will cause an AJAX post into this URL.
  • datetime (datetime) – An optional date+time for this notification.
KINDS = ('info', 'success', 'warning', 'danger')
class shoop.admin.base.Activity(datetime, text, url=None)[source]

Bases: shoop.admin.base.Resolvable

class shoop.admin.base.OrderSection[source]

Bases: object

Subclass this and add the class to the admin_order_section provide list to show a custom section on the order detail on admin.

identifier must be unique name the section caption icon the section icon template the section template file extra_js the section extra javascript template file,

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/stable/shoop/admin/base.py:docstring of shoop.admin.base.OrderSection, line 9)

Unexpected indentation.
set a file which contains js code inside a <script> tag

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/stable/shoop/admin/base.py:docstring of shoop.admin.base.OrderSection, line 10)

Block quote ends without a blank line; unexpected unindent.

order the order

identifier = ''
name = ''
icon = ''
template = ''
extra_js = ''
order = 0
static visible_for_order(order)[source]

Returns whether this sections must be visible while editing the order :type order: shoop.core.models.Order :return whether this section must be shown in order section list :rtype: bool

static get_context_data(order)[source]

Returns additional information to be used in the template

To fetch this data in the template, just access it through OrderSection_identifier.data

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/stable/shoop/admin/base.py:docstring of shoop.admin.base.OrderSection.get_context_data, line 6)

Field list ends without a blank line; unexpected unindent.

:return additional context data :rtype: object|None

shoop.admin.breadcrumbs module

class shoop.admin.breadcrumbs.Breadcrumbs(entries)[source]

Bases: object

classmethod infer(context)[source]

Infer breadcrumbs from the rendering context.

Parameters:context (jinja2.runtime.Context) – Jinja Context
Returns:Breadcrumbs object or None if things fail
Return type:Breadcrumbs|None
get_entries(request)[source]

shoop.admin.currencybound module

class shoop.admin.currencybound.CurrencyBound(currency=None, *args, **kwargs)[source]

Bases: object

Mixin for adding currency property defaulting currency of the first Shop.

The currency property is “lazy” so that database is not accessed on initialization, since this mixin will be used by some AdminModule classes and they will be initialized at import time by module_registry.register (which is called at import because admin.urls calls get_module_urls at import).

currency

shoop.admin.form_part module

class shoop.admin.form_part.TemplatedFormDef(name, form_class, template_name, required=True, kwargs=None)[source]

Bases: shoop.utils.form_group.FormDef

class shoop.admin.form_part.FormPart(request, object=None)[source]

Bases: object

priority = 0
get_form_defs()[source]
form_valid(form)[source]
class shoop.admin.form_part.FormPartsViewMixin[source]

Bases: object

fields = ()
request = None
form_part_class_provide_key = None
base_form_part_classes = ()
get_form_class()[source]
get_form_part_classes()[source]
get_form_parts(object)[source]
get_form(form_class=None)[source]
class shoop.admin.form_part.SaveFormPartsMixin[source]

Bases: object

request = None
object = None
save_form_parts(form)[source]

shoop.admin.menu module

shoop.admin.menu.get_menu_entry_categories(request)[source]

shoop.admin.module_registry module

shoop.admin.module_registry.register(module_class)[source]
shoop.admin.module_registry.discover()[source]
shoop.admin.module_registry.get_modules()[source]
Return type:list[shoop.admin.base.AdminModule]
shoop.admin.module_registry.get_module_urls()[source]
shoop.admin.module_registry.replace_modules(new_module_classes)[source]

Context manager to temporarily replace all modules with something else.

Test utility, mostly.

>>> def some_test():
...     with replace_modules(["foo.bar:QuuxModule"]):
...         pass # do stuff
Parameters:new_module_classes – Iterable of module classes, like you’d pass to register

shoop.admin.toolbar module

class shoop.admin.toolbar.BaseActionButton(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='btn-default')[source]

Bases: object

Parameters:
  • text – The actual text for the button.
  • icon – Icon CSS class string
  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.
  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.
  • extra_css_class (str) – Extra CSS class(es)
base_css_classes = ('btn',)
render(request)[source]

Yield HTML bits for this object. :type request: HttpRequest :rtype: Iterable[str]

render_label()[source]
get_computed_class()[source]
class shoop.admin.toolbar.URLActionButton(url, **kwargs)[source]

Bases: shoop.admin.toolbar.BaseActionButton

An action button that renders as a link leading to url.

Parameters:url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.
render(request)[source]
class shoop.admin.toolbar.NewActionButton(url, **kwargs)[source]

Bases: shoop.admin.toolbar.URLActionButton

An URL button with sane “new” visual semantics

classmethod for_model(model, **kwargs)[source]

Generate a NewActionButton for a model, auto-wiring the URL.

Parameters:model – Model class
Return type:shoop.admin.toolbar.NewActionButton|None
class shoop.admin.toolbar.JavaScriptActionButton(onclick, **kwargs)[source]

Bases: shoop.admin.toolbar.BaseActionButton

An action button that uses onclick for action dispatch.

render(request)[source]
class shoop.admin.toolbar.PostActionButton(post_url=None, name=None, value=None, form_id=None, confirm=None, **kwargs)[source]

Bases: shoop.admin.toolbar.BaseActionButton

An action button that renders as a button POSTing a form containing name`=`value to post_url.

render(request)[source]
class shoop.admin.toolbar.DropdownActionButton(items, split_button=None, **kwargs)[source]

Bases: shoop.admin.toolbar.BaseActionButton

An action button with a chevron button to open a dropdown menu.

base_css_classes = ('btn', 'dropdown-toggle')
render_dropdown(request)[source]
render(request)[source]
class shoop.admin.toolbar.DropdownItem(url='#', onclick=None, **kwargs)[source]

Bases: shoop.admin.toolbar.BaseActionButton

An item to be shown in a DropdownActionButton.

base_css_classes = ()
render(request)[source]
class shoop.admin.toolbar.DropdownDivider(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='btn-default')[source]

Bases: shoop.admin.toolbar.BaseActionButton

A Divider for DropdownActionButtons.

Parameters:
  • text – The actual text for the button.
  • icon – Icon CSS class string
  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.
  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.
  • extra_css_class (str) – Extra CSS class(es)
base_css_classes = ()
render(request)[source]
class shoop.admin.toolbar.DropdownHeader(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='btn-default')[source]

Bases: shoop.admin.toolbar.BaseActionButton

Header for DropdownActionButtons.

Parameters:
  • text – The actual text for the button.
  • icon – Icon CSS class string
  • disable_reason (str|None) – The reason for this button to be disabled. It’s considered good UX to have an user-visible reason for disabled actions; thus the only way to disable an action is to set the reason. See http://stackoverflow.com/a/372503/51685.
  • tooltip (str|None) – Tooltip string, if any. May be replaced by the disable reason.
  • extra_css_class (str) – Extra CSS class(es)
base_css_classes = ()
render(request)[source]
class shoop.admin.toolbar.ButtonGroup[source]

Bases: list

render(request)[source]
class shoop.admin.toolbar.Toolbar[source]

Bases: list

render(request)[source]
render_to_string(request)[source]
shoop.admin.toolbar.try_reverse(viewname, **kwargs)[source]
shoop.admin.toolbar.get_discard_button(discard_url)[source]
shoop.admin.toolbar.get_default_edit_toolbar(view_object, save_form_id, discard_url=None, delete_url=None, with_split_save=True, toolbar=None)[source]

Get a toolbar with buttons used for object editing.

Parameters:
  • view_object (django.views.generic.UpdateView) – The class-based-view object requiring the toolbar
  • save_form_id (str) – The DOM ID to target for the save button
  • discard_url (str|None) – The URL/route name for the Discard button. Falsy values default to the request URL.
  • delete_url (str|None) – The URL/route name for the Delete button. If this is not set, the delete button is not shown.
  • with_split_save (bool) – Use split delete button with “Save and Exit” etc.?
  • toolbar (Toolbar) – The toolbar to augment. If None, a new one is created.
Returns:

Toolbar

Return type:

Toolbar

shoop.admin.urls module

shoop.admin.urls.login(request, **kwargs)[source]
shoop.admin.urls.get_urls()[source]

Module contents

class shoop.admin.ShoopAdminAppConfig(*args, **kwargs)[source]

Bases: shoop.apps.AppConfig

name = 'shoop.admin'
verbose_name = 'Shoop Admin'
label = 'shoop_admin'
required_installed_apps = ['bootstrap3']
provides = {'service_behavior_component_form_part': ['shoop.admin.modules.services.weight_based_pricing.WeightBasedPricingFormPart'], 'service_provider_admin_form': ['shoop.admin.modules.service_providers.forms:CustomCarrierForm', 'shoop.admin.modules.service_providers.forms:CustomPaymentProcessorForm'], 'admin_order_section': ['shoop.admin.modules.orders.sections:ContentsOrderSection', 'shoop.admin.modules.orders.sections:PaymentOrderSection', 'shoop.admin.modules.orders.sections:LogEntriesOrderSection'], 'service_behavior_component_form': ['shoop.admin.modules.services.forms:FixedCostBehaviorComponentForm', 'shoop.admin.modules.services.forms:WaivingCostBehaviorComponentForm', 'shoop.admin.modules.services.forms:WeightLimitsBehaviorComponentForm', 'shoop.admin.modules.services.forms:GroupAvailabilityBehaviorComponentForm', 'shoop.admin.modules.services.forms.StaffOnlyBehaviorComponentForm', 'shoop.admin.modules.services.forms:RoundingBehaviorComponentForm'], 'admin_module': ['shoop.admin.modules.system:SystemModule', 'shoop.admin.modules.products:ProductModule', 'shoop.admin.modules.product_types:ProductTypeModule', 'shoop.admin.modules.media:MediaModule', 'shoop.admin.modules.orders:OrderModule', 'shoop.admin.modules.taxes:TaxModule', 'shoop.admin.modules.categories:CategoryModule', 'shoop.admin.modules.contacts:ContactModule', 'shoop.admin.modules.contact_groups:ContactGroupModule', 'shoop.admin.modules.permission_groups:PermissionGroupModule', 'shoop.admin.modules.users:UserModule', 'shoop.admin.modules.service_providers:ServiceProviderModule', 'shoop.admin.modules.services:PaymentMethodModule', 'shoop.admin.modules.services:ShippingMethodModule', 'shoop.admin.modules.attributes:AttributeModule', 'shoop.admin.modules.sales_units:SalesUnitModule', 'shoop.admin.modules.shops:ShopModule', 'shoop.admin.modules.demo:DemoModule', 'shoop.admin.modules.manufacturers:ManufacturerModule', 'shoop.admin.modules.suppliers:SupplierModule']}
ready()[source]