From 055efb407c3b265ffbc2ed47f1f0b5d1a29b6391 Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Thu, 3 Oct 2019 13:51:25 +0530 Subject: Enable deleting test proposals by reviewer --- fossee_manim/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index 69f8458..af2b96e 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -261,6 +261,7 @@ class AnimationProposal(forms.ModelForm): 'any other related information') } + class Meta: model = Animation fields = ['category', 'subcategory', 'title', 'outline', 'tags'] @@ -282,7 +283,6 @@ class CommentForm(forms.ModelForm): 'comments': forms.CharField(), } - class UploadAnimationForm(forms.ModelForm): def __init__(self, *args, **kwargs): -- cgit From 1151714828cf48b6a496ea7261410a028f306223 Mon Sep 17 00:00:00 2001 From: thedevboy Date: Thu, 3 Oct 2019 15:51:32 +0530 Subject: Integrity error due to name variable checked --- fossee_manim/forms.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index 69f8458..1860bee 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -1,5 +1,7 @@ from django import forms from django.utils import timezone +from taggit.forms import TagWidget + from .models import ( Profile, User, Animation, Comment, AnimationStats @@ -264,6 +266,9 @@ class AnimationProposal(forms.ModelForm): class Meta: model = Animation fields = ['category', 'subcategory', 'title', 'outline', 'tags'] + widgets = { + 'tags': TagWidget(), + } class CommentForm(forms.ModelForm): -- cgit From 145fe3d9baf8e0d52915d7d90c6640553c2ec47c Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Fri, 4 Oct 2019 15:05:40 +0530 Subject: merge forms and some modifictions for proposal page --- fossee_manim/forms.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index af2b96e..8b7eada 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -261,12 +261,87 @@ class AnimationProposal(forms.ModelForm): 'any other related information') } - class Meta: model = Animation + widgets = { + 'sketch': forms.FileInput(), + } fields = ['category', 'subcategory', 'title', 'outline', 'tags'] +class AnimationProposal_edit(forms.ModelForm): + """Animation form """ + required_css_class = 'required' + errorlist_css_class = 'errorlist' + + def __init__(self, *args, **kwargs): + super(AnimationProposal_edit, self).__init__(*args, **kwargs) + self.fields['subcategory'].widget.attrs['placeholder'] = 'Eg: Quantum Mechanics, Topology' + # self.fields['outline'].widget.attrs['placeholder'] = 'NOTE: Do\ + # add info about prerequisites (if any), possible textbooks and \ + # any other related information' + self.fields['outline'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information') + } + self.fields['concepts'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Which concept(s) do you want to animate?' + 'Example: Animation of how data flows in Ring Topology') + } + self.fields['audience'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Who would be the target audience for your video?\n' + 'Example: High School Students, Mechanical Engineers, etc.') + } + + self.fields['reference'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Please try to be as specific as possible. For example,\n' + 'Book used: Linear Algebra.\n' + 'Author: Kenneth Hoffman, Ray Kunze\n' + 'Edition: Second\n' + 'Chapter: 2 ; Page: 40') + } + self.fields['tools'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('What all tools would you be using for animation?\n' + 'Example: manim, blender, mayavi, mathbox, etc') + } + self.fields['detaled_description'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Give a detailed description of your animation') + } + self.fields['link'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Along with the video you will have to submit the source code github link below.\n') + } + self.fields['sketch'].label = "Sketch(.jpeg/.jpg only)" + + class Meta: + model = Animation + widgets = { + 'sketch': forms.FileInput(), + } + fields = ['category', 'subcategory', 'title', 'outline', 'tags', 'concepts', 'audience', 'reference', 'tools', + 'detaled_description', 'link', 'sketch'] + + class CommentForm(forms.ModelForm): """ """ -- cgit From f79913639bc283c945a392d641e84b0a70a97eda Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Mon, 28 Oct 2019 10:58:33 +0530 Subject: PEP8 formatting --- fossee_manim/forms.py | 189 ++++++++++++++++++++++++-------------------------- 1 file changed, 91 insertions(+), 98 deletions(-) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index 8b7eada..0836e47 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -1,9 +1,9 @@ from django import forms from django.utils import timezone from .models import ( - Profile, User, Animation, - Comment, AnimationStats - ) + Profile, User, Animation, + Comment, AnimationStats +) from string import punctuation, digits try: from string import letters @@ -21,7 +21,7 @@ PWD_CHARS = letters + punctuation + digits position_choices = ( ("contributor", "Contributor"), ("reviewer", "Reviewer") - ) +) department_choices = ( ("computer", "Dept. of Computer Science/Engg."), @@ -36,7 +36,7 @@ department_choices = ( ("electronics", "Dept. of Electronics"), ("energy science and engineering", "Dept. of Energy Science and Engg"), ("others", "Others") - ) +) title = ( ("Professor", "Prof."), @@ -47,7 +47,7 @@ title = ( ("Mr", "Mr."), ("Mrs", "Mrs."), ("Miss", "Ms."), - ) +) source = ( ("FOSSEE Email", "FOSSEE Email"), @@ -56,46 +56,46 @@ source = ( ("Social Media", "Social Media"), ("From other College", "From other College"), ("others", "Others") - ) +) states = ( - ("IN-AP", "Andhra Pradesh"), - ("IN-AR", "Arunachal Pradesh"), - ("IN-AS", "Assam"), - ("IN-BR", "Bihar"), - ("IN-CT", "Chhattisgarh"), - ("IN-GA", "Goa"), - ("IN-GJ", "Gujarat"), - ("IN-HR", "Haryana"), - ("IN-HP", "Himachal Pradesh"), - ("IN-JK", "Jammu and Kashmir"), - ("IN-JH", "Jharkhand"), - ("IN-KA", "Karnataka"), - ("IN-KL", "Kerala"), - ("IN-MP", "Madhya Pradesh"), - ("IN-MH", "Maharashtra"), - ("IN-MN", "Manipur"), - ("IN-ML", "Meghalaya"), - ("IN-MZ", "Mizoram"), - ("IN-NL", "Nagaland"), - ("IN-OR", "Odisha"), - ("IN-PB", "Punjab"), - ("IN-RJ", "Rajasthan"), - ("IN-SK", "Sikkim"), - ("IN-TN", "Tamil Nadu"), - ("IN-TG", "Telangana"), - ("IN-TR", "Tripura"), - ("IN-UT", "Uttarakhand"), - ("IN-UP", "Uttar Pradesh"), - ("IN-WB", "West Bengal"), - ("IN-AN", "Andaman and Nicobar Islands"), - ("IN-CH", "Chandigarh"), - ("IN-DN", "Dadra and Nagar Haveli"), - ("IN-DD", "Daman and Diu"), - ("IN-DL", "Delhi"), - ("IN-LD", "Lakshadweep"), - ("IN-PY", "Puducherry") - ) + ("IN-AP", "Andhra Pradesh"), + ("IN-AR", "Arunachal Pradesh"), + ("IN-AS", "Assam"), + ("IN-BR", "Bihar"), + ("IN-CT", "Chhattisgarh"), + ("IN-GA", "Goa"), + ("IN-GJ", "Gujarat"), + ("IN-HR", "Haryana"), + ("IN-HP", "Himachal Pradesh"), + ("IN-JK", "Jammu and Kashmir"), + ("IN-JH", "Jharkhand"), + ("IN-KA", "Karnataka"), + ("IN-KL", "Kerala"), + ("IN-MP", "Madhya Pradesh"), + ("IN-MH", "Maharashtra"), + ("IN-MN", "Manipur"), + ("IN-ML", "Meghalaya"), + ("IN-MZ", "Mizoram"), + ("IN-NL", "Nagaland"), + ("IN-OR", "Odisha"), + ("IN-PB", "Punjab"), + ("IN-RJ", "Rajasthan"), + ("IN-SK", "Sikkim"), + ("IN-TN", "Tamil Nadu"), + ("IN-TG", "Telangana"), + ("IN-TR", "Tripura"), + ("IN-UT", "Uttarakhand"), + ("IN-UP", "Uttar Pradesh"), + ("IN-WB", "West Bengal"), + ("IN-AN", "Andaman and Nicobar Islands"), + ("IN-CH", "Chandigarh"), + ("IN-DN", "Dadra and Nagar Haveli"), + ("IN-DD", "Daman and Diu"), + ("IN-DL", "Delhi"), + ("IN-LD", "Lakshadweep"), + ("IN-PY", "Puducherry") +) def check_upper(uname): @@ -111,7 +111,8 @@ class UserRegistrationForm(forms.Form): a new user to the system""" required_css_class = 'required' errorlist_css_class = 'errorlist' - username = forms.CharField(max_length=32, help_text='''lowercase, letters, digits, + username = forms.CharField( + max_length=32, help_text='''lowercase, letters, digits, period and underscore only.''') email = forms.EmailField() password = forms.CharField(max_length=32, widget=forms.PasswordInput()) @@ -132,7 +133,9 @@ class UserRegistrationForm(forms.Form): department = forms.ChoiceField(help_text='Department you work/study', choices=department_choices) location = forms.CharField(max_length=255, help_text="Place/City") - pincode = forms.RegexField(regex=r'^.{6}$', error_messages={'invalid': "Please enter valid PINCODE"}) + pincode = forms.RegexField( + regex=r'^.{6}$', error_messages={ + 'invalid': "Please enter valid PINCODE"}) state = forms.ChoiceField(choices=states) how_did_you_hear_about_us = forms.ChoiceField(choices=source) @@ -213,11 +216,11 @@ class UserLoginForm(forms.Form): super(UserLoginForm, self).clean() try: u_name, pwd = self.cleaned_data["username"],\ - self.cleaned_data["password"] + self.cleaned_data["password"] user = authenticate(username=u_name, password=pwd) except Exception: - raise forms.ValidationError\ - ("Username and/or Password is not entered") + raise forms.ValidationError( + "Username and/or Password is not entered") if not user: raise forms.ValidationError("Invalid username/password") return user @@ -229,7 +232,7 @@ class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ['first_name', 'last_name', 'institute', 'department', - ] + ] first_name = forms.CharField(max_length=32) last_name = forms.CharField(max_length=32) @@ -253,13 +256,10 @@ class AnimationProposal(forms.ModelForm): # self.fields['outline'].widget.attrs['placeholder'] = 'NOTE: Do\ # add info about prerequisites (if any), possible textbooks and \ # any other related information' - self.fields['outline'].widget.attrs={ - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' - 'any other related information') - } + self.fields['outline'].widget.attrs = { + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information')} class Meta: model = Animation @@ -281,56 +281,37 @@ class AnimationProposal_edit(forms.ModelForm): # add info about prerequisites (if any), possible textbooks and \ # any other related information' self.fields['outline'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' - 'any other related information') - } + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information')} self.fields['concepts'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('Which concept(s) do you want to animate?' - 'Example: Animation of how data flows in Ring Topology') - } + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'Which concept(s) do you want to animate?' + 'Example: Animation of how data flows in Ring Topology')} self.fields['audience'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('Who would be the target audience for your video?\n' - 'Example: High School Students, Mechanical Engineers, etc.') - } + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'Who would be the target audience for your video?\n' + 'Example: High School Students, Mechanical Engineers, etc.')} self.fields['reference'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('Please try to be as specific as possible. For example,\n' - 'Book used: Linear Algebra.\n' - 'Author: Kenneth Hoffman, Ray Kunze\n' - 'Edition: Second\n' - 'Chapter: 2 ; Page: 40') - } + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'Please try to be as specific as possible. For example,\n' + 'Book used: Linear Algebra.\n' + 'Author: Kenneth Hoffman, Ray Kunze\n' + 'Edition: Second\n' + 'Chapter: 2 ; Page: 40')} self.fields['tools'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('What all tools would you be using for animation?\n' - 'Example: manim, blender, mayavi, mathbox, etc') - } + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'What all tools would you be using for animation?\n' + 'Example: manim, blender, mayavi, mathbox, etc')} self.fields['detaled_description'].widget.attrs = { 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ('Give a detailed description of your animation') } - self.fields['link'].widget.attrs = { - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('Along with the video you will have to submit the source code github link below.\n') - } + self.fields['link'].widget.attrs = {'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'Along with the video you will have to submit the source code github link below.\n')} self.fields['sketch'].label = "Sketch(.jpeg/.jpg only)" class Meta: @@ -338,8 +319,19 @@ class AnimationProposal_edit(forms.ModelForm): widgets = { 'sketch': forms.FileInput(), } - fields = ['category', 'subcategory', 'title', 'outline', 'tags', 'concepts', 'audience', 'reference', 'tools', - 'detaled_description', 'link', 'sketch'] + fields = [ + 'category', + 'subcategory', + 'title', + 'outline', + 'tags', + 'concepts', + 'audience', + 'reference', + 'tools', + 'detaled_description', + 'link', + 'sketch'] class CommentForm(forms.ModelForm): @@ -358,6 +350,7 @@ class CommentForm(forms.ModelForm): 'comments': forms.CharField(), } + class UploadAnimationForm(forms.ModelForm): def __init__(self, *args, **kwargs): -- cgit From cfdc41deed280bddbcc6c3cf45e30f33ea139e88 Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Mon, 28 Oct 2019 11:27:18 +0530 Subject: pep8 formatting --- fossee_manim/forms.py | 114 +++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index 1860bee..10be5b1 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -3,9 +3,9 @@ from django.utils import timezone from taggit.forms import TagWidget from .models import ( - Profile, User, Animation, - Comment, AnimationStats - ) + Profile, User, Animation, + Comment, AnimationStats +) from string import punctuation, digits try: from string import letters @@ -23,7 +23,7 @@ PWD_CHARS = letters + punctuation + digits position_choices = ( ("contributor", "Contributor"), ("reviewer", "Reviewer") - ) +) department_choices = ( ("computer", "Dept. of Computer Science/Engg."), @@ -38,7 +38,7 @@ department_choices = ( ("electronics", "Dept. of Electronics"), ("energy science and engineering", "Dept. of Energy Science and Engg"), ("others", "Others") - ) +) title = ( ("Professor", "Prof."), @@ -49,7 +49,7 @@ title = ( ("Mr", "Mr."), ("Mrs", "Mrs."), ("Miss", "Ms."), - ) +) source = ( ("FOSSEE Email", "FOSSEE Email"), @@ -58,46 +58,46 @@ source = ( ("Social Media", "Social Media"), ("From other College", "From other College"), ("others", "Others") - ) +) states = ( - ("IN-AP", "Andhra Pradesh"), - ("IN-AR", "Arunachal Pradesh"), - ("IN-AS", "Assam"), - ("IN-BR", "Bihar"), - ("IN-CT", "Chhattisgarh"), - ("IN-GA", "Goa"), - ("IN-GJ", "Gujarat"), - ("IN-HR", "Haryana"), - ("IN-HP", "Himachal Pradesh"), - ("IN-JK", "Jammu and Kashmir"), - ("IN-JH", "Jharkhand"), - ("IN-KA", "Karnataka"), - ("IN-KL", "Kerala"), - ("IN-MP", "Madhya Pradesh"), - ("IN-MH", "Maharashtra"), - ("IN-MN", "Manipur"), - ("IN-ML", "Meghalaya"), - ("IN-MZ", "Mizoram"), - ("IN-NL", "Nagaland"), - ("IN-OR", "Odisha"), - ("IN-PB", "Punjab"), - ("IN-RJ", "Rajasthan"), - ("IN-SK", "Sikkim"), - ("IN-TN", "Tamil Nadu"), - ("IN-TG", "Telangana"), - ("IN-TR", "Tripura"), - ("IN-UT", "Uttarakhand"), - ("IN-UP", "Uttar Pradesh"), - ("IN-WB", "West Bengal"), - ("IN-AN", "Andaman and Nicobar Islands"), - ("IN-CH", "Chandigarh"), - ("IN-DN", "Dadra and Nagar Haveli"), - ("IN-DD", "Daman and Diu"), - ("IN-DL", "Delhi"), - ("IN-LD", "Lakshadweep"), - ("IN-PY", "Puducherry") - ) + ("IN-AP", "Andhra Pradesh"), + ("IN-AR", "Arunachal Pradesh"), + ("IN-AS", "Assam"), + ("IN-BR", "Bihar"), + ("IN-CT", "Chhattisgarh"), + ("IN-GA", "Goa"), + ("IN-GJ", "Gujarat"), + ("IN-HR", "Haryana"), + ("IN-HP", "Himachal Pradesh"), + ("IN-JK", "Jammu and Kashmir"), + ("IN-JH", "Jharkhand"), + ("IN-KA", "Karnataka"), + ("IN-KL", "Kerala"), + ("IN-MP", "Madhya Pradesh"), + ("IN-MH", "Maharashtra"), + ("IN-MN", "Manipur"), + ("IN-ML", "Meghalaya"), + ("IN-MZ", "Mizoram"), + ("IN-NL", "Nagaland"), + ("IN-OR", "Odisha"), + ("IN-PB", "Punjab"), + ("IN-RJ", "Rajasthan"), + ("IN-SK", "Sikkim"), + ("IN-TN", "Tamil Nadu"), + ("IN-TG", "Telangana"), + ("IN-TR", "Tripura"), + ("IN-UT", "Uttarakhand"), + ("IN-UP", "Uttar Pradesh"), + ("IN-WB", "West Bengal"), + ("IN-AN", "Andaman and Nicobar Islands"), + ("IN-CH", "Chandigarh"), + ("IN-DN", "Dadra and Nagar Haveli"), + ("IN-DD", "Daman and Diu"), + ("IN-DL", "Delhi"), + ("IN-LD", "Lakshadweep"), + ("IN-PY", "Puducherry") +) def check_upper(uname): @@ -113,7 +113,8 @@ class UserRegistrationForm(forms.Form): a new user to the system""" required_css_class = 'required' errorlist_css_class = 'errorlist' - username = forms.CharField(max_length=32, help_text='''lowercase, letters, digits, + username = forms.CharField( + max_length=32, help_text='''lowercase, letters, digits, period and underscore only.''') email = forms.EmailField() password = forms.CharField(max_length=32, widget=forms.PasswordInput()) @@ -134,7 +135,9 @@ class UserRegistrationForm(forms.Form): department = forms.ChoiceField(help_text='Department you work/study', choices=department_choices) location = forms.CharField(max_length=255, help_text="Place/City") - pincode = forms.RegexField(regex=r'^.{6}$', error_messages={'invalid': "Please enter valid PINCODE"}) + pincode = forms.RegexField( + regex=r'^.{6}$', error_messages={ + 'invalid': "Please enter valid PINCODE"}) state = forms.ChoiceField(choices=states) how_did_you_hear_about_us = forms.ChoiceField(choices=source) @@ -215,11 +218,11 @@ class UserLoginForm(forms.Form): super(UserLoginForm, self).clean() try: u_name, pwd = self.cleaned_data["username"],\ - self.cleaned_data["password"] + self.cleaned_data["password"] user = authenticate(username=u_name, password=pwd) except Exception: - raise forms.ValidationError\ - ("Username and/or Password is not entered") + raise forms.ValidationError( + "Username and/or Password is not entered") if not user: raise forms.ValidationError("Invalid username/password") return user @@ -231,7 +234,7 @@ class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ['first_name', 'last_name', 'institute', 'department', - ] + ] first_name = forms.CharField(max_length=32) last_name = forms.CharField(max_length=32) @@ -255,13 +258,10 @@ class AnimationProposal(forms.ModelForm): # self.fields['outline'].widget.attrs['placeholder'] = 'NOTE: Do\ # add info about prerequisites (if any), possible textbooks and \ # any other related information' - self.fields['outline'].widget.attrs={ - 'id': 'custom_editor', - 'rows': 10, - 'cols': 50, - 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' - 'any other related information') - } + self.fields['outline'].widget.attrs = { + 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( + 'NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information')} class Meta: model = Animation -- cgit From 6c741569e8ef73fe1e8773419f241891dd69a1ad Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Mon, 4 Nov 2019 17:26:27 +0530 Subject: removed merge conflicts --- fossee_manim/forms.py | 190 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 129 insertions(+), 61 deletions(-) (limited to 'fossee_manim/forms.py') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index b7555fc..7cc1971 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -1,11 +1,9 @@ from django import forms from django.utils import timezone -from taggit.forms import TagWidget - from .models import ( - Profile, User, Animation, - Comment, AnimationStats -) + Profile, User, Animation, + Comment, AnimationStats + ) from string import punctuation, digits try: from string import letters @@ -23,7 +21,7 @@ PWD_CHARS = letters + punctuation + digits position_choices = ( ("contributor", "Contributor"), ("reviewer", "Reviewer") -) + ) department_choices = ( ("computer", "Dept. of Computer Science/Engg."), @@ -38,7 +36,7 @@ department_choices = ( ("electronics", "Dept. of Electronics"), ("energy science and engineering", "Dept. of Energy Science and Engg"), ("others", "Others") -) + ) title = ( ("Professor", "Prof."), @@ -49,7 +47,7 @@ title = ( ("Mr", "Mr."), ("Mrs", "Mrs."), ("Miss", "Ms."), -) + ) source = ( ("FOSSEE Email", "FOSSEE Email"), @@ -58,46 +56,46 @@ source = ( ("Social Media", "Social Media"), ("From other College", "From other College"), ("others", "Others") -) + ) states = ( - ("IN-AP", "Andhra Pradesh"), - ("IN-AR", "Arunachal Pradesh"), - ("IN-AS", "Assam"), - ("IN-BR", "Bihar"), - ("IN-CT", "Chhattisgarh"), - ("IN-GA", "Goa"), - ("IN-GJ", "Gujarat"), - ("IN-HR", "Haryana"), - ("IN-HP", "Himachal Pradesh"), - ("IN-JK", "Jammu and Kashmir"), - ("IN-JH", "Jharkhand"), - ("IN-KA", "Karnataka"), - ("IN-KL", "Kerala"), - ("IN-MP", "Madhya Pradesh"), - ("IN-MH", "Maharashtra"), - ("IN-MN", "Manipur"), - ("IN-ML", "Meghalaya"), - ("IN-MZ", "Mizoram"), - ("IN-NL", "Nagaland"), - ("IN-OR", "Odisha"), - ("IN-PB", "Punjab"), - ("IN-RJ", "Rajasthan"), - ("IN-SK", "Sikkim"), - ("IN-TN", "Tamil Nadu"), - ("IN-TG", "Telangana"), - ("IN-TR", "Tripura"), - ("IN-UT", "Uttarakhand"), - ("IN-UP", "Uttar Pradesh"), - ("IN-WB", "West Bengal"), - ("IN-AN", "Andaman and Nicobar Islands"), - ("IN-CH", "Chandigarh"), - ("IN-DN", "Dadra and Nagar Haveli"), - ("IN-DD", "Daman and Diu"), - ("IN-DL", "Delhi"), - ("IN-LD", "Lakshadweep"), - ("IN-PY", "Puducherry") -) + ("IN-AP", "Andhra Pradesh"), + ("IN-AR", "Arunachal Pradesh"), + ("IN-AS", "Assam"), + ("IN-BR", "Bihar"), + ("IN-CT", "Chhattisgarh"), + ("IN-GA", "Goa"), + ("IN-GJ", "Gujarat"), + ("IN-HR", "Haryana"), + ("IN-HP", "Himachal Pradesh"), + ("IN-JK", "Jammu and Kashmir"), + ("IN-JH", "Jharkhand"), + ("IN-KA", "Karnataka"), + ("IN-KL", "Kerala"), + ("IN-MP", "Madhya Pradesh"), + ("IN-MH", "Maharashtra"), + ("IN-MN", "Manipur"), + ("IN-ML", "Meghalaya"), + ("IN-MZ", "Mizoram"), + ("IN-NL", "Nagaland"), + ("IN-OR", "Odisha"), + ("IN-PB", "Punjab"), + ("IN-RJ", "Rajasthan"), + ("IN-SK", "Sikkim"), + ("IN-TN", "Tamil Nadu"), + ("IN-TG", "Telangana"), + ("IN-TR", "Tripura"), + ("IN-UT", "Uttarakhand"), + ("IN-UP", "Uttar Pradesh"), + ("IN-WB", "West Bengal"), + ("IN-AN", "Andaman and Nicobar Islands"), + ("IN-CH", "Chandigarh"), + ("IN-DN", "Dadra and Nagar Haveli"), + ("IN-DD", "Daman and Diu"), + ("IN-DL", "Delhi"), + ("IN-LD", "Lakshadweep"), + ("IN-PY", "Puducherry") + ) def check_upper(uname): @@ -113,8 +111,7 @@ class UserRegistrationForm(forms.Form): a new user to the system""" required_css_class = 'required' errorlist_css_class = 'errorlist' - username = forms.CharField( - max_length=32, help_text='''lowercase, letters, digits, + username = forms.CharField(max_length=32, help_text='''lowercase, letters, digits, period and underscore only.''') email = forms.EmailField() password = forms.CharField(max_length=32, widget=forms.PasswordInput()) @@ -135,9 +132,7 @@ class UserRegistrationForm(forms.Form): department = forms.ChoiceField(help_text='Department you work/study', choices=department_choices) location = forms.CharField(max_length=255, help_text="Place/City") - pincode = forms.RegexField( - regex=r'^.{6}$', error_messages={ - 'invalid': "Please enter valid PINCODE"}) + pincode = forms.RegexField(regex=r'^.{6}$', error_messages={'invalid': "Please enter valid PINCODE"}) state = forms.ChoiceField(choices=states) how_did_you_hear_about_us = forms.ChoiceField(choices=source) @@ -218,11 +213,11 @@ class UserLoginForm(forms.Form): super(UserLoginForm, self).clean() try: u_name, pwd = self.cleaned_data["username"],\ - self.cleaned_data["password"] + self.cleaned_data["password"] user = authenticate(username=u_name, password=pwd) except Exception: - raise forms.ValidationError( - "Username and/or Password is not entered") + raise forms.ValidationError\ + ("Username and/or Password is not entered") if not user: raise forms.ValidationError("Invalid username/password") return user @@ -234,7 +229,7 @@ class ProfileForm(forms.ModelForm): class Meta: model = Profile fields = ['first_name', 'last_name', 'institute', 'department', - ] + ] first_name = forms.CharField(max_length=32) last_name = forms.CharField(max_length=32) @@ -258,18 +253,91 @@ class AnimationProposal(forms.ModelForm): # self.fields['outline'].widget.attrs['placeholder'] = 'NOTE: Do\ # add info about prerequisites (if any), possible textbooks and \ # any other related information' + self.fields['outline'].widget.attrs={ + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information') + } + + class Meta: + model = Animation + widgets = { + 'sketch': forms.FileInput(), + } + fields = ['category', 'subcategory', 'title', 'outline', 'tags'] + + +class AnimationProposal_edit(forms.ModelForm): + """Animation form """ + required_css_class = 'required' + errorlist_css_class = 'errorlist' + + def __init__(self, *args, **kwargs): + super(AnimationProposal_edit, self).__init__(*args, **kwargs) + self.fields['subcategory'].widget.attrs['placeholder'] = 'Eg: Quantum Mechanics, Topology' + self.fields['outline'].widget.attrs = { - 'id': 'custom_editor', 'rows': 10, 'cols': 50, 'placeholder': ( - 'NOTE: Do add info about prerequisites (if any), possible textbooks and ' - 'any other related information')} + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information') + } + self.fields['concepts'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Which concept(s) do you want to animate?' + 'Example: Animation of how data flows in Ring Topology') + } + self.fields['audience'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Who would be the target audience for your video?\n' + 'Example: High School Students, Mechanical Engineers, etc.') + } + self.fields['reference'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Please try to be as specific as possible. For example,\n' + 'Book used: Linear Algebra.\n' + 'Author: Kenneth Hoffman, Ray Kunze\n' + 'Edition: Second\n' + 'Chapter: 2 ; Page: 40') + } + self.fields['tools'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('What all tools would you be using for animation?\n' + 'Example: manim, blender, mayavi, mathbox, etc') + } + self.fields['detaled_description'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Give a detailed description of your animation') + } + self.fields['link'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Along with the video you will have to submit the source code github link below.\n') + } + self.fields['sketch'].label = "Sketch(.jpeg/.jpg only)" class Meta: model = Animation - fields = ['category', 'subcategory', 'title', 'outline', 'tags'] widgets = { - 'tags': TagWidget(), + 'sketch': forms.FileInput(), } + fields = ['category', 'subcategory', 'title', 'outline', 'tags', 'concepts', 'audience', 'reference', 'tools', + 'detaled_description', 'link', 'sketch'] class CommentForm(forms.ModelForm): @@ -299,4 +367,4 @@ class UploadAnimationForm(forms.ModelForm): exclude = ['animation', 'views', 'like', 'dislike', 'thumbnail'] widgets = { 'video_path': forms.FileInput(), - } + } \ No newline at end of file -- cgit