fairdm.contrib.admin.views#

Superuser-only admin views, including fixture upload.

Module Contents#

Classes#

FixtureUploadForm

Form with a single field for the fixture file to load.

FixtureUploadView

Upload a fixture file and load it with loaddata.

Functions#

superuser_required

Restrict a view to active superusers.

get_full_extension

Return a filename’s extension, keeping a compression suffix with the one before it.

API#

superuser_required(view_func)[source]#

Restrict a view to active superusers.

Args: view_func: The view to protect.

Returns: The view wrapped so other users are sent to the login page.

class FixtureUploadForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)[source]#

Bases: django.forms.Form

Form with a single field for the fixture file to load.

Initialization

fixture_file#

‘FileField(…)’

get_full_extension(filename)[source]#

Return a filename’s extension, keeping a compression suffix with the one before it.

Args: filename: The uploaded file’s name.

Returns: The extension, for example .json.gz for data.json.gz.

class FixtureUploadView(**kwargs)[source]#

Bases: django.views.View

Upload a fixture file and load it with loaddata.

Initialization

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

template_name#

‘admin/fixture_upload_form.html’

get(request)[source]#

Render the empty upload form.

post(request)[source]#

Load the uploaded fixture and report success or the load error.