Database Viewer Package¶
The db_viewer package defines the resources necessary to enable the backend TerraNexus database to be exposed, queried and updated by the user directly through the TerraNexus Web Application.
Database Viewer Submodules¶
The following submodules are defined by this package.
db_viewer.apps module¶
Note
Module Details
Database Viewer Application Registration module
This Class module is required to register each Django package under the main web application.
Created: 19 January 2020
@author: Dr. Matthew B.J. Purss
db_viewer.forms module¶
Note
Module Details
Database Viewer “Django Forms” Definition Module
This module contains the “Form” definition for the Database Management/Query Interface.
Created: 19 January 2020
@author: Dr. Matthew B.J. Purss
- class src.db_viewer.forms.DBForm(*args, request=None, mongo_query='{}', query_text_cols='40', query_text_rows='10', timespan='---', rows_per_page=25, **kwargs)¶
Bases:
Form
Note
Class Details
Form definition for the database viewer interface Class.
- Parameters:
request (request-object) – The Django html request object this Form will be attached to.
mongo_query (JSON) – JSON string containing the mongodb query to populate the query_text textarea widget with. The mongo_query is the query that is sent to the TerraNexus database when this Form is executed via a POST request.
query_text_cols (string) – User Interface configuration for the query_text textarea widget. This parameter sets the number of columns (i.e. characters to display across the page) to initialise the query_text textarea horizontal size on the page.
query_text_rows (string) – User Interface configuration for the query_text textarea widget. This parameter sets the number of rows to initialise the query_text textarea vertical size on the page.
timespan (string) – The time limit to filter database query results.
rows_per_page (int) – The number of rows per page to display database query results.
- base_fields = {'db_data_file': <django.forms.fields.FileField object>, 'db_filetype_comboBox': <django.forms.fields.ChoiceField object>, 'db_operation_type_comboBox': <django.forms.fields.ChoiceField object>, 'db_query_number_of_records_per_page_comboBox': <django.forms.fields.ChoiceField object>, 'db_query_timespan_comboBox': <django.forms.fields.ChoiceField object>, 'query_text': <django.forms.fields.CharField object>}¶
- clean()¶
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- declared_fields = {'db_data_file': <django.forms.fields.FileField object>, 'db_filetype_comboBox': <django.forms.fields.ChoiceField object>, 'db_operation_type_comboBox': <django.forms.fields.ChoiceField object>, 'db_query_number_of_records_per_page_comboBox': <django.forms.fields.ChoiceField object>, 'db_query_timespan_comboBox': <django.forms.fields.ChoiceField object>, 'query_text': <django.forms.fields.CharField object>}¶
- error_css_class = 'error'¶
- property media¶
Return all media required to render the widgets on this form.
- required_css_class = 'required'¶
db_viewer.urls module¶
Note
Module Details
Database Viewer “URL” Configuration
The urlpatterns list routes URLs to views for the db_viewer package. For more information please see: Django Documentation - urls
Created: 7 September 2017
@author: Dr. Matthew B.J. Purss
db_viewer.views module¶
Note
Module Details
Database Viewer “Views” module
This module prepares the views necessary to perform all tasks relevant to Database Management and Data Viewing.
Created: 7 September 2017
@author: Dr. Matthew B.J. Purss
- src.db_viewer.views.db_backup(request)¶
Note
Function Details
Function to backup the selected database(s) and/or table(s).
- Parameters:
request (request-object) – The html request object.
- src.db_viewer.views.db_delete(request, *args, **kwargs)¶
Note
Function Details
Function to delete the selected database table(s).
- Parameters:
request (request-object) – The html request object.
- src.db_viewer.views.db_load(request)¶
Note
Function Details
Function to load the selected database table(s).
- Parameters:
request (request-object) – The html request object.
- src.db_viewer.views.db_results(request, page=1)¶
Note
Function Details
Function to show the results from the data query. the selected database table(s).
- Parameters:
request (request-object) – The html request object.
page (int, optional) – The page of a multipage database request - used to break the resultset up into into chunks that will make it easier to view.
- src.db_viewer.views.db_viewer(request, *args, **kwargs)¶
Note
Function Details
Database Viewer base view.
- requestrequest-object
The html request object.
#=============================================================================== # @permission_classes((permissions.IsAuthenticatedOrReadOnly,)) #=============================================================================== #=============================================================================== # @permission_classes((permissions.IsAuthenticated,)) #=============================================================================== #=============================================================================== # @authentication_classes((authentication.SessionAuthentication, # authentication.BasicAuthentication, # authentication.TokenAuthentication)) # @rest_login_required(login_url=’user:login’) #===============================================================================