diff options
author | prashantsinalkar | 2019-09-13 16:02:46 +0530 |
---|---|---|
committer | prashantsinalkar | 2019-09-13 16:02:46 +0530 |
commit | f10335fbde4755ccfc29f2407517e0f4d0638d9b (patch) | |
tree | 027790f77fe5d7b495d7b6aa867f5264b0ae1707 | |
parent | 9492133cbd5a9a2ae2849b2b6faefb8c2c04b9db (diff) | |
download | R_on_Cloud_Web_Interface-f10335fbde4755ccfc29f2407517e0f4d0638d9b.tar.gz R_on_Cloud_Web_Interface-f10335fbde4755ccfc29f2407517e0f4d0638d9b.tar.bz2 R_on_Cloud_Web_Interface-f10335fbde4755ccfc29f2407517e0f4d0638d9b.zip |
added from file
-rwxr-xr-x | website/forms.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/website/forms.py b/website/forms.py new file mode 100755 index 0000000..6ce7d74 --- /dev/null +++ b/website/forms.py @@ -0,0 +1,44 @@ +from django import forms +from django.core.validators import validate_email +#from dajax.core import Dajax + +issues = ( + (0, '-- Select Type of issue --'), + (1, 'Blank Code / Incorrect code'), + (2, 'Output error'), + (3, 'Execution error'), + (4, 'Missing example(s)'), + (6, 'Blank output'), + (7, 'Any other / General'), +) + + +class BugForm(forms.Form): + example = forms.CharField(widget=forms.HiddenInput(), required=False) + issue = forms.CharField(widget=forms.Select(choices=issues), required=True) + description = forms.CharField(widget=forms.Textarea) + email = forms.CharField(widget=forms.TextInput(), required=True) + + def clean_email(self): + email = self.cleaned_data.get('email', None) + if not email: + raise forms.ValidationError('Email id is required.') + return email + + def clean(self): + cleaned_data = super(BugForm, self).clean() + issue = self.cleaned_data.get('issue', None) + # example = self.cleaned_data.get('example', None) + if (issue and int(issue) == ''): + raise forms.ValidationError(""" + Please select book, chapter and example. + Or select the *Any other/General* issue type. + """) + return cleaned_data + + +class RevisionForm(forms.Form): + commit_message = forms.CharField( + widget=forms.Textarea, + required=True, + min_length=10) |