forked from entrepreneur-interet-general/solidata_backend
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factorizing models parts + more on projects models
- Loading branch information
1 parent
debf9ed
commit e533d86
Showing
13 changed files
with
353 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
""" | ||
_models/models_generic.py | ||
- provides the models for all api routes | ||
""" | ||
|
||
from log_config import log, pformat | ||
|
||
log.debug("... loading models_generic.py ...") | ||
|
||
|
||
from flask_restplus import fields | ||
|
||
### import data serializers | ||
from solidata_api._serializers.schema_logs import * | ||
from solidata_api._serializers.schema_generic import * | ||
from solidata_api._serializers.schema_projects import * | ||
|
||
|
||
|
||
### MODEL / BASIC INFOS | ||
def create_model_basic_infos(ns_, model_name, | ||
schema=doc_basics, | ||
) : | ||
|
||
basic_infos = fields.Nested( | ||
ns_.model( model_name , doc_basics ) | ||
) | ||
return basic_infos | ||
|
||
|
||
|
||
### MODEL TEAM | ||
def create_model_team(ns_, model_name="Collaborator"): | ||
|
||
collaborator = fields.Nested( | ||
ns_.model( model_name, { | ||
'user_oid' : oid, | ||
'auth_edit' : edit_auth | ||
}) | ||
) | ||
|
||
collaborators = fields.List( | ||
collaborator, | ||
description = "List of collaborators on this document", | ||
default = [] | ||
) | ||
|
||
return collaborators | ||
|
||
|
||
### MODIFICATIONS LOG | ||
def create_model_modif_log(ns_, model_name, | ||
schema = modification_full, | ||
include_counts = False, | ||
counts_name = "counts", | ||
include_created_by = True, | ||
include_is_running = False, | ||
) : | ||
|
||
### create the list of modifications | ||
modifications = fields.List( | ||
fields.Nested( | ||
ns_.model('Modifications', schema ) | ||
), | ||
description = "List of the modifications on this document", | ||
default = [] | ||
) | ||
|
||
log_base = { | ||
'created_at' : created_at, | ||
'modified_log' : modifications | ||
} | ||
|
||
if include_created_by == True : | ||
log_base['created_by'] = oid | ||
|
||
if include_counts == True : | ||
log_base[ counts_name ] = count | ||
|
||
if include_is_running == True : | ||
log_base[ "is_running" ] = is_running | ||
|
||
### compile the document's log | ||
doc_log = fields.Nested( | ||
ns_.model( model_name, log_base ) | ||
) | ||
|
||
return doc_log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
""" | ||
schema_datamodels.py | ||
- provides the model for DATAMODEL definition in DB and Flask-Restplus | ||
""" | ||
|
||
from log_config import log, pformat | ||
|
||
log.debug("... loading schema_datamodels.py ...") | ||
|
||
from flask_restplus import fields | ||
|
||
from .schema_generic import * | ||
from .schema_logs import * | ||
from .schema_users import * |
Oops, something went wrong.