physics_workload.app.models.common¶
Attributes¶
Classes¶
Contains the framework for a DB model to have an icon and title associated with it |
Module Contents¶
- physics_workload.app.models.common.User¶
- class physics_workload.app.models.common.ModelCommon(*args, **kwargs)¶
Bases:
django.db.models.ModelContains the framework for a DB model to have an icon and title associated with it
Classes implement icon (a font-awesome icon name) and url_root (the Django URL resolver root for that model).
- history¶
- property icon: str¶
- Abstractmethod:
The icon shown on the list views e.t.c.
- Type:
return
- property url_root: str¶
- Abstractmethod:
The root of the URLs for this model, to which _detail, _edit e.t.c. will be added
- Type:
return
- get_absolute_url() str¶
- Returns:
The URL for the detail view of this particular instance of the model
- abstractmethod get_absolute_url_if_permitted(user: User) str¶
- Parameters:
user – The user to check authorisation for.
- Returns:
The absolute URL for the detail view of this particular instance of the model if allowed, or blank.
- get_instance_header(text: str | None = None) str¶
Creates a header for a view for an instance of this model. :param text: The text to use for the header, if not just the string representation of the instance. :return: The rendered template, for use on the page.
- classmethod get_model_url() str¶
Equivalent to get_absolute_url() for model list. :return: The URL for the view listing all of this model
- classmethod get_model_header() str¶
Creates a header for the view listing all of this model. :return: The rendered template, for use on the page.
- classmethod get_model_header_singular() str¶
Creates a header for a create view for this model. :return: The rendered template, for use on the page.