Skip to content

Commit

Permalink
init branch + add template usable with cookie-cutter
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed Jan 12, 2024
1 parent fb9bde9 commit 662dede
Show file tree
Hide file tree
Showing 28 changed files with 516 additions and 0 deletions.
160 changes: 160 additions & 0 deletions contrib/examples/submodule_modulator_template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
13 changes: 13 additions & 0 deletions contrib/examples/submodule_modulator_template/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"project_name": "Minimum template for Modulator submodule",
"project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}",
"project_description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
"module_name":"m_test",
"module_desc":"Module de test",
"module_picto": "fa-road",
"active_frontend":true,
"db_schema_name":"pr_test",
"author": "Anonymous",
"author_email": "[email protected]",
"version":"0.0.1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# {{cookiecutter.project_name}}

{{cookiecutter.project_description}}

## Setup

Be sure to have `gn_modulator` installed in your Geonature instance. If not, refer to [https://github.com/PnX-SI/gn_modulator](https://github.com/PnX-SI/gn_modulator).

To install {{cookiecutter.module_name}}, run the following command.

```shell
source <pathtogeonature>/backend/venv/bin/activate
geonature modulator install -p {{cookiecutter.module_name}}
```

**Reminder** As every module in GeoNature, be sure that your user(s) have necessary permissions to access your module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{cookiecutter.version}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MODULE_CODE = "{{cookiecutter.module_name}}"
MODULE_PICTO = "{{cookiecutter.module_picto}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from flask import Blueprint
from {{cookiecutter.module_name}} import MODULE_CODE

blueprint = Blueprint(MODULE_CODE.lower(), __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from marshmallow import Schema


class GnModuleSchemaConf(Schema):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""init sous-module {{cookiecutter.module_name}}
Revision ID: dfsdgf45sdf1
Create Date: 2023-02-01 12:48:24.613956
"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "dfsdgf45sdf1"# TODO : Change it !!!
down_revision = None
branch_labels = "{{cookiecutter.module_name}}"
depends_on = "modulator"


def upgrade():
op.execute("create schema {{cookiecutter.db_schema_name}}")
op.create_table(
"author",
sa.Column("id_author", sa.Integer, primary_key=True),
sa.Column("first_name", sa.String),
sa.Column("last_name", sa.String),
sa.Column("email_address", sa.String),
schema="{{cookiecutter.db_schema_name}}",
)
op.create_table(
"post",
sa.Column("id_post", sa.Integer, primary_key=True),
sa.Column("post_title", sa.String),
sa.Column("post_content", sa.String),
sa.Column("id_author", sa.Integer, sa.ForeignKey("{{cookiecutter.db_schema_name}}.author.id_author")),
schema="{{cookiecutter.db_schema_name}}",
)


def downgrade():
op.drop_table("post", schema="{{cookiecutter.db_schema_name}}")
op.drop_table("author", schema="{{cookiecutter.db_schema_name}}")
op.execute("drop schema {{cookiecutter.db_schema_name}}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from geonature.utils.env import db

class Author(db.Model):
___tablename__ = "author"
__table_args__ = {"schema": "{{cookiecutter.db_schema_name}}"}
id_author = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.String)
last_name = db.Column(db.String)
email_address = db.Column(db.String)
posts = db.relationship("Post", back_populates="author")


class Post(db.Model):
___tablename__ = "post"
__table_args__ = {"schema": "{{cookiecutter.db_schema_name}}"}

id_post = db.Column(db.Integer, primary_key=True)
post_title = db.Column(db.String)
post_content = db.Column(db.String)
id_author = db.Column(
db.Integer, db.ForeignKey("{{cookiecutter.db_schema_name}}.author.id_author"), nullable=False
)
author = db.relationship(Author, back_populates="posts")
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type: schema
code: {{cookiecutter.module_name}}.author
title: schema auteur
description: Définition du schema pour les auteurs liés aux posts
meta:
model: {{cookiecutter.module_name}}.models.Author
module_code: {{cookiecutter.module_name}}
genre: M
label: Auteur
label_field_name: first_name
unique:
- email_address
sql_processing: true
properties:
id_author:
title: ID auteur
first_name:
title: Prénom
last_name:
title: Nom de Famille
email_address:
title: "Adresse E-Mail"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: schema
code: {{cookiecutter.module_name}}.post
title: schema acteur site
description: Définition du schema pour les acteurs liés aux sites
meta:
model: {{cookiecutter.module_name}}.models.Post
module_code: {{cookiecutter.module_name}}
genre: M
label: Post
label_field_name: post_title
unique:
- id_post
sql_processing: true
properties:
id_post:
title: ID post
post_title:
title: Titre
post_content:
title: Contenu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type: data
code: {{cookiecutter.module_name}}.fake_author
title: Données de remplissages
description: Ajout d'auteurs bidons
items:
- schema_code: {{cookiecutter.module_name}}.author
defaults:
id_module: {{cookiecutter.module_name}}
keys: [first_name, last_name, email_address]
items:
- [Bob, "Fokes", "[email protected]"]
- [Anne, "Onyme", "[email protected]"]
- [Jean, "Peste", "[email protected]"]
- [Felicia, "A", "[email protected]"]
- [Fernando, "Zorro", "[email protected]"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: data
code: {{cookiecutter.module_name}}.fake_post
title: Données de remplissages
description: Ajout de posts bidons
items:
- schema_code: {{cookiecutter.module_name}}.post
defaults:
id_module: {{cookiecutter.module_name}}
keys: [post_title, post_content, id_author]
items:
- ["Un raton laveur au lavoir", "lorem ipsum", "[email protected]"]
- ["La rondeur du mystère", "lorem ipsum", "[email protected]"]
- ["La peur de l'erreur: Il hésite", "lorem ipsum", "[email protected]"]
- ["Le festin d'un volcan : un gout de brulé", "lorem ipsum", "[email protected]"]
- ["L'entreprise de minuit : sonnez les cloches", "lorem ipsum", "[email protected]"]
- ["Les derniers mots des fourmis: Oh un Pied !", "lorem ipsum", "[email protected]"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type: data
code: {{cookiecutter.module_name}}.permissions
title: Data permissions {{cookiecutter.module_name}}
description: Permissions disponibles pour le module {{cookiecutter.module_name}}
items:
- schema_code: perm.perm_dispo
defaults:
id_module: {{cookiecutter.module_name}}
keys: [id_object, id_action, scope_filter, label]
items:
- [ALL, C, true, "Créer et importer des posts/auteurs"]
- [ALL, R, true, "Voir les posts/auteurs"]
- [ALL, U, true, "Modifier les posts/auteurs"]
- [ALL, D, true, "Supprimer des posts/auteurs"]
- [ALL, E, true, "Exporter les posts/auteurs"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type: layout
code: {{cookiecutter.module_name}}.author_list
title: Layout site list
description: Layout pour la liste de auteurs

layout:
height_auto: true
items:
- type: section
title: test
items:
- type: message
html: <b>hello word</b>
- type: object
object_code: author
items:
type: form
title: "ddd"
items:
- overflow: true
items: [last_name, first_name, email_address]
- code: utils.buttons_form
- object_code: author
label: "TEST"
items:
- type: object
display: table
items: [last_name, first_name, email_address]
Loading

0 comments on commit 662dede

Please sign in to comment.