From 126558d2dd503efdbdce7545dc4353388c1f405a Mon Sep 17 00:00:00 2001 From: Akshen Date: Wed, 10 Apr 2019 10:34:58 +0530 Subject: Adds how_to_contribute page and videos on index page --- fossee_manim/forms.py | 2 - fossee_manim/models.py | 16 +++++++- fossee_manim/templates/fossee_manim/base.html | 1 + fossee_manim/templates/fossee_manim/how_to.html | 21 +++++++++++ fossee_manim/templates/fossee_manim/index.html | 50 ++++++++++++------------- fossee_manim/templates/fossee_manim/video.html | 22 ++++++++++- fossee_manim/urls.py | 1 + fossee_manim/views.py | 15 ++++++-- 8 files changed, 95 insertions(+), 33 deletions(-) create mode 100644 fossee_manim/templates/fossee_manim/how_to.html (limited to 'fossee_manim') diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index 72e5c83..7543935 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -258,8 +258,6 @@ class CommentForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(CommentForm, self).__init__(*args, **kwargs) self.fields['comment'].label = "" - self.fields['comment'].widget.attrs['rows'] = 5 - self.fields['comment'].widget.attrs['cols'] = 95 class Meta: model = Comment diff --git a/fossee_manim/models.py b/fossee_manim/models.py index 9a85c4d..a3b3537 100644 --- a/fossee_manim/models.py +++ b/fossee_manim/models.py @@ -209,4 +209,18 @@ class AnimationStats(models.Model): # Converting to Python file object with # some Django-specific additions django_file = File(que_file) - self.thumbnail.save(file_name, django_file, save=True) \ No newline at end of file + self.thumbnail.save(file_name, django_file, save=True) + + def _create_ogv(self): + video_input = self.video_path.path + vid_output = path.join( + 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): + que_file = open(vid_output, 'rb') + # Converting to Python file object with + # some Django-specific additions + django_file = File(que_file) + self.video_path.save(file_name, django_file, save=True) \ No newline at end of file diff --git a/fossee_manim/templates/fossee_manim/base.html b/fossee_manim/templates/fossee_manim/base.html index 3fdd977..1a4945d 100644 --- a/fossee_manim/templates/fossee_manim/base.html +++ b/fossee_manim/templates/fossee_manim/base.html @@ -60,6 +60,7 @@ {% if request.user.profile.position == 'contributor' %} +
+
+
+ + + + +
+
+ + + + +
+
+ + + + +
-


Comments

diff --git a/fossee_manim/urls.py b/fossee_manim/urls.py index 278dee2..6181b67 100644 --- a/fossee_manim/urls.py +++ b/fossee_manim/urls.py @@ -18,6 +18,7 @@ urlpatterns = [ name='upload_animation'), url(r'^proposal_status/$', views.proposal_status, name='proposal_status'), url(r'^search/$', views.search, name='search'), + url(r'^how_to/$', views.how_to, name='how_to'), url(r'^view_profile/$', views.view_profile, name='view_profile'), url(r'^edit_profile/$', views.edit_profile, name='edit_profile'), url(r'^video/([1-9][0-9]*)$', views.video, name='video'), diff --git a/fossee_manim/views.py b/fossee_manim/views.py index 93a1763..44f20c1 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -23,6 +23,7 @@ from django.db.models import F, Subquery, OuterRef, Q from zipfile import ZipFile from textwrap import dedent from requests import get +from random import sample from .send_mails import send_email import datetime as dt import shutil @@ -112,7 +113,7 @@ def user_login(request): login(request, user) if user.groups.filter(name='reviewer').count() > 0: return redirect('/view_profile/') - return redirect('/view_profile/') + return redirect('/how_to/') else: return render(request, 'fossee_manim/login.html', {"form": form}) else: @@ -460,12 +461,14 @@ def video(request, aid=None): else: return redirect('/view_profile/') - - + 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] categories = Category.objects.all() return render(request, 'fossee_manim/video.html', {'video': video, 'categories': categories, - 'suggestion_list': suggestion_list, + 'reco': suggestion_list, "comment_form": comment_form, 'comments': comments}) @@ -478,3 +481,7 @@ def search_category(request, cat=None): return render(request, 'fossee_manim/categorical_list.html', {'categorial_list': cat_video_list, 'categories': categories }) + + +def how_to(request): + return render(request, 'fossee_manim/how_to.html') \ No newline at end of file -- cgit