From 84ef988d7e8ae22925b51ea2b3447e471dd38c0c Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 29 Mar 2020 16:29:42 +0200 Subject: feat: create form by cli --- src/frest/manage/utils.py | 13 +++++++++++++ src/frest/templates/form.txt | 1 + 2 files changed, 14 insertions(+) diff --git a/src/frest/manage/utils.py b/src/frest/manage/utils.py index 47adeb1..ed07477 100644 --- a/src/frest/manage/utils.py +++ b/src/frest/manage/utils.py @@ -148,6 +148,15 @@ def create_model_cli(name): f.write(modeltext) +def create_forms(name): + with open("templates/form.txt") as f: + formstext = "".join(f.readlines()) + + formstext = formstext.replace("%%NAME%%", name.capitalize()) + with open(f"scheme/{name}/forms.py", "w") as f: + f.write(formstext) + + def create_app(name): name = name.lower().replace("-", "_") @@ -174,3 +183,7 @@ def create_app(name): logging_arg("Create model for {}...\n", name) create_model_cli(name) logging("OK", 3, "\n") + + logging_arg("Create {}... ", f"scheme/{name}/forms.py") + create_forms(name) + logging("OK", 3, "\n") diff --git a/src/frest/templates/form.txt b/src/frest/templates/form.txt index f4b2c14..ed1017e 100644 --- a/src/frest/templates/form.txt +++ b/src/frest/templates/form.txt @@ -8,3 +8,4 @@ class %%NAME%%Form(ModelForm): def __init__(self, data): super().__init__(self.model) self.data = data + self.ignore = [] -- cgit v1.2.3-18-g5258