diff options
author | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 11:11:03 +0100 |
---|---|---|
committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-03-20 11:11:03 +0100 |
commit | a79bca799a5830b035df818d7e87425c25d081df (patch) | |
tree | 2089b30b66f0022cae889cb7739860dc143d5314 /src/frest/forms.py | |
parent | 6f3c1d94a6a8858369256b63cec90d42d61706ae (diff) |
chore: move frest dir into src
Diffstat (limited to 'src/frest/forms.py')
-rw-r--r-- | src/frest/forms.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/frest/forms.py b/src/frest/forms.py new file mode 100644 index 0000000..8ce2e95 --- /dev/null +++ b/src/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) |