From 1a42123ca12eb45e0163cfb0d1637fdfe805b658 Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Thu, 3 Oct 2019 15:25:52 +0530 Subject: Segregate proposals based on proposal status --- .idea/.gitignore | 6 + .idea/FOSSEE_animations.iml | 31 ++++++ .idea/dataSources.xml | 16 +++ .idea/inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .../templates/fossee_manim/proposal_status.html | 44 ++++++-- fossee_manim/urls.py | 4 + fossee_manim/views.py | 123 +++++++++++++++++++++ 10 files changed, 244 insertions(+), 7 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..455ff31 --- /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..954cdfa --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,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/.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..8656114 --- /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/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index c41a195..a18dc41 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -10,6 +10,36 @@

Proposal Status


+
+
+

Sort by :

+
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+
+
@@ -18,7 +48,7 @@ {% if request.user.profile.position == 'reviewer' %} - + {# #} {% endif %} @@ -36,18 +66,18 @@ {% if request.user.profile.position == 'reviewer' %} - + {# #} {% endif %} - {% if request.user.profile.position == 'reviewer' %} - - {% endif %} + {% if request.user.profile.position == 'reviewer' %} + + {% endif %} {% endfor %} diff --git a/fossee_manim/urls.py b/fossee_manim/urls.py index 1947cba..5c87869 100644 --- a/fossee_manim/urls.py +++ b/fossee_manim/urls.py @@ -36,6 +36,10 @@ urlpatterns = [ name='explore'), url(r'^delete_proposal/([1-9][0-9]*)$',views.delete_proposal,name='delete_proposal'), url(r'^delete_proposal_info/([1-9][0-9]*)$',views.delete_proposal_info,name='delete_proposal_info'), + url(r'^sortproposal_released/$',views.sortproposal_released,name='sortproposal_released'), + url(r'^sortproposal_rejected/$',views.sortproposal_rejected,name='sortproposal_rejected'), + url(r'^sortproposal_changes/',views.sortproposal_changes,name='sortproposal_changes'), + url(r'^sortproposal_pending/$',views.sortproposal_pending,name='sortproposal_pending'), ] urlpatterns += static( diff --git a/fossee_manim/views.py b/fossee_manim/views.py index faa93b9..fc307f2 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -334,6 +334,129 @@ def proposal_status(request): else: return redirect('/login/') +@login_required +def sortproposal_released(request): + user = request.user + if is_email_checked(user) and user.is_authenticated(): + profile = Profile.objects.get(user_id=user) + categories = Category.objects.all() + if profile.position == 'contributor': + animations = Animation.objects.filter(contributor_id=user,status='released').order_by('-created') + else: + animations = Animation.objects.filter(status='released').order_by('-created') + # print(animations) + + # Show upto 9 proposals per page + paginator = Paginator(list(animations), 9) + page = request.GET.get('page') + try: + anime = paginator.page(page) + print(animations.count(), anime) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + anime = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + anime = paginator.page(paginator.num_pages) + + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, + 'categories': categories}) + else: + return redirect('/login/') + +@login_required +def sortproposal_rejected(request): + user = request.user + if is_email_checked(user) and user.is_authenticated(): + profile = Profile.objects.get(user_id=user) + categories = Category.objects.all() + if profile.position == 'contributor': + animations = Animation.objects.filter(contributor_id=user,status='rejected').order_by('-created') + else: + animations = Animation.objects.filter(status='rejected').order_by('-created') + # print(animations) + + # Show upto 9 proposals per page + paginator = Paginator(list(animations), 9) + page = request.GET.get('page') + try: + anime = paginator.page(page) + print(animations.count(), anime) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + anime = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + anime = paginator.page(paginator.num_pages) + + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, + 'categories': categories}) + else: + return redirect('/login/') + +@login_required +def sortproposal_changes(request): + user = request.user + if is_email_checked(user) and user.is_authenticated(): + profile = Profile.objects.get(user_id=user) + categories = Category.objects.all() + if profile.position == 'contributor': + animations = Animation.objects.filter(contributor_id=user,status='changes').order_by('-created') + else: + animations = Animation.objects.filter(status='changes').order_by('-created') + # print(animations) + + # Show upto 9 proposals per page + paginator = Paginator(list(animations), 9) + page = request.GET.get('page') + try: + anime = paginator.page(page) + print(animations.count(), anime) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + anime = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + anime = paginator.page(paginator.num_pages) + + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, + 'categories': categories}) + else: + return redirect('/login/') + +@login_required +def sortproposal_pending(request): + user = request.user + if is_email_checked(user) and user.is_authenticated(): + profile = Profile.objects.get(user_id=user) + categories = Category.objects.all() + if profile.position == 'contributor': + animations = Animation.objects.filter(contributor_id=user,status='pending').order_by('-created') + else: + animations = Animation.objects.filter(status='pending').order_by('-created') + # print(animations) + + # Show upto 9 proposals per page + paginator = Paginator(list(animations), 9) + page = request.GET.get('page') + try: + anime = paginator.page(page) + print(animations.count(), anime) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + anime = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + anime = paginator.page(paginator.num_pages) + + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, + 'categories': categories}) + else: + return redirect('/login/') @login_required def edit_proposal(request, proposal_id=None): -- cgit From 56ecd86e40d5e1b609e19725fea84c1d959d8727 Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Fri, 4 Oct 2019 11:37:37 +0530 Subject: search option for proposal page --- .../templates/fossee_manim/proposal_status.html | 13 ++++++++--- fossee_manim/urls.py | 1 + fossee_manim/views.py | 25 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index a18dc41..19a780d 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -11,12 +11,19 @@

Proposal Status


-
-

Sort by :

+
+
+ {% csrf_token %} + + +
diff --git a/fossee_manim/urls.py b/fossee_manim/urls.py index 5c87869..9615d47 100644 --- a/fossee_manim/urls.py +++ b/fossee_manim/urls.py @@ -40,6 +40,7 @@ urlpatterns = [ url(r'^sortproposal_rejected/$',views.sortproposal_rejected,name='sortproposal_rejected'), url(r'^sortproposal_changes/',views.sortproposal_changes,name='sortproposal_changes'), url(r'^sortproposal_pending/$',views.sortproposal_pending,name='sortproposal_pending'), + url(r'^search_proposal/$', views.search_proposal, name='search_proposal'), ] urlpatterns += static( diff --git a/fossee_manim/views.py b/fossee_manim/views.py index fc307f2..68d2c84 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -601,6 +601,31 @@ def search(request): return render(request, 'fossee_manim/search_results.html', {'s_result': anime_list, 'categories': categories}) +# search results for proposal +def search_proposal(request): + user = request.user + if is_email_checked(user) and user.is_authenticated(): + profile = Profile.objects.get(user_id=user) + categories = Category.objects.all() + word = request.POST.get('sbox') + animations = Animation.objects.filter(title=word) + paginator = Paginator(list(animations), 9) + page = request.GET.get('page') + try: + anime = paginator.page(page) + print(animations.count(), anime) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + anime = paginator.page(1) + except EmptyPage: + # If page is out of range(e.g 999999), deliver last page. + anime = paginator.page(paginator.num_pages) + + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, + 'categories': categories}) + else: + return redirect('/login/') @login_required def upload_animation(request, proposal_id=None): -- 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_anime/settings.py | 2 +- fossee_manim/forms.py | 77 ++++++- fossee_manim/models.py | 19 +- .../templates/fossee_manim/edit_proposal.html | 222 +++++++++++---------- .../templates/fossee_manim/proposal_status.html | 24 ++- fossee_manim/views.py | 6 +- 6 files changed, 225 insertions(+), 125 deletions(-) diff --git a/fossee_anime/settings.py b/fossee_anime/settings.py index 8b5f93a..82265ba 100644 --- a/fossee_anime/settings.py +++ b/fossee_anime/settings.py @@ -49,7 +49,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'taggit', - 'simple_history' + 'simple_history', ] MIDDLEWARE_CLASSES = [ 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): """ """ diff --git a/fossee_manim/models.py b/fossee_manim/models.py index a6f68c2..f400818 100644 --- a/fossee_manim/models.py +++ b/fossee_manim/models.py @@ -115,6 +115,13 @@ def validate_file_extension(value): if not ext.lower() in valid_extensions: raise ValidationError(u'Unsupported file extension.') +def validate_img_extension(value): + import os + from django.core.exceptions import ValidationError + ext = os.path.splitext(value.name)[1] # [0] returns path+filename + valid_extensions = ['.jpg','.jpeg','.png'] + if not ext.lower() in valid_extensions: + raise ValidationError(u'Unsupported file extension.') class Profile(models.Model): """Profile for users(instructors and coordinators)""" @@ -172,19 +179,27 @@ class Animation(models.Model): reviewer = models.ForeignKey(User, null=True, on_delete=models.CASCADE, related_name="%(app_label)s_%(class)s_related") outline = models.TextField() - # concepts = models.TextField() - # audience=models.TextField() status = models.CharField(max_length=255, choices=status) category = models.ForeignKey(Category, on_delete=models.CASCADE) subcategory = models.CharField(max_length=255, blank=True) created = models.DateTimeField(default=timezone.now) tags = TaggableManager() history = HistoricalRecords() + # modifications + concepts=models.TextField(null=True,blank=True) + audience=models.TextField(null=True,blank=True) + reference=models.TextField(null=True,blank=True) + tools=models.TextField(null=True,blank=True) + detaled_description=models.TextField(null=True,blank=True) + link=models.CharField(max_length=255, blank=True) + sketch=models.ImageField(null=True, blank=True, upload_to=attachments, validators=[validate_img_extension]) def __str__(self): return u"{0} | {1}".format(self.title, self.status) + + class Comment(models.Model): comment = models.TextField() commentor = models.ForeignKey(User, on_delete=models.CASCADE) diff --git a/fossee_manim/templates/fossee_manim/edit_proposal.html b/fossee_manim/templates/fossee_manim/edit_proposal.html index 8543014..49bbfd0 100644 --- a/fossee_manim/templates/fossee_manim/edit_proposal.html +++ b/fossee_manim/templates/fossee_manim/edit_proposal.html @@ -1,131 +1,137 @@ {% extends 'fossee_manim/base.html' %} {% block title %} -Edit Proposal + Edit Proposal {% endblock %} {% block content %} - -
-
- {% if messages %} -
    - {% for message in messages %} -
    -
  • {{ message }} -
  • -
    - {% endfor %} -
- {% endif %} + +
+
+ {% if messages %} +
    + {% for message in messages %} +
    +
  • {{ message }} +
  • +
    + {% endfor %} +
+ {% endif %} -
- {% csrf_token %} + + {% csrf_token %} -
Created DateContributor NameMail StatusMail Status
{{ an.created }}{{ an.contributor.get_full_name }}{{ an.contributor.get_full_name }}{{ an.contributor.get_full_name }} - - + +
- {{ proposal_form.as_table }} -
+ + + {{ proposal_form.as_table }} +
PROPOSAL DETAILS
-
- -
- -
+
+ +
+ +
- {% if proposal_form.instance.status == 'changes' and request.user.profile.position == 'contributor' %} -
- {% csrf_token %} - -
- {% elif proposal_form.instance.status == 'pending' and request.user.profile.position == 'contributor' %} -

Awaiting Reviewer's Moderation

-
Further details regarding the second stage of Proposal will be shared with you over the email shortly
+ {% if proposal_form.instance.status == 'changes' and request.user.profile.position == 'contributor' %} +
+ {% csrf_token %} + +
+ {% elif proposal_form.instance.status == 'pending' and request.user.profile.position == 'contributor' %} +

Awaiting Reviewer's Moderation

+
Further details regarding the second stage of Proposal will be shared with you over the email + shortly
- {% else %} - - {% endif %} + {% else %} + + {% endif %} -

- {% if request.user.profile.position == 'reviewer' %} -
- {% csrf_token %} -
-
- - - -
-
-
- {% endif %} -

+

+ {% if request.user.profile.position == 'reviewer' %} +
+ {% csrf_token %} +
+
+ + + {# #} +
+
+
+ {% endif %} +

-

Comments

-
-
-
- {% csrf_token %} - {{ comment_form.as_p }} - -
+

Comments

+
+
+
+ {% csrf_token %} + {{ comment_form.as_p }} + +
-
-
- - {% for comment in comments %} - - - - - - {% endfor %} -
-
{{ comment.commentor.profile.user.get_full_name }} | {{ comment.created_date | date }}
-
{{ comment.comment }}
-
-
+ + {% for comment in comments %} + + + + + + {% endfor %} +
+
{{ comment.commentor.profile.user.get_full_name }} | {{ comment.created_date | date }}
+
{{ comment.comment }}
+
+
-

-
+

+ - -
- +
+
- + {% endblock %} \ No newline at end of file diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index 19a780d..fa28e87 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -55,7 +55,6 @@ Created Date {% if request.user.profile.position == 'reviewer' %} Contributor Name - {# Mail Status#} {% endif %} @@ -71,15 +70,20 @@ {{ an.status }} {% endif %} {{ an.created }} - {% if request.user.profile.position == 'reviewer' %} - {{ an.contributor.get_full_name }} - {# {{ an.contributor.get_full_name }}#} - {% endif %} - - - + + {% if request.user.profile.position == 'reviewer' %} + {{ an.contributor.get_full_name }} + {% endif %} + + + {% if an.status == 'released' or request.user.profile.position == 'reviewer'%} + + + + {% endif %} + {% if request.user.profile.position == 'reviewer' %} diff --git a/fossee_manim/views.py b/fossee_manim/views.py index 68d2c84..59eac34 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -2,7 +2,7 @@ from os import listdir, path, sep, makedirs, remove from .forms import ( UserRegistrationForm, UserLoginForm, ProfileForm, AnimationProposal, - CommentForm, UploadAnimationForm + CommentForm, UploadAnimationForm,AnimationProposal_edit ) from .models import ( Profile, User, AnimationStats, @@ -464,7 +464,7 @@ def edit_proposal(request, proposal_id=None): if is_email_checked(user) and user.is_authenticated(): comment_form = CommentForm() proposal = Animation.objects.get(id=proposal_id) - proposal_form = AnimationProposal(instance=proposal) + proposal_form = AnimationProposal_edit(instance=proposal) upload_form = UploadAnimationForm() categories = Category.objects.all() video = AnimationStats.objects.filter(animation=proposal_id) @@ -516,7 +516,7 @@ def edit_proposal(request, proposal_id=None): proposal=proposal) form_data.save() return redirect('/edit_proposal/{}'.format(proposal_id)) - proposal_form = AnimationProposal(request.POST, instance=proposal) + proposal_form = AnimationProposal_edit(request.POST, instance=proposal) if proposal_form.is_valid(): p_f = proposal_form.save(commit=False) p_f.contributor = user -- cgit From e52409e43fffb75dfc31a0d3ad2d8bedac912694 Mon Sep 17 00:00:00 2001 From: Alwin1847207 Date: Fri, 4 Oct 2019 15:19:50 +0530 Subject: modification in proposal status page --- fossee_manim/templates/fossee_manim/proposal_status.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index fa28e87..2b5387f 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -76,7 +76,7 @@ {% endif %} - {% if an.status == 'released' or request.user.profile.position == 'reviewer'%} + {% if an.status == 'released' or an.status == 'changes' or request.user.profile.position == 'reviewer'%} +
diff --git a/fossee_manim/views.py b/fossee_manim/views.py index 59eac34..314b83f 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -2,7 +2,7 @@ from os import listdir, path, sep, makedirs, remove from .forms import ( UserRegistrationForm, UserLoginForm, ProfileForm, AnimationProposal, - CommentForm, UploadAnimationForm,AnimationProposal_edit + CommentForm, UploadAnimationForm, AnimationProposal_edit ) from .models import ( Profile, User, AnimationStats, @@ -334,6 +334,8 @@ def proposal_status(request): else: return redirect('/login/') + +# this method return the proposal in the status of released @login_required def sortproposal_released(request): user = request.user @@ -341,8 +343,11 @@ def sortproposal_released(request): profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': - animations = Animation.objects.filter(contributor_id=user,status='released').order_by('-created') + # filtering with the proposal status + animations = Animation.objects.filter(contributor_id=user, + status='released').order_by('-created') else: + # filtering with the proposal status animations = Animation.objects.filter(status='released').order_by('-created') # print(animations) @@ -365,6 +370,8 @@ def sortproposal_released(request): else: return redirect('/login/') + +# this method return the proposal in the status of rejected @login_required def sortproposal_rejected(request): user = request.user @@ -372,8 +379,11 @@ def sortproposal_rejected(request): profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': - animations = Animation.objects.filter(contributor_id=user,status='rejected').order_by('-created') + # filtering with the proposal status + animations = Animation.objects.filter(contributor_id=user, + status='rejected').order_by('-created') else: + # filtering with the proposal status animations = Animation.objects.filter(status='rejected').order_by('-created') # print(animations) @@ -396,6 +406,8 @@ def sortproposal_rejected(request): else: return redirect('/login/') + +# this method return the proposal in the status of changes @login_required def sortproposal_changes(request): user = request.user @@ -403,8 +415,11 @@ def sortproposal_changes(request): profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': - animations = Animation.objects.filter(contributor_id=user,status='changes').order_by('-created') + # filtering with the proposal status + animations = Animation.objects.filter(contributor_id=user, + status='changes').order_by('-created') else: + # filtering with the proposal status animations = Animation.objects.filter(status='changes').order_by('-created') # print(animations) @@ -427,6 +442,8 @@ def sortproposal_changes(request): else: return redirect('/login/') + +# this method return the proposal in the status of pending @login_required def sortproposal_pending(request): user = request.user @@ -434,8 +451,11 @@ def sortproposal_pending(request): profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': - animations = Animation.objects.filter(contributor_id=user,status='pending').order_by('-created') + # filtering with the proposal status + animations = Animation.objects.filter(contributor_id=user, + status='pending').order_by('-created') else: + # filtering with the proposal status animations = Animation.objects.filter(status='pending').order_by('-created') # print(animations) @@ -551,6 +571,7 @@ def edit_proposal(request, proposal_id=None): 'msg': msg}) +# this method is used to return the details the proposal selected to delete @login_required def delete_proposal(request, proposal_id=None): user = request.user @@ -562,12 +583,15 @@ def delete_proposal(request, proposal_id=None): return redirect('/register/') +# this method is used to delete the selected proposal by the reviever @login_required def delete_proposal_info(request, proposal_id=None): user = request.user if is_email_checked(user) and user.is_authenticated(): + # delete the selected proposal proposal = Animation.objects.get(id=proposal_id) proposal.delete() + # loading the proposal page to redirect after deleting one proposal profile = Profile.objects.get(user_id=user) categories = Category.objects.all() if profile.position == 'contributor': -- 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 ++++++++++++++++++++++++-------------------------- fossee_manim/urls.py | 28 ++++---- fossee_manim/views.py | 153 +++++++++++++++++++++++++--------------- 3 files changed, 204 insertions(+), 166 deletions(-) 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): diff --git a/fossee_manim/urls.py b/fossee_manim/urls.py index 9615d47..372ebe7 100644 --- a/fossee_manim/urls.py +++ b/fossee_manim/urls.py @@ -26,24 +26,24 @@ 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'), - url(r'^delete_proposal/([1-9][0-9]*)$',views.delete_proposal,name='delete_proposal'), - url(r'^delete_proposal_info/([1-9][0-9]*)$',views.delete_proposal_info,name='delete_proposal_info'), - url(r'^sortproposal_released/$',views.sortproposal_released,name='sortproposal_released'), - url(r'^sortproposal_rejected/$',views.sortproposal_rejected,name='sortproposal_rejected'), - url(r'^sortproposal_changes/',views.sortproposal_changes,name='sortproposal_changes'), - url(r'^sortproposal_pending/$',views.sortproposal_pending,name='sortproposal_pending'), + url(r'^delete_proposal/([1-9][0-9]*)$', views.delete_proposal, name='delete_proposal'), + url(r'^delete_proposal_info/([1-9][0-9]*)$', views.delete_proposal_info, name='delete_proposal_info'), + url(r'^sortproposal_released/$', views.sortproposal_released, name='sortproposal_released'), + url(r'^sortproposal_rejected/$', views.sortproposal_rejected, name='sortproposal_rejected'), + url(r'^sortproposal_changes/', views.sortproposal_changes, name='sortproposal_changes'), + url(r'^sortproposal_pending/$', views.sortproposal_pending, name='sortproposal_pending'), url(r'^search_proposal/$', views.search_proposal, name='search_proposal'), ] 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 314b83f..e7a3aee 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -35,9 +35,14 @@ 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): @@ -52,10 +57,9 @@ def makepath(proposal_data, reject=None): settings.MEDIA_ROOT, proposal_data.category.name, proposal_data.title.replace(" ", "_") )) - except: + except BaseException: logging.info("Proposal rejected") - else: makedirs(path.join(settings.MEDIA_ROOT, proposal_data.category.name, proposal_data.title.replace(" ", "_") @@ -65,7 +69,7 @@ def makepath(proposal_data, reject=None): def check_repo(link): try: return (get(link).status_code == 200) - except: + except BaseException: return False @@ -88,7 +92,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): @@ -119,8 +125,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): @@ -154,7 +160,7 @@ def activate_user(request, key=None): try: user = Profile.objects.get(activation_key=key) - except: + except BaseException: return redirect('/register/') if key == user.activation_key: @@ -198,14 +204,18 @@ 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") + 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 @@ -225,7 +235,7 @@ def view_profile(request): try: logout(request) return redirect('/login/') - except: + except BaseException: return redirect('/register/') @@ -246,7 +256,7 @@ def edit_profile(request): try: logout(request) return redirect('/login/') - except: + except BaseException: return redirect('/register/') context = {'template': template} @@ -274,9 +284,8 @@ def edit_profile(request): 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 @@ -310,7 +319,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) @@ -344,11 +354,12 @@ def sortproposal_released(request): categories = Category.objects.all() if profile.position == 'contributor': # filtering with the proposal status - animations = Animation.objects.filter(contributor_id=user, - status='released').order_by('-created') + animations = Animation.objects.filter( + contributor_id=user, status='released').order_by('-created') else: # filtering with the proposal status - animations = Animation.objects.filter(status='released').order_by('-created') + animations = Animation.objects.filter( + status='released').order_by('-created') # print(animations) # Show upto 9 proposals per page @@ -380,11 +391,12 @@ def sortproposal_rejected(request): categories = Category.objects.all() if profile.position == 'contributor': # filtering with the proposal status - animations = Animation.objects.filter(contributor_id=user, - status='rejected').order_by('-created') + animations = Animation.objects.filter( + contributor_id=user, status='rejected').order_by('-created') else: # filtering with the proposal status - animations = Animation.objects.filter(status='rejected').order_by('-created') + animations = Animation.objects.filter( + status='rejected').order_by('-created') # print(animations) # Show upto 9 proposals per page @@ -416,11 +428,12 @@ def sortproposal_changes(request): categories = Category.objects.all() if profile.position == 'contributor': # filtering with the proposal status - animations = Animation.objects.filter(contributor_id=user, - status='changes').order_by('-created') + animations = Animation.objects.filter( + contributor_id=user, status='changes').order_by('-created') else: # filtering with the proposal status - animations = Animation.objects.filter(status='changes').order_by('-created') + animations = Animation.objects.filter( + status='changes').order_by('-created') # print(animations) # Show upto 9 proposals per page @@ -452,11 +465,12 @@ def sortproposal_pending(request): categories = Category.objects.all() if profile.position == 'contributor': # filtering with the proposal status - animations = Animation.objects.filter(contributor_id=user, - status='pending').order_by('-created') + animations = Animation.objects.filter( + contributor_id=user, status='pending').order_by('-created') else: # filtering with the proposal status - animations = Animation.objects.filter(status='pending').order_by('-created') + animations = Animation.objects.filter( + status='pending').order_by('-created') # print(animations) # Show upto 9 proposals per page @@ -478,6 +492,7 @@ def sortproposal_pending(request): else: return redirect('/login/') + @login_required def edit_proposal(request, proposal_id=None): user = request.user @@ -489,14 +504,15 @@ def edit_proposal(request, proposal_id=None): 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) + 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') @@ -536,7 +552,8 @@ def edit_proposal(request, proposal_id=None): proposal=proposal) form_data.save() return redirect('/edit_proposal/{}'.format(proposal_id)) - proposal_form = AnimationProposal_edit(request.POST, instance=proposal) + proposal_form = AnimationProposal_edit( + request.POST, instance=proposal) if proposal_form.is_valid(): p_f = proposal_form.save(commit=False) p_f.contributor = user @@ -578,7 +595,9 @@ def delete_proposal(request, proposal_id=None): if is_email_checked(user) and user.is_authenticated(): proposal = Animation.objects.get(id=proposal_id) - return render(request, 'fossee_manim/delete_proposal.html', {'proposal': proposal}) + return render(request, + 'fossee_manim/delete_proposal.html', + {'proposal': proposal}) else: return redirect('/register/') @@ -595,7 +614,8 @@ def delete_proposal_info(request, proposal_id=None): 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') paginator = Paginator(list(animations), 9) @@ -608,7 +628,8 @@ def delete_proposal_info(request, proposal_id=None): except EmptyPage: anime = paginator.page(paginator.num_pages) - return render(request, 'fossee_manim/proposal_status.html',{'anime': anime,'categories': categories}) + return render(request, 'fossee_manim/proposal_status.html', + {'anime': anime, 'categories': categories}) else: return redirect('/login/') @@ -618,14 +639,19 @@ 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', {'s_result': anime_list, 'categories': categories}) # search results for proposal + + def search_proposal(request): user = request.user if is_email_checked(user) and user.is_authenticated(): @@ -651,6 +677,7 @@ def search_proposal(request): else: return redirect('/login/') + @login_required def upload_animation(request, proposal_id=None): user = request.user @@ -667,7 +694,7 @@ def upload_animation(request, proposal_id=None): anobj = anim.first() try: remove(anobj.thumbnail.path) - except: + except BaseException: pass remove(anobj.video_path.path) anobj.delete() @@ -678,7 +705,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)) @@ -698,7 +725,7 @@ def video(request, aid=None): 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)] + 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 @@ -741,44 +768,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