Models

This is the documentation of NdrCore’s database models.

models.py contains ndr_core’s database models.

class ndr_core.models.NdrCoreApiConfiguration(*args, **kwargs)

An API configuration contains all necessary information to create a query to an API endpoint.

exception DoesNotExist
exception MultipleObjectsReturned
class Protocol(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Defines the protocol of the API configuration

HTTP = 1
HTTPS = 2
api_auth_key

An API might need an authentication key to function.

api_description

Description of this configuration.

api_host

The API host (domain only, e.g. my-api-host.org)

api_label

The API’s label is the title of the queried repository

api_name

This name is used as identifier for the API Can’t contain special characters or spaces

api_page_size

The query results will return a page of the results. You can define the page size

api_password

An API might need to authenticate a user with username/password credentials.

api_port

The TCP port of the API

api_protocol

The protocol used (http or https)

api_repository_url

URL to the repository’s website.

api_type

Refers to the API implementation used for this configuration.

api_type_id
api_url_stub

Static URL part after host, before API parameters.

api_user_name

An API might need to authenticate a user with username/password credentials.

get_api_protocol_display(*, field=<django.db.models.fields.PositiveSmallIntegerField: api_protocol>)
get_base_url()

Get the base URL for a configured API :return: base URL for a configured API

get_number_of_test_files()
get_test_files()
ndrcorecorrection_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

ndrcorefilterablelistconfiguration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

ndrcorepage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

ndrcoresearchconfiguration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

ndrcoresearchstatisticentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreApiImplementation(*args, **kwargs)

NDR Core has different API implementations to target different APIS. They are saved in this model.

exception DoesNotExist
exception MultipleObjectsReturned
description

Description of this implementation.

label

Display Label of the implementation.

name

Name of the API implementation. Used as identifier, can’t contain special characters.

ndrcoreapiconfiguration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
supports_advanced

True if the API supports a field based search where different search values can be searched for different fields.

supports_facets

True if the different values of a result are grouped in filter options.

supports_lists

True if the API supports static lists which can be requested by an API query.

supports_simple

True if the API supports a catch all search with a simple search term.

supports_simple_and_or

True if the API supports an AND and OR option for the simple search.

supports_single_result

True if a single result can be downloaded.

url

URL of API homepage or documentation.

class ndr_core.models.NdrCoreColorScheme(*args, **kwargs)

The NDR Core UI styles get colored with a certain color scheme. The selected scheme is used to create a colors.css stylesheet file in your ndr installation. It gets regenerated when you change the selected scheme.

exception DoesNotExist
exception MultipleObjectsReturned
accent_color_1

Accent color 1.

accent_color_2

Accent color 2.

background_color

Basic background color of the whole page.

button_border_color

Border color of primary buttons.

button_color

Background color of primary buttons.

button_hover_color

Hover color of primary buttons.

button_text_color

Text color of primary buttons.

static color_list()
container_bg_color

Basic container (cards, tables, etc.) color of the whole page.

error_color

Error color for alerts.

footer_bg

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

form_field_bg

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

form_field_fg

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

info_color

Info color for alerts.

Color for hrefs.

objects = <django.db.models.manager.Manager object>
scheme_label

Human readable label of the scheme

scheme_name

The name of the color scheme. For display and reference.

second_button_border_color

Border color of secondary buttons.

second_button_color

Basic color of secondary buttons.

second_button_hover_color

Hover color of secondary buttons.

second_button_text_color

Text color of secondary buttons.

success_color

Success color for alerts.

text_color

Basic text color for the whole page.

title_color

Title text color for the whole page.

class ndr_core.models.NdrCoreCorrectedField(*args, **kwargs)

TODO

exception DoesNotExist
exception MultipleObjectsReturned
field_name

TODO

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ndr_correction

TODO

ndr_correction_id
new_value

TODO

objects = <django.db.models.manager.Manager object>
old_value

TODO

class ndr_core.models.NdrCoreCorrection(*args, **kwargs)

Users can be given the opportunity to correct entries which have errors. Each correction can consist of multiple field corrections. Users need to provide an ORCID. This does not automatically correct data but administrators can accept or reject corrections.

exception DoesNotExist
exception MultipleObjectsReturned
corrected_dataset

TODO

corrected_dataset_id
corrected_record_id

TODO

corrector_orcid

TODO

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ndrcorecorrectedfield_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreDataSchema(*args, **kwargs)

NdrCore provides a number of already implemented schemas. For each schema it is known which search fields are possible so they can be generated automatically. Example: NdrCore has a ‘Historic Person Instances’ schema implemented for which we know we can search for last and given names, organization affiliation and locations (etc.). So we provide a django-fixture to automatically create these NdrCoreSearchField objects to use them in a search form. The list of available schemas is loaded when the management command ‘init_ndr_core’ is executed and can not be manipulated by users.

exception DoesNotExist
exception MultipleObjectsReturned
fixture_name

This is the filename of the fixture to load the search fields from. This contains only the file name which must be available in the ndr_core module in ‘ndr_core/fixtures/’

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
schema_label

This is a human readable label for the schema (e.g. its title)

schema_name

This is the name of the schema (e.g. its identifier within ndrCore)

schema_url

This is a stable URL of the implemented schema

class ndr_core.models.NdrCoreFilterableListConfiguration(*args, **kwargs)

TODO

exception DoesNotExist
exception MultipleObjectsReturned
api_configuration

TODO

api_configuration_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

list_name

TODO

ndrcorepage_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreImage(*args, **kwargs)

Directory of all images used outside the ckeditor and the logo.

exception DoesNotExist
class ImageGroup(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
BGS = 'backgrounds'
ELEMENTS = 'elements'
FIGURES = 'figures'
LOGOS = 'logos'
PEOPLE = 'people'
static get_label_by_value(group_value, choices)
exception MultipleObjectsReturned
caption

Caption of the image

citation

Source of the image

get_absolute_url()
get_image_group_display(*, field=<django.db.models.fields.CharField: image_group>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

image

Actual image

image_active

To indicate that this image is not to be used in automatic collections.

image_group

Group the image belongs to.

index_in_group

For ordering the images within the group.

ndrcoreuielementitem_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
title

Title of the image

url

URL to image or source

class ndr_core.models.NdrCorePage(*args, **kwargs)

An NdrCorePage is a web page on the ndr_core website instance. Each page has a type (see PageType) and upon creation, a HTML template is created and saved in the projects template folder. This allows users to create pages over the administration interface and then adapt its contents as needed.

exception DoesNotExist
exception MultipleObjectsReturned
class PageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Ndr Core can display multiple page types which are listed in this choice class

ABOUT_PAGE = 8

TODO

A combined search page contains both a simple and a configured search form which search the same repo.

CONTACT = 5

A contact from page displays a form to send a message to the project team

FILTER_LIST = 6

A filter list page shows a list of data which can be filtered down

FLIP_BOOK = 7

TODO

SEARCH = 3

A search page features a configured search form which contains a number of search fields

A simple search page is a page which contains a form with a single catch-all search field

TEMPLATE = 1

A template page is a static page. A HTML template is created which can be filled with any content

get_page_type_display(*, field=<django.db.models.fields.IntegerField: page_type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

index

The index determines the order the pages are displayed. 0 comes first (=most left)

label

This is the navigation label which is displayed in the navigation

list_configs

If the page is of the List type, a list configuration can be saved.

name

This is the name/title of the page. It will be displayed as a <h2>title</h2>

nav_icon

For the navigation, fontawesome icons can be displayed (e.g. ‘fas fa-home’)

ndrcorepage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
page_type

The page_type determines what kind of page is generated and what View is called (see PageType)

parent_page

Any NDR Core page might have children. Currently used for flip book. In the future to be used as navigation hierarchy.

parent_page_id
search_configs

If the page is of one of the search types (SEARCH, COMBINED_SEARCH), a number of search configurations can be saved.

simple_api

If the page is of type SIMPLE_SEARCH, a simple search configuration can be saved.

simple_api_id
template_text

Template Pages can be filled with RichText content (instead of ‘manual’ HTML).

url()

Returns the url of a given page or ‘#’ if none is found

view_name

The view_name is part of the page url in the form: https://yourdomain.org/p/view_name

class ndr_core.models.NdrCoreResultMapping(*args, **kwargs)

An NDR Core Result template mapping maps result jsons to html templates.

exception DoesNotExist
exception MultipleObjectsReturned
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ndrcoreresulttemplatefield_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreResultTemplateField(*args, **kwargs)

An NdrCoreResultTemplateField maps a json-result-value to a template-value

class Container(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
OPTIONS = 'options'
VALUE_LIST = 'values'
exception DoesNotExist
exception MultipleObjectsReturned
class Renderer(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
GEONAMES = 2
URL = 1
alternate_field_name

Field name of the raw search result json. Used if ‘source_field_name’ does not exist or its value is None.

belongs_to

TODO

belongs_to_id
field_container

TODO

field_label

TODO

field_none_value

Displayed value if both ‘source_field_name’ and ‘alternate_field_name’ are None.

field_renderer

TODO

get_field_container_display(*, field=<django.db.models.fields.CharField: field_container>)
get_field_renderer_display(*, field=<django.db.models.fields.IntegerField: field_renderer>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
source_field_name

Field name of the raw search result json. Nested objects are separated by ‘.’

target_field_name

Field name of the resulting structured response which is used to render a result line

class ndr_core.models.NdrCoreSearchConfiguration(*args, **kwargs)

A search configuration describes a configured search form which targets a specified API configuration.

exception DoesNotExist
exception MultipleObjectsReturned
api_configuration

The API to send the query to

api_configuration_id
conf_label

Name of the search configuration

conf_name

Name of the search configuration. Can’t contain spaces or special characters. Can’t be ‘simple’

static get_simple_search_mockup_config(api_configuration)

All search related functions expect a SearchConfiguration but the simple search only provides an ApiConfiguration. This returns a mockup config with the simple-search-api-configuration.

ndrcorepage_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
search_form_fields

Fields associated with this configuration

search_has_compact_result

If the result has a normal and a compact view, check this box.

class ndr_core.models.NdrCoreSearchField(*args, **kwargs)

A NdrCoreSearch field servers two purposes: First it can produce a HTML form field and second its information is used to formulate an API request.

exception DoesNotExist
class FieldType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

The FieldType of a searchField is used to render the HTML form

BOOLEAN = 5

This type produces a checkbox

DATE = 6

This type produces a date field

DATE_RANGE = 7

This type produces a date range field

HIDDEN = 9

This type produces a hidden field

INFO_TEXT = 10

This type produces a HTML component to show info text. This is not an input field

LIST = 3

This field produces a dropdown or multi select field

MULTI_LIST = 4

This field produces a multi select field

NUMBER = 2

This type produces a number field

NUMBER_RANGE = 8

This type produces a number range field

STRING = 1

This type produces a text field

exception MultipleObjectsReturned
api_parameter

The name of the API parameter which is used to generate a query

field_label

The field_label is the label for the HTML form field

field_name

The field_name is used as the HTML form name

field_required

Sets a field to ‘required’ which means it can’t be blank

field_type

Type of the form field. This translates to the HTML input type

get_field_type_display(*, field=<django.db.models.fields.PositiveSmallIntegerField: field_type>)
get_list_choices()
get_list_choices_as_dict()
help_text

The help text which will be displayed in the form

list_choices

Comma separated list of choices for dropdowns

lower_value

The lower value of a range field

ndrcoresearchfieldformconfiguration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
schema_name

If the search fields were created from a schema, this field gets filled out with the schema’s name. This helps to identify fields which were automatically created so they can be overwritten when they are regenerated from a schema

upper_value

The upper value of a range field

use_in_csv_export

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ndr_core.models.NdrCoreSearchFieldFormConfiguration(*args, **kwargs)

Search fields can be used in forms. In order to place them, they can be configured to fit in a grid with a NdrCoreSearchFieldFormConfiguration.

exception DoesNotExist
exception MultipleObjectsReturned
field_column

The column in the form. Is a value between 1 and 12

field_row

The row in the form. Starts with 1.

field_size

The size of the field. Is a value between 1 and 12

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ndrcoresearchconfiguration_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
search_field

The search field to place in a form

search_field_id
class ndr_core.models.NdrCoreSearchStatisticEntry(*args, **kwargs)

Every time a search is executed, a NdrCoreSearchStatisticEntry object is created if the setting ‘statistics_feature’ is set to ‘true’

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by_search_time(*, field=<django.db.models.fields.DateTimeField: search_time>, is_next=True, **kwargs)
get_previous_by_search_time(*, field=<django.db.models.fields.DateTimeField: search_time>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
search_api

The API which was queried in the search.

search_api_id
search_location

The location the user searched from.

search_no_results

TODO

search_query

TODO

search_term

The search term(s) which have been searched.

search_time

The time the user searched.

class ndr_core.models.NdrCoreUIElement(*args, **kwargs)

UI Element

exception DoesNotExist
exception MultipleObjectsReturned
class UIElementType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
BANNER = 'banner'
CARD = 'card'
CAROUSEL = 'carousel'
IFRAME = 'iframe'
JUMBOTRON = 'jumbotron'
SLIDESHOW = 'slides'
get_()
autoplay

TODO

get_absolute_url()
get_type_display(*, field=<django.db.models.fields.CharField: type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

items()

TODO

TODO

ndrcoreuielementitem_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
show_image

TODO

show_indicators

TODO

show_text

TODO

show_title

TODO

title

TODO

type

Type of the element. Decides how it is rendered.

use_image_conf

TODO

class ndr_core.models.NdrCoreUiElementItem(*args, **kwargs)

TODO

exception DoesNotExist
exception MultipleObjectsReturned
belongs_to

TODO

belongs_to_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ndr_image

TODO

ndr_image_id
objects = <django.db.models.manager.Manager object>
order_idx

TODO

text

TODO

title

TODO

url

TODO

class ndr_core.models.NdrCoreUiStyle(*args, **kwargs)

A NDR Core page is styled a certain way. Navigation may be on top or to the left, fonts may be different and so on. Each UI Style provides a base.html and (most probably) a css file.

exception DoesNotExist
exception MultipleObjectsReturned
description

Description of the style, highlighting its properties.

filename

Filename to save the base file and css with (no extension and no path information).

label

Human readable and descriptive label of the UI style.

name

Name of the style. Used as identifier.

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreUpload(id, title, file)
exception DoesNotExist
exception MultipleObjectsReturned
file

Actual file

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
title

Title of the upload

class ndr_core.models.NdrCoreUserMessage(*args, **kwargs)

If the contact form is sent, a user message object is created.

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by_message_time(*, field=<django.db.models.fields.DateTimeField: message_time>, is_next=True, **kwargs)
get_previous_by_message_time(*, field=<django.db.models.fields.DateTimeField: message_time>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

message_archived

Indicates if the message has been archived.

message_forwarded

Indicates if the messagge has been forwarded to a specified e-mail address.

message_ret_email

TODO

message_subject

TODO

message_text

TODO

message_time

TODO

objects = <django.db.models.manager.Manager object>
class ndr_core.models.NdrCoreValue(*args, **kwargs)

NdrCore provides a number of ready-to-use components which need to be configured with setting values. This data model stores these setting values. Example: A contact form has a subject field which can be prefilled with a string of choice. This string can be provided by this data model (value_name=’contact_form_default_subject’). The list of values is given and gets loaded from a fixture when the management command ‘init_ndr_core’ is executed. Users can only manipulate the ‘value_value’ of each object.

exception DoesNotExist
exception MultipleObjectsReturned
class ValueType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
BOOLEAN = 'boolean'
INTEGER = 'integer'
LIST = 'list'
STRING = 'string'
URL = 'url'
get_options()

For lists there are options, saved as string in the form: (key1,value1);(key2,value2)

static get_or_initialize(value_name, init_value=None, init_label=None, init_type=ValueType.STRING)

Returns or creates an NdrCoreValue object.

get_value()

Returns the valued which is always saved as string as the proper type.

get_value_type_display(*, field=<django.db.models.fields.CharField: value_type>)
is_user_value

Indicates if a value was created by a user

objects = <django.db.models.manager.Manager object>
set_value(value)
value_help_text

This is the help text for a value which explains to users what it is for

value_label

This is a human readable label for the value (e.g. its title)

value_name

This is the identifier of a NdrCoreValue. In the source, each value gets loaded by searching for this name

value_options

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

value_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

value_value

This is the actual value which can be updated by the user