Submission¶
Models for the HEPData Submission Workflow. |
|
hepdata.modules.submission.admin¶
- class hepdata.modules.submission.admin.HEPSubmissionAdminView(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]¶
HEPSubmissionAdminView view.
- can_view_details = True¶
Setting this to true will enable the details view. This is recommended when there are too many columns to display in the list_view.
- can_delete = False¶
Is model deletion allowed
- column_list = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
Collection of the model field names for the list view. If set to None, will get them from the model.
For example:
class MyModelView(BaseModelView): column_list = ('name', 'last_name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): column_list = ('name', User.last_name)
- When using SQLAlchemy models, you can reference related columns like this::
- class MyModelView(BaseModelView):
column_list = (‘<relationship>.<related column name>’,)
- form_columns = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
Collection of the model field names for the form. If set to None will get them from the model.
Example:
class MyModelView(BaseModelView): form_columns = ('name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): form_columns = ('name', User.last_name)
SQLA Note: Model attributes must be on the same model as your ModelView or you will need to use inline_models.
- column_searchable_list = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
Collection of the searchable columns.
Example:
class MyModelView(ModelView): column_searchable_list = ('name', 'email')
You can also pass columns:
class MyModelView(ModelView): column_searchable_list = (User.name, User.email)
The following search rules apply:
If you enter
ZZZ
in the UI search field, it will generateILIKE '%ZZZ%'
statement against searchable columns.If you enter multiple words, each word will be searched separately, but only rows that contain all words will be displayed. For example, searching for
abc def
will find all rows that containabc
anddef
in one or more columns.If you prefix your search term with
^
, it will find all rows that start with^
. So, if you entered^ZZZ
thenILIKE 'ZZZ%'
will be used.If you prefix your search term with
=
, it will perform an exact match. For example, if you entered=ZZZ
, the statementILIKE 'ZZZ'
will be used.
- column_filters = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
Collection of the column filters.
Can contain either field names or instances of
flask_admin.contrib.sqla.filters.BaseSQLAFilter
classes.Filters will be grouped by name when displayed in the drop-down.
For example:
class MyModelView(BaseModelView): column_filters = ('user', 'email')
or:
from flask_admin.contrib.sqla.filters import BooleanEqualFilter class MyModelView(BaseModelView): column_filters = (BooleanEqualFilter(column=User.name, name='Name'),)
or:
from flask_admin.contrib.sqla.filters import BaseSQLAFilter class FilterLastNameBrown(BaseSQLAFilter): def apply(self, query, value, alias=None): if value == '1': return query.filter(self.column == "Brown") else: return query.filter(self.column != "Brown") def operation(self): return 'is Brown' class MyModelView(BaseModelView): column_filters = [ FilterLastNameBrown( User.last_name, 'Last Name', options=(('1', 'Yes'), ('0', 'No')) ) ]
- column_details_list = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
Collection of the field names included in the details view. If set to None, will get them from the model.
- columns_sortable_list = ('id', 'publication_recid', 'overall_status', 'coordinator', 'doi', 'version')¶
- column_labels = {'_displayname': 'Display Name'}¶
Dictionary where key is column name and value is string to display.
For example:
class MyModelView(BaseModelView): column_labels = dict(name='Name', last_name='Last Name')
- action_view()¶
Mass-model action view.
- ajax_lookup()¶
- ajax_update()¶
Edits a single column of a record in list view.
- create_view()¶
Create model view
- delete_view()¶
Delete model view. Only POST method is allowed.
- details_view()¶
Details model view
- edit_view()¶
Edit model view
- export(export_type)¶
- index_view()¶
List view
- class hepdata.modules.submission.admin.DataResourceAdminView(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]¶
- can_view_details = True¶
Setting this to true will enable the details view. This is recommended when there are too many columns to display in the list_view.
- can_delete = True¶
Is model deletion allowed
- column_list = ('id', 'file_location', 'file_type', 'created')¶
Collection of the model field names for the list view. If set to None, will get them from the model.
For example:
class MyModelView(BaseModelView): column_list = ('name', 'last_name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): column_list = ('name', User.last_name)
- When using SQLAlchemy models, you can reference related columns like this::
- class MyModelView(BaseModelView):
column_list = (‘<relationship>.<related column name>’,)
- form_columns = ('id', 'file_location', 'file_type', 'created')¶
Collection of the model field names for the form. If set to None will get them from the model.
Example:
class MyModelView(BaseModelView): form_columns = ('name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): form_columns = ('name', User.last_name)
SQLA Note: Model attributes must be on the same model as your ModelView or you will need to use inline_models.
- column_searchable_list = ('id', 'file_location', 'file_type', 'created')¶
Collection of the searchable columns.
Example:
class MyModelView(ModelView): column_searchable_list = ('name', 'email')
You can also pass columns:
class MyModelView(ModelView): column_searchable_list = (User.name, User.email)
The following search rules apply:
If you enter
ZZZ
in the UI search field, it will generateILIKE '%ZZZ%'
statement against searchable columns.If you enter multiple words, each word will be searched separately, but only rows that contain all words will be displayed. For example, searching for
abc def
will find all rows that containabc
anddef
in one or more columns.If you prefix your search term with
^
, it will find all rows that start with^
. So, if you entered^ZZZ
thenILIKE 'ZZZ%'
will be used.If you prefix your search term with
=
, it will perform an exact match. For example, if you entered=ZZZ
, the statementILIKE 'ZZZ'
will be used.
- column_filters = ('id', 'file_location', 'file_type', 'created')¶
Collection of the column filters.
Can contain either field names or instances of
flask_admin.contrib.sqla.filters.BaseSQLAFilter
classes.Filters will be grouped by name when displayed in the drop-down.
For example:
class MyModelView(BaseModelView): column_filters = ('user', 'email')
or:
from flask_admin.contrib.sqla.filters import BooleanEqualFilter class MyModelView(BaseModelView): column_filters = (BooleanEqualFilter(column=User.name, name='Name'),)
or:
from flask_admin.contrib.sqla.filters import BaseSQLAFilter class FilterLastNameBrown(BaseSQLAFilter): def apply(self, query, value, alias=None): if value == '1': return query.filter(self.column == "Brown") else: return query.filter(self.column != "Brown") def operation(self): return 'is Brown' class MyModelView(BaseModelView): column_filters = [ FilterLastNameBrown( User.last_name, 'Last Name', options=(('1', 'Yes'), ('0', 'No')) ) ]
- column_details_list = ('id', 'file_location', 'file_type', 'created')¶
Collection of the field names included in the details view. If set to None, will get them from the model.
- columns_sortable_list = ('id', 'file_location', 'file_type', 'created')¶
- column_labels = {'_displayname': 'Display Name'}¶
Dictionary where key is column name and value is string to display.
For example:
class MyModelView(BaseModelView): column_labels = dict(name='Name', last_name='Last Name')
- action_view()¶
Mass-model action view.
- ajax_lookup()¶
- ajax_update()¶
Edits a single column of a record in list view.
- create_view()¶
Create model view
- delete_view()¶
Delete model view. Only POST method is allowed.
- details_view()¶
Details model view
- edit_view()¶
Edit model view
- export(export_type)¶
- index_view()¶
List view
hepdata.modules.submission.api¶
- hepdata.modules.submission.api.is_resource_added_to_submission(recid, version, resource_url)[source]¶
Returns if a submission already has the given resource url :param recid: :param version: :param resource_url: :return:
- hepdata.modules.submission.api.get_latest_hepsubmission(*args, **kwargs)[source]¶
Gets the latest HEPSubmission record matching the given kwargs
- Returns
the HEPSubmission object or None
- hepdata.modules.submission.api.get_submission_participants_for_record(publication_recid, roles=None, **kwargs)[source]¶
Gets the participants for a given publication record id
- Parameters
publication_recid (int) – publication_recid of a submission.
**kwargs – Additional filter parameters to pass to filter_by.
- Returns
List of participants relating to that record
- Return type
list[SubmissionParticipant]
hepdata.modules.submission.models¶
Models for the HEPData Submission Workflow.
- class hepdata.modules.submission.models.LargeBinaryString(*args, **kwargs)[source]¶
Decorator for unicode strings which are stored in the DB as LargeBinary objects, to allow them to be treated as strings in python3
- impl¶
alias of
sqlalchemy.sql.sqltypes.LargeBinary
- process_literal_param(value, dialect)[source]¶
Receive a literal parameter value to be rendered inline within a statement.
This method is used when the compiler renders a literal value without using binds, typically within DDL such as in the “server default” of a column or an expression within a CHECK constraint.
The returned string will be rendered into the output string.
New in version 0.9.0.
- process_bind_param(value, dialect)¶
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngine
object, and from there to the DBAPIexecute()
method.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.
- Parameters
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
- process_result_value(value, dialect)[source]¶
Receive a result-row column value to be converted.
Subclasses should implement this method to operate on data fetched from the database.
Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying
TypeEngine
object, originally from the DBAPI cursor methodfetchone()
or similar.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
- Parameters
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- class hepdata.modules.submission.models.HEPSubmission(**kwargs)[source]¶
This is the main submission object. It maintains the submissions to HEPData and who the coordinator and who the reviewers/uploaders are (via participants).
- id¶
- publication_recid¶
- inspire_id¶
- data_abstract¶
- resources¶
- coordinator¶
- overall_status¶
- created¶
- last_updated¶
- version¶
- doi¶
- reviewers_notified¶
- class hepdata.modules.submission.models.DataSubmission(**kwargs)[source]¶
The submission object associated with a data table.
- id¶
- publication_recid¶
- publication_inspire_id¶
- location_in_publication¶
- name¶
- description¶
- keywords¶
- data_file¶
- resources¶
- doi¶
- associated_recid¶
- version¶
- hepdata.modules.submission.models.receive_before_flush(session, flush_context, instances)[source]¶
Listen for the ‘before_flush’ event to check for DataSubmission deletions and ensure related DataResource and DataReview entries are loaded by SQLAlchemy before deletion to ensure all cascades, event listeners, etc are run.
- class hepdata.modules.submission.models.DataResource(**kwargs)[source]¶
Details of a data resource, which could be a data table, an image, a script, a ROOT file, or a link to an external website or GitHub repo.
Data resources can be related to submissions in various ways:
Resources relating to a submission (HEPSubmission.resources) are linked via the data_resource_link table
Data files belonging to a data table (DataSubmission.data_file) are linked via the data_file field of datasubmission
Resources relating to a data table (DataSubmission.resources) are linked via the datafile_identifier table
- id¶
- file_location¶
- file_type¶
- file_description¶
- file_license¶
- created¶
- hepdata.modules.submission.models.receive_data_resource_after_delete(mapper, connection, target)[source]¶
Delete the file on disk when a DataResource is deleted
- class hepdata.modules.submission.models.DataReview(**kwargs)[source]¶
Represent a data review including links to the messages made about a data record upload and its current status.
- id¶
- publication_recid¶
- data_recid¶
- creation_date¶
- modification_date¶
- status¶
- messages¶
- version¶
- class hepdata.modules.submission.models.Message(**kwargs)[source]¶
General message structure.
- id¶
- user¶
- message¶
- creation_date¶
hepdata.modules.submission.views¶
- hepdata.modules.submission.views.process_submission_payload(*args, **kwargs)[source]¶
Processes the submission payload.
- Parameters
inspire_id –
title –
reviewer –
uploader –
send_upload_email –
- Returns