erecord_cmn package

Submodules

erecord_cmn.forms module

erecord_cmn.forms

Forms common to erecord applications

class erecord_cmn.forms.ErrorForm(*args, **kwargs)[source]

Bases: django.forms.forms.Form

Form dedicated to an error

base_fields = {'detail': <django.forms.fields.CharField object>, 'status': <django.forms.fields.IntegerField object>}
declared_fields = {'detail': <django.forms.fields.CharField object>, 'status': <django.forms.fields.IntegerField object>}
media
class erecord_cmn.forms.ReadonlyForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

Form with all fields readonly and in textarea

base_fields = {}
declared_fields = {}
media
class erecord_cmn.forms.TextAreasForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

Form with all fields in textarea

base_fields = {}
declared_fields = {}
make_readonly(name_field)[source]
media

erecord_cmn.models_mixins module

erecord_cmn.models_mixins

Mixins common to erecord applications models

class erecord_cmn.models_mixins.DefaultVerboseNameMixin[source]

Bases: object

additional to some models

set_default_value_verbose_name(verbose_name=None)[source]

set a default value to verbose_name if empty

erecord_cmn.renderers module

erecord_cmn.renderers

Renderers common to erecord applications

class erecord_cmn.renderers.CsvRenderer[source]

Bases: rest_framework.renderers.BaseRenderer

format = 'csv'
media_type = 'application/zip'
render(data, media_type=None, renderer_context=None)[source]
class erecord_cmn.renderers.PdfRenderer[source]

Bases: rest_framework.renderers.BaseRenderer

format = 'pdf'
media_type = 'application/zip'
render(data, media_type=None, renderer_context=None)[source]
class erecord_cmn.renderers.PlainTextRenderer[source]

Bases: rest_framework.renderers.BaseRenderer

format = 'txt'
media_type = 'text/plain'
render(data, media_type=None, renderer_context=None)[source]
class erecord_cmn.renderers.ZIPRenderer[source]

Bases: rest_framework.renderers.BaseRenderer

format = 'zip'
media_type = 'application/zip'
render(data, media_type=None, renderer_context=None)[source]

erecord_cmn.router module

erecord_cmn.router

Database router, for multiple databases case

class erecord_cmn.router.DatabaseRouter[source]

Bases: object

A router to control all database operations on models in an application.

DatabaseRouter is an abstract class, to be heritated by an application in multiple databases case. The child class defines db_name and app_name.

allow_migrate(db, model)[source]

Make sure the app_name app only appears in the db_name database.

allow_relation(obj1, obj2, **hints)[source]

Allow relations if a model in the app_name app is involved.

allow_syncdb(db, model)[source]

Make sure the app_name app only appears in the db_name database.

db_for_read(model, **hints)[source]

Attempts to read app_name models go to db_name.

db_for_write(model, **hints)[source]

Attempts to write app_name models go to db_name.

erecord_cmn.serializers module

erecord_cmn.serializers

Serializers common to erecord applications

class erecord_cmn.serializers.FormatOptionSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)[source]

Bases: rest_framework.serializers.Serializer

Option ‘format’

validate(attrs)[source]
class erecord_cmn.serializers.JwtOptionSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)[source]

Bases: rest_framework.serializers.Serializer

Option ‘jwt’ for JWT (JSON Web Token)

validate(attrs)[source]
erecord_cmn.serializers.getKeyOptionValues(data, key)[source]

returns list of values of key option

erecord_cmn.views module

erecord_cmn.views

erecord_cmn.views.onlinedoc_page(request)[source]

online documentation page

erecord_cmn.views_mixins module

erecord_cmn.views_mixins

Mixins common to erecord applications views

class erecord_cmn.views_mixins.DataFolderCopyViewMixin[source]

Bases: object

additional methods for views having datafoldercopy option

get_datafoldercopy_value(data)[source]

returns the datafoldercopy value according to data

datafoldercopy = replace, overwrite. Default value : replace.

class erecord_cmn.views_mixins.DataListViewMixin[source]

Bases: erecord_cmn.views_mixins.RenderViewMixin

additional methods for views returning a list of datas

get_renderers()[source]

indice 0 for ‘json’, 1 for ‘api’, 2 for ‘yaml’, 3 for ‘xml’ (and 4 for ‘html’ if defined later on)

class erecord_cmn.views_mixins.DataViewMixin[source]

Bases: object

additional methods for views managing both GET and POST requests

data_from_request(request)[source]
request_data(request)[source]
request_query_params(request)[source]
class erecord_cmn.views_mixins.DetailViewMixin[source]

Bases: erecord_cmn.views_mixins.RenderViewMixin

additional methods for views about detail

formats .html and .api, .json, .yaml, .xml

get_renderers()[source]

indice 0 for ‘json’, 1 for ‘api’, 2 for ‘yaml’, 3 for ‘xml’ (and 4 for ‘html’ if defined later on)

get_specific_renderers(template_name)[source]
class erecord_cmn.views_mixins.ErrorViewMixin[source]

Bases: object

additional methods for views returning error response

html_error_context(detail, status)[source]

builds and returns the html context relative to an error

class erecord_cmn.views_mixins.FormatViewMixin[source]

Bases: object

additional methods for views having format option

get_format_value(data)[source]

returns the format value found in data and else, None

class erecord_cmn.views_mixins.ListViewMixin[source]

Bases: erecord_cmn.views_mixins.RenderViewMixin

additional methods for views about list

formats .api, .html, .json, .yaml

get_renderers()[source]

indice 0 for ‘json’, 1 for ‘api’, 2 for ‘yaml’, 3 for ‘xml’ (and 4 for ‘html’ if defined later on)

class erecord_cmn.views_mixins.ModeOptionViewMixin[source]

Bases: object

additional methods for views having mode option

The ‘mode’ option is used for different choices. Some of them may not be available in some calling/view cases. Some may be incompatible each other.

The class has been completed in order to also accept some other intuitive option names : ‘style’, ‘plan’, ‘restype’.

@include erecord_cmn/docs/mode_option.txt (for more information, see the online documentation, main page)

get_bycol_value(data)[source]

returns the bycol value according to data

bycol = True, False. Default value : False.

get_mode_option_values(data)[source]

Option ‘mode’ (several values are possible)

Returns the list of mode option values.

The ‘mode’ option is used for different choices. Some of them may not be available in some calling/view cases. Some may be incompatible each other.

The method has been completed in order to also accept, instead of ‘mode’ name, some other intuitive option names : ‘style’, ‘plan’, ‘restype’.

get_plan_value(data)[source]

returns the plan value according to data

plan = single, linear. Default value : single.

get_restype_value(data)[source]

returns the restype value according to data

restype = dataframe, matrix. Default value : dataframe.

get_storage_value(data)[source]

returns the storage value according to data

storage = True, False. Default value : False.

get_todownload_value(data)[source]

returns the todownload value according to data

todownload = True, False. Default value : False.

class erecord_cmn.views_mixins.RenderViewMixin[source]

Bases: object

additional method about formats .api, .json, .yaml, .xml

get_renderers()[source]

indice 0 for ‘json’, 1 for ‘api’, 2 for ‘yaml’, 3 for ‘xml’ (and 4 for ‘html’ if defined later on)

class erecord_cmn.views_mixins.StyleViewMixin[source]

Bases: erecord_cmn.views_mixins.ModeOptionViewMixin

additional methods for views having style (in mode option)

style = tree or link

get_serializer_class_style(serializer_tree_class, serializer_link_class)[source]

returns the serializer class corresponding with style value

get_style_value()[source]

returns the style value according to data

style = tree or link. Default value : tree.

Module contents

erecord_cmn

This package is part of erecord - Record platform web development

copyright:Copyright (C) 2014-2015 INRA http://www.inra.fr.
license:GPLv3, see License for more details.
authors:see Authors.

Common application

The erecord_cmn common application contains resources for the other applications.

See erecord