summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-03-29 16:29:42 +0200
committerSanto Cariotti <dcariotti24@gmail.com>2020-03-29 16:32:20 +0200
commit84ef988d7e8ae22925b51ea2b3447e471dd38c0c (patch)
tree2a45bfd29df79ccf76d9541b8b32f3cf4444a01e /src
parent474631ff96cae0bc1a526dc37f77e317f7af0505 (diff)
feat: create form by cli
Diffstat (limited to 'src')
-rw-r--r--src/frest/manage/utils.py13
-rw-r--r--src/frest/templates/form.txt1
2 files changed, 14 insertions, 0 deletions
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 = []