shuup.admin package

Subpackages

Submodules

shuup.admin.base module

class shuup.admin.base.AdminModule[source]

Bases: object

name = '_Base_'
breadcrumbs_menu_entry = None
get_urls()[source]
Return type:

list[django.urls.RegexURLPattern]

get_menu_category_icons()[source]
Return type:

dict[str,str]

get_menu_entries(request)[source]
Return type:

list[shuup.admin.base.MenuEntry]

get_search_results(request, query)[source]
Return type:

list[shuup.admin.base.SearchResult]

get_dashboard_blocks(request)[source]
Return type:

list[shuup.admin.dashboard.DashboardBlock]

get_help_blocks(request, kind)[source]
Parameters:
  • request (django.http.request.HttpRequest) – Request.

  • kind (str) – block kind. Currently “setup” or “quicklink”.

Return type:

list[shuup.admin.views.home.HelpBlock]

get_required_permissions() Iterable[str][source]

Returns a list of required permissions for this module to be enabled :rtype: list[str]

get_extra_permissions() Iterable[str][source]

Define custom extra permissions for admin module for option to limit certain parts of the admin module based on per user permission string. Should return unique list permission strings across the installation to prevent unwanted side effects.

Return type:

list[str]

get_permissions_help_texts() Dict[str, str] | Iterable[str][source]

Returns a dictionary where the keys is the permission identifier and the value is a help text that can help the user to understand where the permissions is used and how it works.

get_notifications(request)[source]
Return type:

list[shuup.admin.base.Notification]

get_activity(request, cutoff)[source]
Parameters:
  • cutoff (datetime.datetime) – Cutoff datetime.

  • request (django.http.request.HttpRequest) – Request.

Returns:

list[shuup.admin.base.Activity]

get_model_url(object, kind, shop=None)[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:
Returns:

The reversed URL or none.

Return type:

str|None

class shuup.admin.base.Resolvable[source]

Bases: object

property url

Resolve this object’s _url to an actual URL.

Returns:

URL or no URL.

Return type:

str|None

property original_url
class shuup.admin.base.BaseMenuEntry[source]

Bases: Resolvable

identifier = None
name = None
icon = ''
is_hidden = False
ordering = -1
entries: List[Any] = []
property id

Value containing only hexadecimal digits, we can use this safely in html code.

property has_entries
to_dict()[source]
get(item, default=None)[source]
class shuup.admin.base.MenuEntry(text, url, icon=None, category=None, ordering=99999, aliases=(), **kwargs)[source]

Bases: BaseMenuEntry

__init__(text, url, icon=None, category=None, ordering=99999, aliases=(), **kwargs)[source]
property identifier
property name
get_search_query_texts()[source]
get_text(request) str[source]
get_badge(request) Dict | None[source]

Should return a dictionary with the information of the badge or None: ```

{

“tag”: “info|success|danger|warning”, “value”: “my value”

}

```

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

Bases: Resolvable

__init__(text, url, icon=None, category=None, is_action=False, relevance=100, target=None)[source]
to_json()[source]
class shuup.admin.base.Notification(text, title=None, url=None, kind='info', dismissal_url=None, datetime=None)[source]

Bases: 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')
__init__(text, title=None, url=None, kind='info', dismissal_url=None, datetime=None)[source]
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.

class shuup.admin.base.Activity(datetime, text, url=None)[source]

Bases: Resolvable

__init__(datetime, text, url=None)[source]
class shuup.admin.base.Section[source]

Bases: object

Subclass this and add the class to the admin_*_section provide list (e.g. admin_order_section) to show a custom section on the specified model object’s admin detail page.

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, set a file which contains js code inside a <script> tag. order the order.

identifier: str = ''
name: str | Any = ''
icon: str = ''
template: str = ''
extra_js: str = ''
order: int = 0
classmethod visible_for_object(obj, request)[source]

Returns whether this sections must be visible for the provided object (e.g. order).

:return whether this section must be shown in order section list, defaults to false :rtype: bool

classmethod get_context_data(obj, request)[source]

Returns additional information to be used in the template.

To fetch this data in the template, you must first add it to your request’s context

e.g. `context[admin_order_section.identifier] =

admin_order_section.get_context_data(self.object)`

:return additional context data :rtype: object|None

class shuup.admin.base.AdminTemplateInjector[source]

Bases: object

classmethod get_admin_template_snippet(place: str, shop: Shop, user: User, supplier: Supplier | None)[source]

Get snippets to be injected on base admin template. The place can be: body_start, body_end, hear_start or head_end.

shuup.admin.browser_config module

class shuup.admin.browser_config.BaseBrowserConfigProvider[source]

Bases: object

classmethod get_browser_urls(request, **kwargs)[source]
classmethod get_gettings(request, **kwargs)[source]
class shuup.admin.browser_config.DefaultBrowserConfigProvider[source]

Bases: BaseBrowserConfigProvider

classmethod get_browser_urls(request, **kwargs)[source]
classmethod get_gettings(request, **kwargs)[source]

shuup.admin.currencybound module

class shuup.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).

__init__(currency=None, *args, **kwargs)[source]
property currency

shuup.admin.error_handlers module

class shuup.admin.error_handlers.AdminPageErrorHandler[source]

Bases: ErrorPageHandler

Page Error handler for Shuup Admin

classmethod can_handle_error(request, error_status)[source]

Returns whether this object can handle the error.

Return type:

bool

classmethod handle_error(request, error_status)[source]

Returns a response for the given request and error status.

Return type:

django.http.HttpResponse

shuup.admin.form_modifier module

class shuup.admin.form_modifier.ModifiableFormMixin[source]

Bases: object

form_modifier_provide_key = None
clean()[source]
class shuup.admin.form_modifier.ModifiableViewMixin[source]

Bases: object

add_extra_fields(form, object=None)[source]
get_form(form_class=None)[source]
form_valid_hook(form, object)[source]
form_valid(form)[source]
class shuup.admin.form_modifier.FormModifier[source]

Bases: object

Base class for form modifiers.

get_extra_fields(object=None)[source]

Get extra fields to add to the form.

clean_hook(form)[source]

Hook for additional form cleaning.

form_valid_hook(form, object)[source]

Hook called when form is valid.

shuup.admin.form_part module

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

Bases: FormDef

__init__(name, form_class, template_name, required=True, kwargs=None)[source]
class shuup.admin.form_part.FormPart(request, object=None)[source]

Bases: object

priority: int = 0
__init__(request, object=None)[source]
get_form_defs()[source]
form_valid(form)[source]
class shuup.admin.form_part.FormPartsViewMixin[source]

Bases: object

fields: Tuple | List = ()
request: Any | None = None
form_part_class_provide_key: str | None = None
base_form_part_classes: Any = ()
get_form_class()[source]
get_form_part_classes()[source]
get_form_parts(object)[source]
get_form(form_class=None)[source]
class shuup.admin.form_part.SaveFormPartsMixin[source]

Bases: object

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

shuup.admin.menu module

shuup.admin.menu.extend_main_menu(menu)[source]
shuup.admin.menu.customize_menu(entries, request)[source]

Merge system menu with customized admin menu

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

shuup.admin.middleware module

class shuup.admin.middleware.ShuupAdminMiddleware(get_response=None)[source]

Bases: MiddlewareMixin

Handle Shuup Admin specific tasks for each request and response.

  • Sets the current shop from the request request.shop : shuup.core.models.Shop

    Currently active Shop.

process_view(request, view_func, view_args, view_kwargs)[source]

shuup.admin.module_registry module

shuup.admin.module_registry.register(module_class)[source]
shuup.admin.module_registry.discover()[source]
shuup.admin.module_registry.get_admin_modules()[source]
Return type:

list[shuup.admin.base.AdminModule]

shuup.admin.module_registry.get_modules()[source]
Return type:

list[shuup.admin.base.AdminModule]

shuup.admin.module_registry.get_module_urls()[source]
shuup.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

shuup.admin.settings module

Settings of Shuup Admin.

See Settings (in shuup.apps) for general information about the Shuup settings system. Especially, when inventing settings of your own, the Naming Settings section is an important read.

shuup.admin.settings.SHUUP_SETUP_WIZARD_PANE_SPEC: List[str] = []

Spec which defines a list of Wizard Panes to be shown in Shuup Admin during Shuup’s initialization and configuration.

Panes must be subclasses of shuup.admin.views.WizardPane.

shuup.admin.settings.SHUUP_GET_ADMIN_MODULES_SPEC = 'shuup.admin.module_registry.get_admin_modules'

Spec which defines a function that loads and returns discovered admin modules. This function should return a list of shuup.admin.base.AdminModule.

shuup.admin.settings.SHUUP_ADMIN_SHOP_PROVIDER_SPEC = 'shuup.admin.shop_provider.AdminShopProvider'

Spec which defines the Shop provider. The shop provider is the interface responsible for fetching and setting the active shop in the admin module.

shuup.admin.settings.SHUUP_ADMIN_MERCHANT_DOCS_PAGE = 'https://shuup-guide.readthedocs.io/en/latest/'

URL address to Shuup Merchant Documentation and Guide. The URL must end with a slash.

The minimum number of characters required to start a search.

shuup.admin.settings.SHUUP_ADMIN_SUPPLIER_PROVIDER_SPEC = 'shuup.admin.supplier_provider.DefaultSupplierProvider'

Spec that defines the Supplier Provider for a given request.

shuup.admin.settings.SHUUP_ADMIN_DATE_INPUT_FORMAT = 'Y-m-d'

The input format to be used in date pickers.

shuup.admin.settings.SHUUP_ADMIN_DATETIME_INPUT_FORMAT = 'Y-m-d H:i'

The input format to be used in datetime pickers.

shuup.admin.settings.SHUUP_ADMIN_TIME_INPUT_FORMAT = 'H:i'

The input format to be used in time pickers.

shuup.admin.settings.SHUUP_ADMIN_DATETIME_INPUT_STEP = 15

The input step to be used for time pickers.

shuup.admin.settings.SHUUP_ALWAYS_ACTIVE_MENU_CATEGORY_IDENTIFIERS: List[str] = []

Menu category identifiers that should always activate the menu item. Useful in case there is a need to always open certain menus.

shuup.admin.settings.SHUUP_ADMIN_NAVIGATION_GET_FRONT_URL_SPEC = 'shuup.admin.utils.urls.get_front_url'

Get front URL for admin panel navigation bar. Can be useful for example to override a custom domain logic when admin panel is used from the shared marketplace URL.

shuup.admin.settings.SHUUP_ADMIN_LOAD_SELECT_OBJECTS_ASYNC = {'categories': True, 'suppliers': True}

Indicates which objects select fields should load options asynchronously.

When enabled, fields will load options through AJAX requests instead of generating them during the initial rendering the page. For enviroments with a huge amount of options in their fields, like categories, it is best to have this enabled.

When disabled, the options will be generated during the first page load.

shuup.admin.settings.SHUUP_ADMIN_AUTH_FORM_SPEC = 'shuup.admin.forms.EmailAuthenticationForm'

Indicates the authentication form class, which should be used in login views inside Admin.

shuup.admin.settings.SHUUP_ADMIN_LOGIN_AS_REDIRECT_VIEW = 'shuup:index'

To which view redirect impersonator when login as regular user

shuup.admin.settings.SHUUP_ADMIN_LOGIN_AS_STAFF_REDIRECT_VIEW = 'shuup_admin:dashboard'

To which view redirect impersonator when login as staff

shuup.admin.settings.SHUUP_ADMIN_REQUIRE_SHIPPING_METHOD_AT_ORDER_CREATOR = True

Whether to require shipping method at admin order creator/edit

shuup.admin.settings.SHUUP_ADMIN_REQUIRE_PAYMENT_METHOD_AT_ORDER_CREATOR = True

Whether to require payment method at admin order creator/edit

shuup.admin.settings.SHUUP_ADMIN_ALLOW_HTML_IN_PRODUCT_DESCRIPTION = True

Whether to allow vendors and staff to use a rich text editor and HTML for product descriptions. If this is False, only a allow simple text field and sanitize all HTML from it.

shuup.admin.settings.SHUUP_ADMIN_ALLOW_HTML_IN_VENDOR_DESCRIPTION = True

Whether to allow vendors to use a rich text editor and HTML for their profile descriptions. If this is False, only a allow simple text field and sanitize all HTML from it.

shuup.admin.settings.SHUUP_GET_MEDIA_FOLDER_FROM_FOLDER = 'shuup.admin.utils.media_folder_from_folder'

The method used to get the media folder from the folder. The relationship between media folder and folder is a foregin key from the mediafolder to the folder. Alltho this allows many media folder to be linked a folder we only have one media folder per folder. If the use case change we can change this setting to get the media folder from the folder.

shuup.admin.settings.SHUUP_ADMIN_PRODUCT_CLONER = 'shuup.admin.utils.product.ProductCloner'

Spec that indicates the product cloner object

shuup.admin.shop_provider module

class shuup.admin.shop_provider.AdminShopProvider[source]

Bases: object

get_shop(request)[source]
set_shop(request, shop=None)[source]
unset_shop(request)[source]
shuup.admin.shop_provider.get_shop_provider()[source]
shuup.admin.shop_provider.get_shop(request)[source]
shuup.admin.shop_provider.set_shop(request, shop=None)[source]
shuup.admin.shop_provider.unset_shop(request)[source]

shuup.admin.signal_handling module

shuup.admin.signal_handling.on_user_groups_change(instance, action, model, **kwargs)[source]
shuup.admin.signal_handling.on_object_saved(sender, object, **kwargs)[source]

shuup.admin.signals module

shuup.admin.supplier_provider module

class shuup.admin.supplier_provider.DefaultSupplierProvider[source]

Bases: object

classmethod get_supplier(request, **kwargs)[source]
shuup.admin.supplier_provider.get_supplier(request, **kwargs)[source]

shuup.admin.toolbar module

class shuup.admin.toolbar.BaseToolbarButtonProvider[source]

Bases: object

classmethod get_buttons_for_view(view)[source]

Implement this method to add custom buttons to a view’s toolbar

You can check the view attributes before returning buttons. In case you need to access the request, get it from the view: view.request. You can also access the view object when that is available:

``` if getattr(view, “object”, None):

yield JavaScriptActionButton(onclick=”window.doSomething()”, text=”Do Something”)

```

Parameters:

django.views.View (view) – the view object to add the toolbar.

:rtype iterator|list

class shuup.admin.toolbar.BaseActionButton(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='', required_permissions=(), identifier=None)[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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ('btn', '')
__init__(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='', required_permissions=(), identifier=None)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render(request)[source]

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

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

Bases: 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.

__init__(url, **kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

render(request)[source]

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

class shuup.admin.toolbar.SettingsActionButton(url, **kwargs)[source]

Bases: URLActionButton

A generic settings button meant to be used across many modules

Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

__init__(url, **kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

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

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

Parameters:

model – Model class

Return type:

shuup.admin.toolbar.SettingsActionButton|None

class shuup.admin.toolbar.NewActionButton(url, **kwargs)[source]

Bases: URLActionButton

An URL button with sane “new” visual semantics

Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

__init__(url, **kwargs)[source]
Parameters:

url (str) – The URL to navigate to. For convenience, if this contains no slashes, reverse is automatically called on it.

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

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

Parameters:

model – Model class

Return type:

shuup.admin.toolbar.NewActionButton|None

class shuup.admin.toolbar.JavaScriptActionButton(onclick, **kwargs)[source]

Bases: BaseActionButton

An action button that uses onclick for action dispatch.

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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ('btn', 'btn-default')
__init__(onclick, **kwargs)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render(request)[source]

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

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

Bases: BaseActionButton

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

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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

__init__(post_url=None, name=None, value=None, form_id=None, confirm=None, **kwargs)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render(request)[source]

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

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

Bases: BaseActionButton

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

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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ('btn', 'dropdown-toggle')
__init__(items, split_button=None, **kwargs)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render_dropdown(request)[source]
render(request)[source]

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

class shuup.admin.toolbar.DropdownItem(url='#', onclick=None, **kwargs)[source]

Bases: BaseActionButton

An item to be shown in a DropdownActionButton.

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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ()
__init__(url='#', onclick=None, **kwargs)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render(request)[source]

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

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.admin.toolbar.PostActionDropdownItem(**kwargs)[source]

Bases: PostActionButton

A POST action item to be shown in a DropdownActionButton.

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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ('dropdown-item', '')
__init__(**kwargs)[source]
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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

render(request)[source]

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

static visible_for_object(object)[source]

Used when dropdown item is added through provides

:return whether this item must be shown :rtype: bool

class shuup.admin.toolbar.DropdownDivider(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='', required_permissions=(), identifier=None)[source]

Bases: 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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ()
render(request)[source]

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

class shuup.admin.toolbar.DropdownHeader(text='', icon=None, disable_reason=None, tooltip=None, extra_css_class='', required_permissions=(), identifier=None)[source]

Bases: 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)

  • required_permissions (Iterable[str]) – Optional iterable of permission strings

base_css_classes = ()
render(request)[source]

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

class shuup.admin.toolbar.Toolbar(*args, **kwargs)[source]

Bases: list

Toolbar for admin views

Add buttons (subclasses of BaseActionButton) to the toolbar through toolbar.append(button) method.

A toolbar can be created for a given View using Toolbar.for_view(view_instance) class method. This method will create an empty toolbar and it will be populated using button providers that are loaded using provides. Views which have the toolbar_buttons_provider_key attribute indicate that buttons should be added to the toolbar using that provide key, e.g:

in your view.py: ``` class MyView(View):

toolbar_buttons_provider_key = ‘my_view_toolbar_provider_key’

```

in your apps.py: ``` class AppConfig(shuup.apps.AppConfig):

provides = {
“my_view_toolbar_provider_key”: [

“myapp.toolbar:MyViewToolbarButtonProvider”

]

}

```

in your toolbar.py: ``` class MyViewToolbarButtonProvider(BaseToolbarButtonProvider):

@classmethod def get_buttons_for_view(cls, view):

if getattr(view, “object”, None) and isinstance(view.object, Product):

yield JavaScriptActionButton(onclick=”window.doSomething()”, text=”Do Something”)

```

You can also provide buttons to the tollbar of any view using the admin_toolbar_button_provider provide key.

__init__(*args, **kwargs)[source]
render(request)[source]
render_to_string(request)[source]
classmethod for_view(view)[source]
shuup.admin.toolbar.try_reverse(viewname, **kwargs)[source]
shuup.admin.toolbar.get_discard_button(discard_url)[source]
shuup.admin.toolbar.get_save_as_copy_button(object, copy_url)[source]
shuup.admin.toolbar.get_default_edit_toolbar(view_object, save_form_id, discard_url=None, delete_url=None, copy_url=None, with_split_save=True, with_save_as_copy=False, toolbar=None, required_permissions=())[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

shuup.admin.urls module

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

Module contents

class shuup.admin.ShuupAdminAppConfig(*args, **kwargs)[source]

Bases: AppConfig

name = 'shuup.admin'
verbose_name = 'Shuup Admin'
label = 'shuup_admin'
required_installed_apps = ['bootstrap3']

Apps that are required to be in INSTALLED_APPS for this app

This may also be a dict of the form {app_name: reason} where the reason will then be listed in the ImproperlyConfigured exception.

provides = {'admin_attribute_form_part': ['shuup.admin.modules.attributes.form_parts.AttributeBaseFormPart', 'shuup.admin.modules.attributes.form_parts.AttributeChoiceOptionsFormPart'], 'admin_browser_config_provider': ['shuup.admin.browser_config:DefaultBrowserConfigProvider'], 'admin_contact_section': ['shuup.admin.modules.contacts.sections:BasicInfoContactSection', 'shuup.admin.modules.contacts.sections:AddressesContactSection', 'shuup.admin.modules.contacts.sections:OrdersContactSection', 'shuup.admin.modules.contacts.sections:MembersContactSection'], 'admin_model_url_resolver': ['shuup.admin.utils.urls.get_model_url'], 'admin_module': ['shuup.admin.modules.system:SystemModule', 'shuup.admin.modules.products:ProductModule', 'shuup.admin.modules.product_types:ProductTypeModule', 'shuup.admin.modules.media:MediaModule', 'shuup.admin.modules.orders:OrderModule', 'shuup.admin.modules.orders:OrderStatusModule', 'shuup.admin.modules.taxes:TaxModule', 'shuup.admin.modules.categories:CategoryModule', 'shuup.admin.modules.contacts:ContactModule', 'shuup.admin.modules.contact_groups:ContactGroupModule', 'shuup.admin.modules.contact_group_price_display:ContactGroupPriceDisplayModule', 'shuup.admin.modules.currencies:CurrencyModule', 'shuup.admin.modules.customers_dashboard:CustomersDashboardModule', 'shuup.admin.modules.permission_groups:PermissionGroupModule', 'shuup.admin.modules.users:UserModule', 'shuup.admin.modules.service_providers:ServiceProviderModule', 'shuup.admin.modules.services:PaymentMethodModule', 'shuup.admin.modules.services:ShippingMethodModule', 'shuup.admin.modules.attributes:AttributeModule', 'shuup.admin.modules.sales_units:DisplayUnitModule', 'shuup.admin.modules.sales_units:SalesUnitModule', 'shuup.admin.modules.sales_dashboard:SalesDashboardModule', 'shuup.admin.modules.shops:ShopModule', 'shuup.admin.modules.manufacturers:ManufacturerModule', 'shuup.admin.modules.suppliers:SupplierModule', 'shuup.admin.modules.support:ShuupSupportModule', 'shuup.admin.modules.settings.SettingsModule', 'shuup.admin.modules.labels:LabelsModule', 'shuup.admin.modules.menu:YourAdminMenuModule', 'shuup.admin.modules.menu:SuperUserAdminMenuModule', 'shuup.admin.modules.menu:StaffAdminMenuModule', 'shuup.admin.modules.menu:SupplierAdminMenuModule'], 'admin_object_selector': ['shuup.admin.modules.attributes.object_selector.AttributeAdminObjectSelector', 'shuup.admin.modules.categories.object_selector.CategoryAdminObjectSelector', 'shuup.admin.modules.contacts.object_selector.ContactAdminObjectSelector', 'shuup.admin.modules.contacts.object_selector.PersonContactAdminObjectSelector', 'shuup.admin.modules.contacts.object_selector.CompanyContactAdminObjectSelector', 'shuup.admin.modules.manufacturers.object_selector.ManufacturerAdminObjectSelector', 'shuup.admin.modules.permission_groups.object_selector.PermissionGroupAdminObjectSelector', 'shuup.admin.modules.product_types.object_selector.ProductTypeAdminObjectSelector', 'shuup.admin.modules.products.object_selector.ProductAdminObjectSelector', 'shuup.admin.modules.products.object_selector.ShopProductAdminObjectSelector', 'shuup.admin.modules.services.object_selector.CarrierAdminObjectSelector', 'shuup.admin.modules.services.object_selector.PaymentMethodAdminObjectSelector', 'shuup.admin.modules.services.object_selector.ShippingMethodAdminObjectSelector', 'shuup.admin.modules.shops.object_selector.ShopAdminObjectSelector', 'shuup.admin.modules.suppliers.object_selector.SupplierAdminObjectSelector', 'shuup.admin.modules.taxes.object_selector.CustomerTaxGroupAdminObjectSelector', 'shuup.admin.modules.taxes.object_selector.TaxAdminObjectSelector', 'shuup.admin.modules.taxes.object_selector.TaxClassAdminObjectSelector', 'shuup.admin.modules.users.object_selector.UserAdminObjectSelector'], 'admin_order_section': ['shuup.admin.modules.orders.sections:BasicDetailsOrderSection', 'shuup.admin.modules.orders.sections:PaymentOrderSection', 'shuup.admin.modules.orders.sections:LogEntriesOrderSection', 'shuup.admin.modules.orders.sections:ShipmentSection', 'shuup.admin.modules.orders.sections:AdminCommentSection', 'shuup.admin.modules.orders.sections:OrderHistorySection'], 'admin_order_toolbar_action_item': ['shuup.admin.modules.orders.toolbar:CreatePaymentAction', 'shuup.admin.modules.orders.toolbar:SetPaidAction', 'shuup.admin.modules.orders.toolbar:CreateRefundAction', 'shuup.admin.modules.orders.toolbar:EditAddresses'], 'admin_product_form_part': ['shuup.admin.modules.products.views.edit.ProductBaseFormPart', 'shuup.admin.modules.products.views.edit.ShopProductFormPart', 'shuup.admin.modules.products.views.edit.ProductAttributeFormPart', 'shuup.admin.modules.products.views.edit.ProductImageMediaFormPart', 'shuup.admin.modules.products.views.edit.ProductMediaFormPart'], 'admin_product_section': ['shuup.admin.modules.products.sections:ProductOrdersSection'], 'admin_shop_form_part': ['shuup.admin.modules.settings.form_parts.OrderConfigurationFormPart'], 'admin_supplier_form_part': ['shuup.admin.modules.suppliers.form_parts.SupplierBaseFormPart', 'shuup.admin.modules.suppliers.form_parts.SupplierContactAddressFormPart'], 'carrier_wizard_form_def': ['shuup.admin.modules.service_providers.wizard_form_defs:ManualShippingWizardFormDef'], 'payment_processor_wizard_form_def': ['shuup.admin.modules.service_providers.wizard_form_defs:ManualPaymentWizardFormDef'], 'service_behavior_component_form': ['shuup.admin.modules.services.forms:FixedCostBehaviorComponentForm', 'shuup.admin.modules.services.forms:WaivingCostBehaviorComponentForm', 'shuup.admin.modules.services.forms:WeightLimitsBehaviorComponentForm', 'shuup.admin.modules.services.forms:GroupAvailabilityBehaviorComponentForm', 'shuup.admin.modules.services.forms.StaffOnlyBehaviorComponentForm', 'shuup.admin.modules.services.forms.OrderTotalLimitBehaviorComponentForm', 'shuup.admin.modules.services.forms.CountryLimitBehaviorComponentForm'], 'service_behavior_component_form_part': ['shuup.admin.modules.services.weight_based_pricing.WeightBasedPricingFormPart'], 'service_provider_admin_form': ['shuup.admin.modules.service_providers.forms:CustomCarrierForm', 'shuup.admin.modules.service_providers.forms:CustomPaymentProcessorForm'], 'user_list_mass_actions_provider': ['shuup.admin.modules.users.mass_actions.UserMassActionProvider']}

See /provides for details about the provides variable.

ready()[source]

Override this method in subclasses to run code when Django starts.