diff options
author | prashantsinalkar | 2018-08-23 16:57:20 +0530 |
---|---|---|
committer | prashantsinalkar | 2018-08-23 16:57:20 +0530 |
commit | 38d3b98ef3695add04945151a558d954ebf02140 (patch) | |
tree | d40a79c323f80bd1841163e70d99c856d2bc30f6 | |
parent | 5320025f26e00321f3bef69e7109e769f15dad60 (diff) | |
download | SciPy2018-38d3b98ef3695add04945151a558d954ebf02140.tar.gz SciPy2018-38d3b98ef3695add04945151a558d954ebf02140.tar.bz2 SciPy2018-38d3b98ef3695add04945151a558d954ebf02140.zip |
added new forms
-rwxr-xr-x | website/forms.py | 75 |
1 files changed, 59 insertions, 16 deletions
diff --git a/website/forms.py b/website/forms.py index 97f9196..d9cb520 100755 --- a/website/forms.py +++ b/website/forms.py @@ -1,6 +1,6 @@ from django import forms -from django.forms import ModelForm +from django.forms import ModelForm, widgets from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User @@ -43,15 +43,13 @@ rating=( ('10','10'), ) +CHOICES=[('1','Yes'), + ('0','No')] +#modal proposal form for cfp class ProposalForm(forms.ModelForm): - class Meta: - model = Proposal - exclude = ('user', 'email','prerequisite','status','rate') - - about_me = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About Me'}), required = True, error_messages = {'required':'About me field required.'}, @@ -66,19 +64,21 @@ class ProposalForm(forms.ModelForm): required = True, error_messages = {'required':'Title field required.'}, ) - abstract = forms.CharField(min_length = 300, widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Abstract'}), + abstract = forms.CharField(min_length = 300, widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Abstract', 'onkeyup':'countChar(this)'}), required = True, label = 'Abstract (Min. 300 char.)', error_messages = {'required':'Abstract field required.'}, ) proposal_type = forms.CharField(widget = forms.HiddenInput(), label = '', initial = 'ABSTRACT', required=False) - + duration = forms.ChoiceField(choices=abs_duration, label = 'Duration (Mins.)') tags = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tags'}), required = False, ) - + open_to_share = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(),required = True, + label = 'I am agree to publish my content',) + class Meta: model = Proposal @@ -98,6 +98,8 @@ class ProposalForm(forms.ModelForm): raise forms.ValidationError('File size exceeds 5MB') return attachment + +#modal workshop form for cfw class WorkshopForm(forms.ModelForm): about_me = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About Me'}), required = True, @@ -112,11 +114,10 @@ class WorkshopForm(forms.ModelForm): required = True, error_messages = {'required':'Title field required.'}, ) - abstract = forms.CharField(min_length = 300 ,widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Desciption'}), + abstract = forms.CharField(min_length = 300 ,widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Desciption','onkeyup':'countChar(this)'}), required = True, - label = 'Description (Min. 300 char.)', - error_messages = {'required':'Abstract field required.'}, - ) + label = 'Description (Min. 300 char.)',) + prerequisite = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Prerequisite'}), label = 'Prerequisites', required = False, @@ -126,7 +127,9 @@ class WorkshopForm(forms.ModelForm): duration = forms.ChoiceField(choices=ws_duration, label = 'Duration (Hrs.)') tags = forms.ChoiceField(choices=MY_CHOICES, label = 'Level') - + open_to_share = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(),required = True, + label = 'I am agree to publish my content',) + class Meta: model = Proposal exclude = ('user', 'email','status','rate') @@ -145,6 +148,48 @@ class WorkshopForm(forms.ModelForm): return attachment +class UserRegisterForm(UserCreationForm): + class Meta: + model = User + fields = ('first_name', 'last_name', 'email', 'username', 'password1', + 'password2') + first_name = forms.CharField(widget=forms.TextInput(attrs={'class' : 'form-control', 'placeholder': 'First Name'}), + label = 'First Name' + ) + last_name = forms.CharField(widget=forms.TextInput(attrs={'class' : 'form-control' ,'placeholder': 'Last Name'}), + label = 'Last Name' + ) + email = forms.EmailField(widget=forms.TextInput(attrs={'class' : 'form-control' ,'placeholder': 'Email'}), + required = True, + error_messages = {'required':'Email field required.'}, + label = 'Email' + ) + username = forms.CharField(widget=forms.TextInput(attrs={'class' : 'form-control' ,'placeholder': 'Username'}), + required = True, + error_messages = {'required':'Username field required.'}, + label = 'Username' + ) + password1 = forms.CharField(widget=forms.PasswordInput(attrs={'class' : 'form-control' ,'placeholder': 'Password'}), + required = True, + error_messages = {'required':'Password field required.'}, + label = 'Password' + ) + password2 = forms.CharField(widget=forms.PasswordInput(attrs={'class' : 'form-control' ,'placeholder': 'Confirm Password'}), + required = True, + error_messages = {'required':'Password Confirm field required.'}, + label = 'Re-enter Password' + ) + + def clean_first_name(self): + return self.cleaned_data["first_name"].title() + + def clean_email(self): + return self.cleaned_data["email"].lower() + + def clean_last_name(self): + return self.cleaned_data["last_name"].title() + + class UserLoginForm(forms.Form): username = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-inline', 'placeholder': 'Username'}), @@ -154,5 +199,3 @@ class UserLoginForm(forms.Form): widget=forms.PasswordInput(attrs={'class': 'form-inline', 'placeholder': 'Password'}), label='Password' ) - - |