summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <dcariotti24@gmail.com>2020-03-20 10:19:59 +0100
committerSanto Cariotti <dcariotti24@gmail.com>2020-03-20 10:19:59 +0100
commit9f8faa7c8e7aab724450a281ce3b5583c2c25e6a (patch)
tree13ced867f17b2c9483e6e0171f41163846ad601e
parent4a49b7aad064c5a0b896b8f76b40da28272e4aa6 (diff)
feat: forms
-rw-r--r--frest/forms.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/frest/forms.py b/frest/forms.py
new file mode 100644
index 0000000..8ce2e95
--- /dev/null
+++ b/frest/forms.py
@@ -0,0 +1,20 @@
+class ModelForm(object):
+ def __init__(self, model):
+ self.data = {}
+ self.model = model
+ no_params = ["metadata", "query", "query_class"]
+ self.attributes = [
+ i for i in dir(self.model) if not i.startswith("_") and i not in no_params
+ ]
+ self.ignore = []
+
+ def is_valid(self):
+ for key, value in self.data.items():
+ if key in self.attributes:
+ if (value == "" or not value) and key not in self.ignore:
+ return False
+
+ return True
+
+ def get(self, attr):
+ return self.data.get(attr)