Brain admin
This page lists the classes and methods used to administer the ‘Brain’ app in our database portal. This is where the end user can create, retrieve, update and delete (CRUD) metadata associated with the ‘Brain’ app. It does not list the fields (database columns). Look in the models document for the database table model.
- class brain.admin.AnimalAdmin(model, admin_site)
This class is used to administer the animal. It includes all the metadata entered by the user. The animal class is often used as a key in another table.
- class brain.admin.AtlasAdminModel(model, admin_site)
This is used as a base class for most of the other classes. It contains all the common variables that all the tables/objects have. It inherits from the Django base admin model: admin.ModelAdmin
- class Media
This is a simple class that defines some CSS attributes for the thumbnails
- formfield_for_foreignkey(db_field, request, **kwargs)
Simple formatting for foreign keys
- Parameters
db_field – data row field
request – http request
kwargs – extra args
- Returns
the HTML of the form field
- is_active(instance)
A method returning a boolean showing if the data row is active
- Parameters
instance – obj class
- Returns
A boolean
- class brain.admin.ExportCsvMixin
A class used by most of the admin categories. It adds formatting to make fields look consistent and also adds the method to export to CSV from each of the ‘Action’ dropdowns in each category.
- export_as_csv(request, queryset)
Set the callback function to be executed when the device sends a notification to the client.
- Parameters
request – The http request
queryset – The query used to fetch the CSV data
- Returns
a http response
- class brain.admin.HistologyAdmin(model, admin_site)
A class to administer the histology of each animal
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- class brain.admin.InjectionAdmin(model, admin_site)
A class to describe the injections (if any) for each animal. Each animal can have multiple injections.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- class brain.admin.InjectionVirusAdmin(model, admin_site)
This class describes a many to many relationship between the virus and the injection classes. An animal can multiple injections, with each injection having one or more viruses.
- Inheritance
- AtlasAdminModel
The base admin model
- injection_comments(instance)
This gives the description from the injection foreign key
- Parameters
instance – the obj
- Returns
a string that contains the comments
- prep_id(instance)
This returns the animal name (string) used as a foreign key in this class.
- Parameters
instance – the obj
- Returns
the prep_id (AKA the animal name) as a string
- virus_name(instance)
Gives the description from the virus foreign key
- Parameters
instance – the obj
- class brain.admin.LogEntryAdmin(model, admin_site)
This class describes the log objects used during the preprocessing pipeline
- Inheritance
- admin.ModelAdmin
the base Django admin obj
- has_add_permission(request)
This data is added by the preprocessing pipeline so can’t be changed here
- Parameters
request – http request
- Returns
False
- has_change_permission(request, obj=None)
This data is added by the preprocessing pipeline so can’t be changed here
- Parameters
request – http request
obj – the LogEntry obj
- Returns
False
- has_delete_permission(request, obj=None)
This data is added by the preprocessing pipeline so can’t be deleted here
- Parameters
request – http request
obj – the LogEntry obj
- Returns
False
- has_view_permission(request, obj=None)
This data can only be viewed by a superuser
- Parameters
request – http request
obj – the LogEntry obj
- Returns
boolean depending on if the user is a super user or not
- class brain.admin.OrganicLabelAdmin(model, admin_site)
Description of OrganicLabelAdmin This class describes the organice label for an animal. So far, it has had no data entered in it.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- class brain.admin.ScanRunAdmin(model, admin_site)
This class describes what occurs when the slides are actually scanned. Many of the attributes from this class are used throughout the preprocessing An animal can have multiple scan runs, but usually, there is just one scanning done for each animal.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- class brain.admin.SectionAdmin(model, admin_site)
This class describes the Section methods and attributes. Sections come from a view and not a table so it needs to be handled a bit differently.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- class Media
- changelist_view(request, extra_context=None)
The ‘change list’ admin view for this model.
- get_queryset(request, obj=None)
Description of get_queryset - the query starts out with an empty qeuryset ‘prep_id=XXXX’ so the initial page is empty and the user is forced to select one and only one animal. The order is descided upon whether the brain was section from left to right, or right to left. This comes from the histology table: side_sectioned_first
- Parameters
request – http request
obj – section obj
- Returns
the queryset ordered correctly
- has_add_permission(request, obj=None)
The add button is not shown as sections are a view and they can’t be added to.
- Parameters
request – http request
obj – the section obj
- Returns
False
- has_change_permission(request, obj=None)
The edit button is not shown as sections are a view and they can’t be changed.
- Parameters
request – http request
obj – the section obj
- Returns
False
- has_delete_permission(request, obj=None)
The add button is not shown as sections are a view and they can’t be added to.
- Parameters
request – http request
obj – the section obj
- Returns
False
- list_display_links = None
- section_number(instance)
Description of section_number - this is just an ordered query, so to get the section number, we just use an incrementor
- Parameters
instance – section obj
- class brain.admin.SlideAdmin(model, admin_site)
This class describes the admin area for a particular slide. This is used in the QA process and includes the inline TIFF files in the QA form.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- get_fields(request, obj)
This method fetches the correct number of inline TIFF files that are used in the QA form.
- Parameters
request – http request
obj – the TIFF obj
- Returns
HTML of the fields
- has_add_permission(request, obj=None)
Cannot show or use the add button at this stage
- Parameters
request – http request
obj – the TIFF obj
- Returns
False
- has_delete_permission(request, obj=None)
Cannot show or use the delete button at this stage.
- Parameters
request – http request
obj – the slide obj
- Returns
False
- prep_id(instance)
Returns the animal name that the slide belongs to
- Parameters
instance – the TIFF obj
- Returns
False
- response_change(request, obj)
Reset all tifs belong to this slide to its original state
- save_model(request, obj, form, change)
Description of save_model - overridden method of the save method. When the user changes the scenes via the QA form, the usual save isn’t sufficient so we override it.
- Parameters
self – the admin slide obj
request – the http request
obj – the slide obj
form – the form obj
change – if the form has changed or not.
- scene_count(obj)
Determines how many scenes are there for a slide
- Parameters
obj – the slide obj
- Returns
an integer of the number of scenes
- class brain.admin.SlideCziToTifAdmin(model, admin_site)
A class to administer the individual scene, AKA the TIFF file.
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.
- has_add_permission(request, obj=None)
Cannot show or use the add button at this stage
- Parameters
request – http request
obj – the TIFF obj
- Returns
False
- has_delete_permission(request, obj=None)
Cannot show or use the delete button at this stage
- Parameters
request – http request
obj – the TIFF obj
- Returns
False
- class brain.admin.TifInline(parent_model, admin_site)
This class is solely used for the database QA. It will display the associated TIFF files for each slide on the slide page.
- Inheritance
- admin.TabularInline
The class that describes how the data is laid out on the page.
- formset
alias of
TifInlineFormset
- get_formset(request, obj=None, **kwargs)
Description of get_formset - sets up the form for the set of TIFF files for each slide
- Parameters
request – http request
obj – the TIFF obj
kwargs – extra args
- Returns
the HTML of the formset
- get_queryset(request)
Description of get_queryset - returns just the first channel for each slide. We only need to look at the first channel for QA purposes.
- Parameters
obj – the TIFF obj
- Returns
a query set
- has_add_permission(request, obj=None)
TIFF files cannot be added at this stage.
- Parameters
request – http request
obj – the TIFF obj
- Returns
False
- has_change_permission(request, obj=None)
TIFF files can be edited at this stage.
- Parameters
request – http request
obj – the TIFF obj
- Returns
True
- model
alias of
SlideCziToTif
- scene_image(obj)
This method tests if there is a PNG file for each scene, and if so, shows it on the QA page for each slide. This is very helpful when the user must decide if the TIFF file is usable.
- Parameters
obj – the TIFF obj
- Returns
HTML that displays a link to the scene PNG file
- section_image(obj)
This method shows the TIFF image as a PNG later on in the QA process after it has been cleaned and aligned.
- Parameters
obj – the TIFF obj
- Returns
HTML that displays a link to the scene PNG file
- class brain.admin.VirusAdmin(model, admin_site)
A class used to describe a virus. This class can then be a foreign key into the Injection class
- Inheritance
- AtlasAdminModel
The base admin model
- ExportCsvMixin
The class with standard features and CSV exporter method.