geonature.core.imports.models#
Attributes#
Classes#
Functions#
Convert optional conditions into a JSON schema. |
|
|
Get all BibFields associated with a given entity. |
Module Contents#
- class geonature.core.imports.models.ImportUserErrorType[source]#
Bases:
geonature.utils.env.db.Model
- class geonature.core.imports.models.Destination[source]#
Bases:
geonature.utils.env.db.Model
- static allowed_destinations(user: pypnusershub.db.models.User | None = None, action_code: str = 'C') List[Destination] [source]#
Return a list of allowed destinations for a given user and an action.
Parameters#
- userUser, optional
The user to filter destinations for. If not provided, the current_user is used.
- actionstr
The action to filter destinations for. Possible values are “C”, “R”, “U”, “V”, “E”, “D”.
Returns#
- allowed_destinationList of Destination
List of allowed destinations for the given user.
- filter_by_role(user: pypnusershub.db.models.User | None = None, action_code: str = 'C', **kwargs)[source]#
Filter Destination by role.
Parameters#
- userUser, optional
The user to filter destinations for. If not provided, the current_user is used.
Returns#
- sqlalchemy.sql.elements.BinaryExpression
A filter criterion for the
id_destination
column of theDestination
table.
- has_instance_permission(user: pypnusershub.db.models.User | None = None, action_code: str = 'C')[source]#
Check if a user has the permissions to do an action on this destination.
Parameters#
- userUser, optional
The user to check the permission for. If not provided, the current_user is used.
- action_codestr
The action to check the permission for. Possible values are “C”, “R”, “U”, “V”, “E”, “D”.
Returns#
- bool
True if the user has the right to do the action on this destination, False otherwise.
- class geonature.core.imports.models.TImports[source]#
Bases:
InstancePermissionMixin
,geonature.utils.env.db.Model
- geonature.core.imports.models.optional_conditions_to_jsonschema(name_field: str, optional_conditions: Iterable[str]) dict [source]#
Convert optional conditions into a JSON schema.
Parameters#
- name_fieldstr
The name of the field.
- optional_conditionsIterable[str]
The optional conditions.
Returns#
- dict
The JSON schema.
Notes#
The JSON schema is created to ensure that if any of the optional conditions is not provided, the name_field is required.
- geonature.core.imports.models.get_fields_of_an_entity(entity: Entity, columns: List[str] | None = None, optional_where_clause: Any | None = None) List[BibFields] [source]#
Get all BibFields associated with a given entity.
Parameters#
- entityEntity
The entity to get the fields for.
- columnsOptional[List[str]], optional
The columns to retrieve. If None, all columns are retrieved.
- optional_where_clauseOptional[Any], optional
An optional where clause to apply to the query.
Returns#
- List[BibFields]
The BibFields associated with the given entity.
- class geonature.core.imports.models.FieldMapping[source]#
Bases:
MappingTemplate