Widgets
This part of the documentation covers all the reusable django-wildewidgets widgets provided by
django-sphinx-hosting.
Projects
These widgets are used on the project listing and details pages.
- class sphinx_hosting.wildewidgets.ClassifierFilterForm(table_name: str, column_number: int, **kwargs)[source]
The tree-like classifier filter form that appears to the right of the
sphinx_hosting.wildewidgets.project.ProjectTable. It is embedded inClassifierFilterBlock.It allows the user to select a set of classifiers by which to filter the projects listing table.
- __init__(table_name: str, column_number: int, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- add_subtree(contents: UnorderedList, nodes: dict[str, sphinx_hosting.models.ClassifierNode]) None[source]
Add a subtree of classifier checkboxes.
- Parameters:
contents – the
<ul>block to which to add our list of classifier checkboxes nodes (_type_): _description_nodes – the classifier nodes to add to the list. The key is the classifier id, and the value is the
ClassifierNodeinstance.
- get_checkbox(node: ClassifierNode) HorizontalLayoutBlock[source]
Build and return the
wildewidgets.CheckboxInputBlockfor the classifiernode.- Parameters:
node – the classifier data
- Returns:
A configured
wildewidgets.CheckboxInputBlock
- class sphinx_hosting.wildewidgets.ClassifierFilterBlock(table_name: str, column_number: int, **kwargs)[source]
A
wildewidgets.CardWidgetthat contains theClassifierFilterForm. This the right of thesphinx_hosting.wildewidgets.project.ProjectTable. This widget is embedded insphinx_hosting.wildewdigets.project.ProjectTableWidget- Parameters:
table_name – the name of the dataTables table to control
column_number – the number of the column in the dataTable that contains classifier names
- __init__(table_name: str, column_number: int, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.ProjectCreateModalWidget(*args, **kwargs)[source]
A modal dialog that holds the
sphinx_hosting.forms.ProjectCreateForm.- Parameters:
args – the arguments to pass to the modal widget
- Keyword Arguments:
kwargs – the keyword arguments to pass to the modal widget
- __init__(*args, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.ProjectDetailWidget(*blocks: Any, form: Form | None = None, **kwargs: Any)[source]
Renders an update form for a
sphinx_hosting.models.Project.Use directly it like so:
>>> project = Project.objects.get(pk=1) >>> form = ProjectUpdateForm(instance=project) >>> widget = ProjectDetailWidget(form=form)
Or you can simply add the form to your view context and
ProjectDetailWidgetwill pick it up automatically.
- class sphinx_hosting.wildewidgets.ProjectTableWidget(user: AbstractUser, **kwargs)[source]
A
wildewidgets.CardWidgetthat gives ourProjectTabledataTable a nice header with a total book count and an “Add Project” button that opens a modal dialog.- __init__(user: AbstractUser, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.ProjectVersionsTableWidget(project_id: int, **kwargs)[source]
A
wildewidgets.CardWidgetthat gives ourProjectVersionTabledataTable a nice header with a total version count.- __init__(project_id: int, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.ProjectTable(*args, actions: list[wildewidgets.widgets.tables.actions.RowActionButton] | None = None, button_size: str | None = None, justify: Literal['start', 'center', 'end'] | None = None, **kwargs)[source]
Displays a dataTable of our
sphinx_hosting.models.Projectinstances.It’s used as a the main widget in by
ProjectTableWidget.- filter_classifiers_column(qs: QuerySet, _: str, value: str) QuerySet[source]
Filter our results by the
value, a comma separated list ofsphinx_hosting.models.Classifiernames.- Parameters:
qs – the current
QuerySetcolunn – the name of the column to filter on
value – a comma-separated list of classifier names
- Returns:
A
QuerySetfiltered for rows that contain the selected classifiers.
- render_classifiers_column(row: Project, _: str) str[source]
Render our
classifierscolumn.- Parameters:
row – the
Projectwe are renderingcolunn – the name of the column to render
- Returns:
A
<br>separated list of classifier names
- render_latest_version_column(row: Project, _: str) str[source]
Render our
latest_versioncolumn. This is the version string of thesphinx_hosting.models.Versionthat has the most recentsphinx_hosting.models.Version.modifiedtimestamp.If there are not yet any
sphinx_hosting.models.Versioninstances for this project, return empty string.- Parameters:
row – the
Projectwe are renderingcolunn – the name of the column to render
- Returns:
The version string of the most recently published version, or empty string.
- render_latest_version_date_column(row: Project, _: str) str[source]
Render our
latest_version_datecolumn. This is the last modified date of thesphinx_hosting.models.Versionthat has the most recentsphinx_hosting.models.Version.modifiedtimestamp.If there are not yet any
sphinx_hosting.models.Versioninstances for this project, return empty string.- Parameters:
row – the
Projectwe are renderingcolunn – the name of the column to render
- Returns:
The of the most recently published version, or empty string.
- actions: Final[list[RowActionButton]] = [<sphinx_hosting.wildewidgets.project.LatestVersionButton object>, <wildewidgets.widgets.tables.actions.RowModelUrlButton object>, <wildewidgets.widgets.tables.actions.RowEditButton object>]
A list of
RowActionButtonsubclasses to display in the
- alignment: Final[dict[str, str]] = {'classifiers': 'left', 'description': 'left', 'latest_version': 'left', 'latest_version_date': 'left', 'machine_name': 'left', 'title': 'left'}
- fields: Final[list[str]] = ['title', 'machine_name', 'classifiers', 'latest_version', 'description', 'latest_version_date']
A list of fields that we will list as columns. These are either fields on our
model, or defined asrender_FIELD_NAME_columnmethods
- unsearchable: Final[list[str]] = ['classifiers', 'latest_version', 'latest_version_date']
A list of names of columns that will will not be searched when doing a
- class sphinx_hosting.wildewidgets.ProjectVersionTable(*args, **kwargs)[source]
Displays a dataTable of our
sphinx_hosting.models.Versioninstances for a particularsphinx_hosting.models.Project.It’s used as a the main widget in by
ProjectVersionTableWidget.- __init__(*args, **kwargs) None[source]
One of our
kwargsmust beproject_id, thepkof thesphinx_hosting.models.Projectfor which we want to listsphinx_hosting.models.Versionobjects.This will get added to the
extra_datadict in thekwargskey, from which we reference it.
- get_initial_queryset() QuerySet[Version][source]
Filter our
sphinx_hosting.models.Versionobjects byproject_id.- Returns:
A filtered
QuerySetonsphinx_hosting.models.Version
- render_num_images_column(row: Version, _: str) str[source]
Render our
num_imagescolumn. This is the number ofsphinx_hosting.models.SphinxImageobjects imported for this version.- Parameters:
row – the
Versionwe are renderingcolunn – the name of the column to render
- Returns:
The number of images for this version.
- render_num_pages_column(row: Version, _: str) str[source]
Render our
num_pagescolumn. This is the number ofsphinx_hosting.models.SphinxPageobjects imported for this version.- Parameters:
row – the
Versionwe are renderingcolunn – the name of the column to render
- Returns:
The number of pages for this version.
- actions: bool = True
Per row action buttons. If not
False, this will simply add a rightmost column namedActionswith a button nameddefault_action_button_labelwhich when clicked will take the
- alignment: Final[dict[str, str]] = {'created': 'left', 'modified': 'left', 'num_images': 'right', 'num_pages': 'right', 'version': 'left'}
- fields: Final[list[str]] = ['version', 'num_pages', 'num_images', 'created', 'modified']
A list of fields that we will list as columns. These are either fields on our
model, or defined asrender_FIELD_NAME_columnmethods
- project_id: int | None
The pk of the
sphinx_hosting.models.Projectfor which to
Search
These widgets are used on the search results page.
- class sphinx_hosting.wildewidgets.GlobalSearchFormWidget(*args, **kwargs)[source]
Encapsulates the
sphinx_hosting.forms.GlobalSearchForm.- __init__(*args, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.PagedSearchLayout(results: SearchQuerySet, query: str | None = None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
The page layout for the entire search results page.
- Parameters:
query – the text entered into the search form that got us to this results page
- Keyword Arguments:
query – the text entered into the search form that got us to this results page
facets – the active facet filters. This will be a dict where the key is the facet name, and the value is a list of facet values to filter by.
- __init__(results: SearchQuerySet, query: str | None = None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SearchResultsPageHeader(query: str | None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
The header for the entire search results page. This shows the search string that got us here, and any active facet filters, allowing the user to remove any active filter by clicking the “X” next to the filter name.
- Parameters:
query – the text entered into the search form that got us to this results page
- Keyword Arguments:
facets – the active facet filters. This will be a dict where the key is the facet name, and the value is a list of facet values to filter by.
- __init__(query: str | None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.FacetBlock(results: SearchQuerySet, query: str | None, **kwargs)[source]
Base class for blocks that appear to the right of the search results listing on the search results page that allows you to refine your results by a particular facet that is present in the result set.
Subclass this to create facet filtering blocks for specific facets. Any facet you want to filter by must be defined on your search index by adding
faceted=Trueto the field definition.- Parameters:
results – the Haystack search queryset containing our search results
query – the text entered into the search form that got us to this results page
- __init__(results: SearchQuerySet, query: str | None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- model: type[django.db.models.Model]
- class sphinx_hosting.wildewidgets.SearchResultsClassifiersFacet(results: SearchQuerySet, query: str | None, **kwargs)[source]
A
FacetBlockthat allows the user to filter search results by classifier.- model
alias of
Classifier
- class sphinx_hosting.wildewidgets.SearchResultsProjectFacet(results: SearchQuerySet, query: str | None, **kwargs)[source]
A
FacetBlockthat allows the user to filter search results by project.
- class sphinx_hosting.wildewidgets.PagedSearchResultsBlock(results: SearchQuerySet, query: str | None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
Paged listing of
SearchResultBlockentries describing our search results.- Parameters:
results – the Haystack search queryset containing our search results
query – the text entered into the search form that got us to this results
page –
- Keyword Arguments:
facets – a dictionary of facet names to lists of facet values that were selected on the search results page
- model_widget
alias of
SearchResultBlock
- __init__(results: SearchQuerySet, query: str | None, facets: dict[str, list[str]] | None = None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SearchResultsHeader(results: SearchQuerySet, **kwargs)[source]
The header for the search results listing (not the page header – that is
SearchResultsPageHeader).- Parameters:
results – the Haystack search queryset containing our search results
- __init__(results: SearchQuerySet, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- justify: str = 'between'
How to align items horizontally within this widget. Valid choices:
start, :center,end,between,around,evenly. See Bootstrap: Flex, justify content. If not supplied here andjustifyisNone, do whatever
- class sphinx_hosting.wildewidgets.SearchResultBlock(object: SearchResult = None, **kwargs)[source]
Block we use for rendering a particular search result on the search results page.
- Keyword Arguments:
object – the
haystack.models.SearchResultobject to render
- class Header(result: SearchResult, **kwargs)[source]
- __init__(result: SearchResult, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- __init__(object: SearchResult = None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
Versions
- class sphinx_hosting.wildewidgets.VersionInfoWidget(version: Version, **kwargs)[source]
Gives a
wildewidget.Datagridtype overview of information about this version:A link to the project that owns this
sphinx_hosting.models.VersionCreate and last modified timestamps
What version of Sphinx was used to generate the pages
- Parameters:
version – the
Versionobject we’re describing
- __init__(version: Version, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.VersionSphinxPageTableWidget(version_id: int, **kwargs)[source]
A
wildewidgets.CardWidgetthat gives ourVersionSphinxPageTabledataTable a nice header with a total page count.- __init__(version_id: int, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.VersionUploadBlock(*blocks, form=None, **kwargs)[source]
Holds the upload form for uploading documentation tarballs. Once uploaded, the tarball will be run through
sphinx_hosting.importers.SphinxPackageImporterto actually import it into the database.- __init__(*blocks, form=None, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.VersionSphinxImageTableWidget(version_id: int, **kwargs)[source]
A
wildewidgets.CardWidgetthat gives ourVersionSphinxImageTabledataTable a nice header with a total image count.- __init__(version_id: int, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.VersionSphinxPageTable(*args, **kwargs)[source]
Displays a dataTable of our
sphinx_hosting.models.SphinxPageinstances for a particularsphinx_hosting.models.Version.It’s used as a the main widget in by
VersionSphinxPageTableWidget.- model
alias of
SphinxPage
- __init__(*args, **kwargs) None[source]
One of our
kwargsmust beversion_id, thepkof thesphinx_hosting.models.Versionfor which we want to listsphinx_hosting.models.SphinxPageobjects.This will get added to the
extra_datadict in thekwargskey, from which we reference it.
- get_initial_queryset() QuerySet[source]
Filter our
sphinx_hosting.models.SphinxPageobjects byversion_id.
- actions: bool = True
Per row action buttons. If not
False, this will simply add a rightmost column namedActionswith a button nameddefault_action_button_labelwhich when clicked will take the
- fields: Final[list[str]] = ['title', 'relative_path', 'size']
These are the fields on our model (or which are computed) that we will
- version_id: int | None
The pk of the
sphinx_hosting.models.Versionfor which to
- class sphinx_hosting.wildewidgets.VersionSphinxImageTable(*args, **kwargs)[source]
Displays a dataTable of our
sphinx_hosting.models.SphinxImageinstances for a particularsphinx_hosting.models.Version.It’s used as a the main widget in by
VersionSphinxImageTableWidget.- model
alias of
SphinxImage
- __init__(*args, **kwargs) None[source]
One of our
kwargsmust beversion_id, thepkof thesphinx_hosting.models.Versionfor which we want to listsphinx_hosting.models.SphinxPageobjects.This will get added to the
extra_datadict in thekwargskey, from which we reference it.
- get_initial_queryset() QuerySet[source]
Filter our
sphinx_hosting.models.SphinxPageobjects byversion_id.
- render_file_path_column(row: Version, _: str) str[source]
Render our
file_pathcolumn. This is the path to the file inMEDIA_ROOT.- Parameters:
row – the
Versionwe are renderingcolunn – the name of the column to render
- Returns:
The size in bytes of the uploaded file.
- render_size_column(row: Version, _: str) str[source]
Render our
sizecolumn. This is the size in bytes of thesphinx_hosting.models.SphinxImage.filefield.- Parameters:
row – the
Versionwe are renderingcolunn – the name of the column to render
- Returns:
The size in bytes of the uploaded file.
- fields: Final[list[str]] = ['orig_path', 'file_path', 'size']
These are the fields on our model (or which are computed) that we will
- version_id: int | None
The pk of the
sphinx_hosting.models.Versionfor which to
Sphinx Pages
- class sphinx_hosting.wildewidgets.SphinxPageGlobalTableOfContentsMenu(*items: MenuItem, title: str | None = None, title_tag: str | None = None, title_css_classes: str | None = None, **kwargs)[source]
The version-specific navigation menu that gets inserted into the page sidebar when viewing the documentation for a
sphinx_hosting.models.Version. It will appear on all pages for that version.- classmethod parse_obj(version: Version) SphinxPageGlobalTableOfContentsMenu[source]
Parse the globaltoc of a
sphinx_hosting.models.Versioninto awildewidgets.Menusuitable for insertion into awildewidgets.NavbarThe
sphinx_hosting.models.Version.globaltocis a dict that looks like this:{ items: [ {'text': 'foo'}, {'text': 'bar', 'url': '/foo', 'icon': 'blah'} {'text': 'bar', 'url': '/foo', 'icon': 'blah', items: [{'text': 'blah' ...} ...]} ... ] }
- Parameters:
version – the
Versionfor which we are building the menu- Returns:
A configured
SphinxPageGlobalTableOfContentsMenu.
- class sphinx_hosting.wildewidgets.SphinxPageLayout(page: SphinxPage, **kwargs)[source]
The page layout for a single
sphinx_hosting.models.SphinxPage. It consists of a two column layout with the page’s table of contents in the left column, and the content of the page in the right column.- Parameters:
page – the
SphinxPageto render
- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SphinxPagePagination(page: SphinxPage, **kwargs)[source]
Draws the “Previous Page”, Parent Page and Next Page buttons that are found at the top of each
sphinx_hosting.views.SphinxPageDetailView.It is built out of a Tabler/Bootstrap
row, with each of the buttons in an equal sizedcol.- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SphinxPageTitle(page: SphinxPage, **kwargs)[source]
The title block for a
sphinx_hosting.models.SphinxPagepage.- Parameters:
page – the
SphinxPageto render
- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SphinxPagePermalinkWidget(page: SphinxPage, **kwargs)[source]
Draws the “Permalink” button that is found at the top of the right-hand column of each
sphinx_hosting.views.SphinxPageDetailView.- Parameters:
page – the
SphinxPagewe are rendering
- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SphinxPageBodyWidget(page: SphinxPage, **kwargs)[source]
The body of the page. The body as stored in the model is actually a Django template, so we retrieve the body, run it through the Django template engine, and display the results.
- Parameters:
page – the
SphinxPagewe are rendering
- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.
- class sphinx_hosting.wildewidgets.SphinxPageTableOfContentsWidget(page: SphinxPage, **kwargs)[source]
Draws the in-page navigation – the header hierarchy.
- Parameters:
page – the
SphinxPagewe are rendering
- __init__(page: SphinxPage, **kwargs)[source]
Initialize a new Widget instance.
- Parameters:
*args – Variable length argument list passed to parent.
- Keyword Arguments:
title – Optional title to display with the widget.
icon – Optional icon identifier to use for this widget.
**kwargs – Arbitrary keyword arguments passed to parent.