From dd2f35df5bfd31a5d16f5057eaa45d23492c755c Mon Sep 17 00:00:00 2001 From: thedevboy Date: Thu, 3 Oct 2019 14:49:03 +0530 Subject: Footer fixed --- .idea/.gitignore | 6 + .idea/FOSSEE_animations.iml | 31 +++ .idea/dataSources.xml | 22 ++ .idea/inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + fossee_manim/static/css/index.css | 32 ++- fossee_manim/templates/fossee_manim/about.html | 9 +- fossee_manim/templates/fossee_manim/base.html | 225 ++++++++++----------- fossee_manim/templates/fossee_manim/faqs.html | 2 +- .../templates/fossee_manim/honorarium.html | 8 +- fossee_manim/templates/fossee_manim/index.html | 2 +- fossee_manim/templates/fossee_manim/logout.html | 2 +- fossee_manim/templates/fossee_manim/outreach.html | 2 +- .../templates/fossee_manim/proposal_status.html | 1 + 16 files changed, 244 insertions(+), 125 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/FOSSEE_animations.iml create mode 100644 .idea/dataSources.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..3889a9e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,6 @@ + +# Default ignored files +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml \ No newline at end of file diff --git a/.idea/FOSSEE_animations.iml b/.idea/FOSSEE_animations.iml new file mode 100644 index 0000000..201c35f --- /dev/null +++ b/.idea/FOSSEE_animations.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..aaac02c --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,22 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/db.sqlite3 + + + + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/sqlite-jdbc-3.25.1.jar + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.25.1/license.txt + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f99b311 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3dd842f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/fossee_manim/static/css/index.css b/fossee_manim/static/css/index.css index 0a7895e..5994fb1 100644 --- a/fossee_manim/static/css/index.css +++ b/fossee_manim/static/css/index.css @@ -62,7 +62,7 @@ form.example::after { } #btns { - padding: 25 25 25 25; + padding:25 25 25 25; font-size: 155%; font-family: 'Lato', sans-serif; } @@ -124,3 +124,33 @@ hr { background-color: #ffe0b2; border-radius: 50%; } + +.footer{ + right: 0; + left: 0; + position: relative; + bottom: 0; + + owerflow: hidden; + padding: 95px; + text-align: center; +} +a{ + color:white; +} + +a:hover{ + color:white; + background-color: gray; +} + +.navbar-toggler-icon { + display: inline-block; + width: 1.5em; + height: 1.5em; + vertical-align: middle; + content: ""; + background: no-repeat center center; + background-size: 100% 100%; + background-color: white; +} \ No newline at end of file diff --git a/fossee_manim/templates/fossee_manim/about.html b/fossee_manim/templates/fossee_manim/about.html index 13b5a01..744aecf 100644 --- a/fossee_manim/templates/fossee_manim/about.html +++ b/fossee_manim/templates/fossee_manim/about.html @@ -5,8 +5,8 @@ {% endblock %} {% block content %} -
- +
+ {% comment %}style="padding-top:120px"> {% endcomment %}

About FOSSEE Animations

What do we do and why?

@@ -16,4 +16,7 @@
- {% endblock content %} +
+ {% endblock content %} +
+ diff --git a/fossee_manim/templates/fossee_manim/base.html b/fossee_manim/templates/fossee_manim/base.html index 06d7071..5e6326e 100644 --- a/fossee_manim/templates/fossee_manim/base.html +++ b/fossee_manim/templates/fossee_manim/base.html @@ -1,15 +1,16 @@ + {% block title %} - HomePage + HomePage {% endblock %} - + @@ -19,116 +20,110 @@ - - + + + - - {% block extra %} + +{% block extra %} - {% endblock %} +{% endblock %} - {% block header %} - - - -
-
- -
-
- {% endblock %} - - {% block content %} -

-

Base Template Content. Please override me

- {% endblock %} - + {% block content %} +

+

Base Template Content. Please override me

+ + {% endblock %} {% block footer %} - {% endblock footer %} - - - {% endblock %} diff --git a/fossee_manim/templates/fossee_manim/honorarium.html b/fossee_manim/templates/fossee_manim/honorarium.html index 3896717..5fff216 100644 --- a/fossee_manim/templates/fossee_manim/honorarium.html +++ b/fossee_manim/templates/fossee_manim/honorarium.html @@ -57,10 +57,10 @@

Kindly print out the forms below, fill the required fields and mail them to the address:

diff --git a/fossee_manim/templates/fossee_manim/index.html b/fossee_manim/templates/fossee_manim/index.html index a598513..4a9cc6d 100644 --- a/fossee_manim/templates/fossee_manim/index.html +++ b/fossee_manim/templates/fossee_manim/index.html @@ -60,7 +60,7 @@

HOW IT WORKS

Infographic
- Want to know more? Visit our Guidelines page! + Want to know more? Visit our page! {% endblock %} diff --git a/fossee_manim/templates/fossee_manim/logout.html b/fossee_manim/templates/fossee_manim/logout.html index b326547..03f655b 100644 --- a/fossee_manim/templates/fossee_manim/logout.html +++ b/fossee_manim/templates/fossee_manim/logout.html @@ -9,7 +9,7 @@

You have logged out successfully.

-

If you want to Login again please click here

+

If you want to Login again please click here


diff --git a/fossee_manim/templates/fossee_manim/outreach.html b/fossee_manim/templates/fossee_manim/outreach.html index bc85714..9299023 100644 --- a/fossee_manim/templates/fossee_manim/outreach.html +++ b/fossee_manim/templates/fossee_manim/outreach.html @@ -5,7 +5,7 @@ {% endblock %} {% block content %} -
+

FOSSEE Animations Outreach


diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index 7294d3a..2091a46 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -18,6 +18,7 @@ Created Date {% if request.user.profile.position == 'reviewer' %} Contributor Name + {% endif %} -- 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 --- .idea/dataSources.xml | 11 +++++++++++ fossee_manim/forms.py | 5 +++++ fossee_manim/models.py | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index aaac02c..4ab70d8 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -18,5 +18,16 @@ + + sqlite.xerial + true + true + $PROJECT_DIR$/fossee_anime/settings.py + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/db.sqlite3 + + + + \ No newline at end of file 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): diff --git a/fossee_manim/models.py b/fossee_manim/models.py index 273ebe6..e49726e 100644 --- a/fossee_manim/models.py +++ b/fossee_manim/models.py @@ -166,6 +166,12 @@ class Category(models.Model): return u"{0}".format(self.name) +# test +class Example(models.Model): + name = models.CharField(max_length=20) + tags = TaggableManager() + + class Animation(models.Model): title = models.CharField(max_length=255) contributor = models.ForeignKey(User, on_delete=models.CASCADE) -- 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 +++++++++++----------- fossee_manim/models.py | 134 +++++++++++++------------- fossee_manim/urls.py | 16 ++-- fossee_manim/views.py | 251 +++++++++++++++++++++++++++++-------------------- 4 files changed, 284 insertions(+), 231 deletions(-) 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 diff --git a/fossee_manim/models.py b/fossee_manim/models.py index e49726e..21b2a3c 100644 --- a/fossee_manim/models.py +++ b/fossee_manim/models.py @@ -13,7 +13,7 @@ import subprocess position_choices = ( ("contributor", "Contributor"), ("reviewer", "Reviewer") - ) +) department_choices = ( ("computer", "Computers"), @@ -29,7 +29,7 @@ department_choices = ( ("electronics", "Electronics"), ("energy science and engineering", "Energy Science and Engineering"), ("others", "Others") - ) +) title = ( ("Professor", "Prof."), @@ -40,7 +40,7 @@ title = ( ("Mr", "Mr."), ("Mrs", "Mrs."), ("Miss", "Ms."), - ) +) source = ( ("FOSSEE website", "FOSSEE website"), @@ -48,46 +48,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") +) status = ( ("pending", "Pending Acceptance"), @@ -107,6 +107,7 @@ def attachments(instance, filename): instance.animation.title, str(instance.animation.id), filename) + def validate_file_extension(value): import os from django.core.exceptions import ValidationError @@ -124,13 +125,13 @@ class Profile(models.Model): institute = models.CharField(max_length=150, blank=True) department = models.CharField(max_length=150, choices=department_choices) phone_number = models.CharField( - max_length=10, - validators=[RegexValidator( - regex=r'^.{10}$', message=( - "Phone number must be entered \ + max_length=10, + validators=[RegexValidator( + regex=r'^.{10}$', message=( + "Phone number must be entered \ in the format: '9999999999'.\ Up to 10 digits allowed.") - )], null=False) + )], null=False) position = models.CharField(max_length=32, choices=position_choices, default='contributor') how_did_you_hear_about_us = models.CharField(max_length=255, blank=True, @@ -140,21 +141,21 @@ class Profile(models.Model): state = models.CharField(max_length=255, choices=states, default="IN-MH") pincode = models.CharField(max_length=6, blank=True, validators=[RegexValidator( - regex=r'^.{6}$', message=( - "Please enter valid PINCODE" - ) - )]) + regex=r'^.{6}$', message=( + "Please enter valid PINCODE" + ) + )]) is_email_verified = models.BooleanField(default=False) activation_key = models.CharField(max_length=255, blank=True, null=True) key_expiry_time = models.DateTimeField(blank=True, null=True) def __str__(self): return u"id: {0}| {1} {2} | {3} ".format( - self.user.id, - self.user.first_name, - self.user.last_name, - self.user.email - ) + self.user.id, + self.user.first_name, + self.user.last_name, + self.user.email + ) class Category(models.Model): @@ -175,8 +176,11 @@ class Example(models.Model): class Animation(models.Model): title = models.CharField(max_length=255) contributor = models.ForeignKey(User, on_delete=models.CASCADE) - reviewer = models.ForeignKey(User, null=True, on_delete=models.CASCADE, - related_name="%(app_label)s_%(class)s_related") + reviewer = models.ForeignKey( + User, + null=True, + on_delete=models.CASCADE, + related_name="%(app_label)s_%(class)s_related") outline = models.TextField() status = models.CharField(max_length=255, choices=status) category = models.ForeignKey(Category, on_delete=models.CASCADE) @@ -209,16 +213,20 @@ class AnimationStats(models.Model): like = models.PositiveIntegerField(default=0) dislike = models.PositiveIntegerField(default=0) thumbnail = models.ImageField(null=True, blank=True, upload_to=attachments) - video_path = models.FileField(null=True, blank=True, upload_to=attachments, validators=[validate_file_extension]) + video_path = models.FileField( + null=True, + blank=True, + upload_to=attachments, + validators=[validate_file_extension]) def _create_thumbnail(self): video_path = self.video_path.path img_output = path.join( - tempfile.mkdtemp(), "{0}.jpg".format(self.animation.title) - ) + tempfile.mkdtemp(), "{0}.jpg".format(self.animation.title) + ) file_name = "{0}.jpg".format(self.animation.title) subprocess.call(['ffmpeg', '-i', video_path, '-ss', '00:00:02.000', - '-vframes', '1', img_output]) + '-vframes', '1', img_output]) if path.exists(img_output): que_file = open(img_output, 'rb') # Converting to Python file object with @@ -229,8 +237,8 @@ class AnimationStats(models.Model): def _create_ogv(self): video_input = self.video_path.path vid_output = path.join( - tempfile.mkdtemp(), "{0}.ogv".format(self.animation.title) - ) + tempfile.mkdtemp(), "{0}.ogv".format(self.animation.title) + ) file_name = "{0}.ogv".format(self.animation.title) subprocess.call(['ffmpeg', '-i', video_input, '-r', '24', vid_output]) if path.exists(vid_output): diff --git a/fossee_manim/urls.py b/fossee_manim/urls.py index dac61e2..a9af19e 100644 --- a/fossee_manim/urls.py +++ b/fossee_manim/urls.py @@ -26,17 +26,17 @@ urlpatterns = [ url(r'^faqs/$', views.faqs, name='faqs'), url(r'^search_category/(?P.+)$', views.search_category, name='search_category'), - url(r'^about/$',views.about, name='about'), - url(r'^outreach/$',views.outreach, name='outreach'), - url(r'^library/$',views.library, name='library'), - url(r'^libraryMath/$',views.libraryMath, name='libraryMath'), - url(r'^libraryPhys/$',views.libraryPhys, name='libraryPhys'), - url(r'^libraryCS/$',views.libraryCS, name='libraryCS'), + url(r'^about/$', views.about, name='about'), + url(r'^outreach/$', views.outreach, name='outreach'), + url(r'^library/$', views.library, name='library'), + url(r'^libraryMath/$', views.libraryMath, name='libraryMath'), + url(r'^libraryPhys/$', views.libraryPhys, name='libraryPhys'), + url(r'^libraryCS/$', views.libraryCS, name='libraryCS'), url(r'^explore/(?P.+)$', views.explore, name='explore'), ] urlpatterns += static( - settings.MEDIA_URL, - document_root=settings.MEDIA_ROOT + settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT ) diff --git a/fossee_manim/views.py b/fossee_manim/views.py index 3732ce7..4f3cf44 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -1,14 +1,14 @@ from os import listdir, path, sep, makedirs, remove from .forms import ( - UserRegistrationForm, UserLoginForm, - ProfileForm, AnimationProposal, - CommentForm, UploadAnimationForm - ) + UserRegistrationForm, UserLoginForm, + ProfileForm, AnimationProposal, + CommentForm, UploadAnimationForm +) from .models import ( - Profile, User, AnimationStats, - has_profile, Animation, Comment, - Category - ) + Profile, User, AnimationStats, + has_profile, Animation, Comment, + Category +) from datetime import datetime, date from django.contrib.auth import login, logout, authenticate from django.contrib.auth.decorators import login_required @@ -34,38 +34,44 @@ except ImportError: from io import BytesIO as string_io __author__ = "Akshen Doke" -__credits__ = ["Prabhu Ramachandran", "Aditya P.", "KhushalSingh Rajput", - "Prathamesh Salunke", "Purusharth Saxsena", "Sharanya Achut", "Ankit Javalkar" - ] +__credits__ = [ + "Prabhu Ramachandran", + "Aditya P.", + "KhushalSingh Rajput", + "Prathamesh Salunke", + "Purusharth Saxsena", + "Sharanya Achut", + "Ankit Javalkar"] + def makepath(proposal_data, reject=None): if not path.exists(path.join(settings.MEDIA_ROOT, - proposal_data.category.name)): + proposal_data.category.name)): makedirs(path.join(settings.MEDIA_ROOT, - proposal_data.category.name)) + proposal_data.category.name)) if reject: try: shutil.rmtree(path.join( - settings.MEDIA_ROOT, proposal_data.category.name, - proposal_data.title.replace(" ", "_") - )) - except: + settings.MEDIA_ROOT, proposal_data.category.name, + proposal_data.title.replace(" ", "_") + )) + except BaseException: logging.info("Proposal rejected") - else: makedirs(path.join(settings.MEDIA_ROOT, proposal_data.category.name, - proposal_data.title.replace(" ", "_") - )) + proposal_data.title.replace(" ", "_") + )) def check_repo(link): try: return (get(link).status_code == 200) - except: + except BaseException: return False + def is_email_checked(user): if hasattr(user, 'profile'): return True if user.profile.is_email_verified else False @@ -85,7 +91,9 @@ def index(request): categories = Category.objects.all() if user.is_authenticated() and is_email_checked(user): return redirect('/proposal_status/') - return render(request, "fossee_manim/index.html", {"categories": categories}) + return render(request, + "fossee_manim/index.html", + {"categories": categories}) def is_reviewer(user): @@ -116,8 +124,8 @@ def user_login(request): return render(request, 'fossee_manim/login.html', {"form": form}) else: form = UserLoginForm() - return render(request, 'fossee_manim/login.html', {"form": form, - 'categories': categories }) + return render(request, 'fossee_manim/login.html', + {"form": form, 'categories': categories}) def user_logout(request): @@ -125,7 +133,7 @@ def user_logout(request): categories = Category.objects.all() logout(request) return render(request, 'fossee_manim/logout.html', - {'categories': categories }) + {'categories': categories}) def activate_user(request, key=None): @@ -133,25 +141,25 @@ def activate_user(request, key=None): if is_superuser(user): return redirect("/admin") if key is None: - if user.is_authenticated() and user.profile.is_email_verified==0 and \ - timezone.now() > user.profile.key_expiry_time: + if user.is_authenticated() and user.profile.is_email_verified == 0 and \ + timezone.now() > user.profile.key_expiry_time: status = "1" Profile.objects.get(user_id=user.profile.user_id).delete() User.objects.get(id=user.profile.user_id).delete() return render(request, 'fossee_manim/activation.html', - {'status':status}) - elif user.is_authenticated() and user.profile.is_email_verified==0: + {'status': status}) + elif user.is_authenticated() and user.profile.is_email_verified == 0: return render(request, 'fossee_manim/activation.html') elif user.is_authenticated() and user.profile.is_email_verified: status = "2" return render(request, 'fossee_manim/activation.html', - {'status':status}) + {'status': status}) else: return redirect('/register/') try: user = Profile.objects.get(activation_key=key) - except: + except BaseException: return redirect('/register/') if key == user.activation_key: @@ -162,7 +170,7 @@ def activate_user(request, key=None): logout(request) return redirect('/logout/') return render(request, 'fossee_manim/activation.html', - {"status": status}) + {"status": status}) def user_register(request): @@ -176,9 +184,9 @@ def user_register(request): login(request, new_user) user_position = request.user.profile.position send_email( - request, call_on='Registration', - key=key - ) + request, call_on='Registration', + key=key + ) return render(request, 'fossee_manim/activation.html') else: @@ -195,14 +203,19 @@ def user_register(request): elif request.user.is_authenticated(): return render(request, 'fossee_manim/activation.html') form = UserRegistrationForm() - return render(request, "fossee_manim/register.html", {'form': form, 'categories': categories}) + return render(request, "fossee_manim/register.html", + {'form': form, 'categories': categories}) def explore(request, category): - categories = Category.objects.all() #not related to category below - videos = AnimationStats.objects.filter(animation__category__name= category , animation__status="released") + categories = Category.objects.all() # not related to category below + videos = AnimationStats.objects.filter( + animation__category__name=category, + animation__status="released") + + return render(request, "fossee_manim/explore.html", + {"videos": videos, "categories": categories}) - return render(request, "fossee_manim/explore.html", {"videos": videos, "categories": categories}) @login_required def view_profile(request): @@ -221,7 +234,7 @@ def view_profile(request): try: logout(request) return redirect('/login/') - except: + except BaseException: return redirect('/register/') @@ -242,7 +255,7 @@ def edit_profile(request): try: logout(request) return redirect('/login/') - except: + except BaseException: return redirect('/register/') context = {'template': template} @@ -262,17 +275,16 @@ def edit_profile(request): form_data.save() return render( - request, 'fossee_manim/profile_updated.html', - {'categories': categories} - ) + request, 'fossee_manim/profile_updated.html', + {'categories': categories} + ) else: context['form'] = form return render(request, 'fossee_manim/edit_profile.html', context) else: form = ProfileForm(user=user, instance=profile) - return render(request, 'fossee_manim/edit_profile.html', {'form': form, - 'categories': categories} - ) + return render(request, 'fossee_manim/edit_profile.html', + {'form': form, 'categories': categories}) @login_required @@ -289,12 +301,12 @@ def send_proposal(request): form.save() else: return render(request, 'fossee_manim/send_proposal.html', - {'form': form, 'categories': categories}) + {'form': form, 'categories': categories}) return redirect('/proposal_status/') else: form = AnimationProposal() return render(request, 'fossee_manim/send_proposal.html', - {'form': form, 'categories': categories}) + {'form': form, 'categories': categories}) else: return redirect('/register/') @@ -306,7 +318,8 @@ def proposal_status(request): profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': - animations = Animation.objects.filter(contributor_id=user).order_by('-created') + animations = Animation.objects.filter( + contributor_id=user).order_by('-created') else: animations = Animation.objects.order_by('-created') # print(animations) @@ -315,18 +328,18 @@ def proposal_status(request): paginator = Paginator(list(animations), 9) page = request.GET.get('page') try: - anime = paginator.page(page) + anime = paginator.page(page) print(animations.count(), anime) except PageNotAnInteger: # If page is not an integer, deliver first page. - anime = paginator.page(1) + anime = paginator.page(1) except EmptyPage: # If page is out of range(e.g 999999), deliver last page. - anime = paginator.page(paginator.num_pages) + anime = paginator.page(paginator.num_pages) return render(request, 'fossee_manim/proposal_status.html', - {'anime': anime, - 'categories': categories}) + {'anime': anime, + 'categories': categories}) else: return redirect('/login/') @@ -341,15 +354,16 @@ def edit_proposal(request, proposal_id=None): upload_form = UploadAnimationForm() categories = Category.objects.all() video = AnimationStats.objects.filter(animation=proposal_id) - if len(video)>0: - msg = ('Previously a video was uploaded for '+ video[0].animation.title) + if len(video) > 0: + msg = ( + 'Previously a video was uploaded for ' + + video[0].animation.title) else: msg = ('No video uploaded') try: - comments = Comment.objects.filter(animation_id=proposal_id).order_by( - '-created_date' - ) - except: + comments = Comment.objects.filter( + animation_id=proposal_id).order_by('-created_date') + except BaseException: comments = None if request.method == 'POST': text = request.POST.get('comment') @@ -361,16 +375,16 @@ def edit_proposal(request, proposal_id=None): if status1: proposal.status = 'released' send_email(request, call_on='released', - contributor=proposal.contributor) + contributor=proposal.contributor) elif status3: send_email(request, call_on='proposal_form', - contributor=proposal.contributor) + contributor=proposal.contributor) return redirect('/proposal_status/') else: proposal.status = 'rejected' makepath(proposal, reject=1) send_email(request, call_on='rejected', - contributor=proposal.contributor) + contributor=proposal.contributor) proposal.reviewer = user proposal.save() return redirect('/proposal_status/') @@ -385,8 +399,8 @@ def edit_proposal(request, proposal_id=None): proposal.status = 'changes' proposal.save() send_email(request, call_on='changes', - contributor=proposal.contributor, - proposal=proposal) + contributor=proposal.contributor, + proposal=proposal) form_data.save() return redirect('/edit_proposal/{}'.format(proposal_id)) proposal_form = AnimationProposal(request.POST, instance=proposal) @@ -403,25 +417,25 @@ def edit_proposal(request, proposal_id=None): return redirect('/register/') if comments is not None: - #Show upto 12 Workshops per page - paginator = Paginator(comments, 9) - page = request.GET.get('page') - try: - comments = paginator.page(page) - except PageNotAnInteger: - #If page is not an integer, deliver first page. - comments = paginator.page(1) - except EmptyPage: - #If page is out of range(e.g 999999), deliver last page. - comments = paginator.page(paginator.num_pages) + # Show upto 12 Workshops per page + paginator = Paginator(comments, 9) + page = request.GET.get('page') + try: + comments = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + comments = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + comments = paginator.page(paginator.num_pages) return render(request, 'fossee_manim/edit_proposal.html', - {'proposal_form': proposal_form, - "comments": comments, - "comment_form": comment_form, - "upload_form": upload_form, - 'video': video, - 'categories': categories, - 'msg': msg}) + {'proposal_form': proposal_form, + "comments": comments, + "comment_form": comment_form, + "upload_form": upload_form, + 'video': video, + 'categories': categories, + 'msg': msg}) def search(request): @@ -429,8 +443,11 @@ def search(request): if request.method == 'POST': word = request.POST.get('sbox') anime_list = AnimationStats.objects.filter( - Q(animation__title__contains=word) | Q(animation__outline__contains=word) - | Q(animation__category__name__contains=word) | Q(animation__subcategory__contains=word), + Q( + animation__title__contains=word) | Q( + animation__outline__contains=word) | Q( + animation__category__name__contains=word) | Q( + animation__subcategory__contains=word), animation__status='released') return render(request, 'fossee_manim/search_results.html', @@ -444,16 +461,16 @@ def upload_animation(request, proposal_id=None): if request.method == 'POST': proposal = Animation.objects.get(id=proposal_id) anim_stats = UploadAnimationForm(request.POST or None, - request.FILES or None) + request.FILES or None) if anim_stats.is_valid(): try: anim = AnimationStats.objects.filter( - animation=proposal) + animation=proposal) if anim.exists(): anobj = anim.first() try: remove(anobj.thumbnail.path) - except: + except BaseException: pass remove(anobj.video_path.path) anobj.delete() @@ -464,7 +481,7 @@ def upload_animation(request, proposal_id=None): animation=proposal, video_path=request.FILES['video_path']) anobj._create_thumbnail() return render(request, 'fossee_manim/upload_success.html') - except: + except BaseException: messages.warning(request, 'Please Upload a valid File') return redirect('/edit_proposal/{}'.format(proposal_id)) @@ -480,15 +497,15 @@ def video(request, aid=None): if len(video): comment_form = CommentForm() # if views crosses limit comment the line below - video.update(views=F('views')+1) - video.update(like=F('like')+1) + video.update(views=F('views') + 1) + video.update(like=F('like') + 1) anim_list = AnimationStats.objects.filter(animation__status="released") suggestion_list = [x for x in anim_list if ( x.animation.category == video[0].animation.category)] reviewer_id = video[0].animation.reviewer.id comment_list = Comment.objects.filter(animation=video[0].animation) comments = [x for x in comment_list if x.animation_status not in - ('pending', 'changes')] + ('pending', 'changes')] if request.method == 'POST': if is_email_checked(user): comment_form = CommentForm(request.POST) @@ -503,7 +520,7 @@ def video(request, aid=None): else: return redirect('/view_profile/') - if len(suggestion_list)>3: + if len(suggestion_list) > 3: suggestion_list = sample(suggestion_list, 3) else: suggestion_list = [x for x in anim_list if x.id != int(aid)][:3] @@ -527,34 +544,62 @@ def search_category(request, cat=None): def guidelines(request): categories = Category.objects.all() - return render(request, 'fossee_manim/guidelines.html', {'categories': categories}) + return render(request, + 'fossee_manim/guidelines.html', + {'categories': categories}) + def about(request): categories = Category.objects.all() - return render(request, 'fossee_manim/about.html', {'categories': categories}) + return render(request, + 'fossee_manim/about.html', + {'categories': categories}) + def honorarium(request): categories = Category.objects.all() - return render(request, 'fossee_manim/honorarium.html', {'categories': categories}) + return render(request, + 'fossee_manim/honorarium.html', + {'categories': categories}) + def faqs(request): categories = Category.objects.all() - return render(request, 'fossee_manim/faqs.html', {'categories': categories}) + return render(request, + 'fossee_manim/faqs.html', + {'categories': categories}) + def outreach(request): categories = Category.objects.all() - return render(request, 'fossee_manim/outreach.html', {'categories': categories}) + return render(request, + 'fossee_manim/outreach.html', + {'categories': categories}) + def library(request): categories = Category.objects.all() - return render(request, 'fossee_manim/library.html', {'categories': categories}) + return render(request, + 'fossee_manim/library.html', + {'categories': categories}) + def libraryMath(request): categories = Category.objects.all() - return render(request, 'fossee_manim/libraryMath.html', {'categories': categories}) + return render(request, + 'fossee_manim/libraryMath.html', + {'categories': categories}) + + def libraryPhys(request): categories = Category.objects.all() - return render(request, 'fossee_manim/libraryPhys.html', {'categories': categories}) + return render(request, + 'fossee_manim/libraryPhys.html', + {'categories': categories}) + + def libraryCS(request): categories = Category.objects.all() - return render(request, 'fossee_manim/libraryCS.html', {'categories': categories}) + return render(request, + 'fossee_manim/libraryCS.html', + {'categories': categories}) -- cgit