summaryrefslogtreecommitdiff
path: root/fossee_manim
diff options
context:
space:
mode:
Diffstat (limited to 'fossee_manim')
-rw-r--r--fossee_manim/admin.py29
-rw-r--r--fossee_manim/forms.py3
-rw-r--r--fossee_manim/models.py1
-rw-r--r--fossee_manim/static/css/sticky-footer.css14
-rw-r--r--fossee_manim/templates/fossee_manim/base.html14
-rw-r--r--fossee_manim/templates/fossee_manim/categorical_list.html29
-rw-r--r--fossee_manim/templates/fossee_manim/edit_proposal.html6
-rw-r--r--fossee_manim/templates/fossee_manim/search_results.html28
-rw-r--r--fossee_manim/templates/fossee_manim/video.html62
-rw-r--r--fossee_manim/views.py64
10 files changed, 182 insertions, 68 deletions
diff --git a/fossee_manim/admin.py b/fossee_manim/admin.py
index 35bf57b..121c487 100644
--- a/fossee_manim/admin.py
+++ b/fossee_manim/admin.py
@@ -46,5 +46,32 @@ class CategoryAdmin(admin.ModelAdmin):
list_filter = ['name']
+class AnimationAdmin(admin.ModelAdmin):
+ list_display = ['title', 'status', 'contributor']
+ list_filter = ['category']
+ actions = ['download_data']
+
+ def download_data(self, request, queryset):
+ openfile = string_io()
+ response = HttpResponse(content_type='text/csv')
+ response['Content-Disposition'] = 'attachment;\
+ filename=animations_data.csv'
+
+ writer = csv.writer(response)
+ writer.writerow(['title', 'contributor', 'reviewer', 'description',
+ 'status', 'github link', 'category'])
+
+ for q in queryset:
+ writer.writerow([q.title, q.contributor.get_full_name(),
+ q.reviewer.get_full_name(), q.description, q.status, q.github,
+ q.category])
+
+ openfile.seek(0)
+ response.write(openfile.read())
+ return response
+
+ download_data.short_description = "Download data CSV file."
+
admin.site.register(Category, CategoryAdmin)
-admin.site.register(Profile, ProfileAdmin) \ No newline at end of file
+admin.site.register(Profile, ProfileAdmin)
+admin.site.register(Animation, AnimationAdmin) \ No newline at end of file
diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py
index b3b33eb..72e5c83 100644
--- a/fossee_manim/forms.py
+++ b/fossee_manim/forms.py
@@ -263,7 +263,8 @@ class CommentForm(forms.ModelForm):
class Meta:
model = Comment
- exclude = ['animation', 'created_date', 'commentor']
+ exclude = ['animation', 'created_date', 'commentor',
+ 'animation_status']
widgets = {
'comments': forms.CharField(),
}
diff --git a/fossee_manim/models.py b/fossee_manim/models.py
index 75f03da..240ec1b 100644
--- a/fossee_manim/models.py
+++ b/fossee_manim/models.py
@@ -179,6 +179,7 @@ class Comment(models.Model):
commentor = models.ForeignKey(User, on_delete=models.CASCADE)
animation = models.ForeignKey(Animation, on_delete=models.CASCADE)
created_date = models.DateTimeField(default=timezone.now)
+ animation_status = models.CharField(max_length=255)
def __str__(self):
return u"{1} | {0}".format(
diff --git a/fossee_manim/static/css/sticky-footer.css b/fossee_manim/static/css/sticky-footer.css
index ea445db..d0054bd 100644
--- a/fossee_manim/static/css/sticky-footer.css
+++ b/fossee_manim/static/css/sticky-footer.css
@@ -70,17 +70,3 @@
margin-left: .1rem;
margin-right: .1rem;
}
-
-
-/**
- * Footer Styles
- */
-
-.footer {
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- background-color: #efefef;
- text-align: center;
-} \ 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 c9d6242..3fdd977 100644
--- a/fossee_manim/templates/fossee_manim/base.html
+++ b/fossee_manim/templates/fossee_manim/base.html
@@ -43,10 +43,11 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Categories
</a>
+
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
- <a class="dropdown-item" href="#">Math</a>
- <a class="dropdown-item" href="#">Aerospace</a>
- <a class="dropdown-item" href="#">Biology</a>
+ {% for c in categories %}
+ <a class="dropdown-item" href="{% url 'search_category' c.name %}">{{c.name}}</a>
+ {% endfor %}
</div>
</li>
</ul>
@@ -93,10 +94,5 @@
{% endblock %}
</body>
-<br><br>
- <footer class="footer">
- <div class="container">
- <p align="center">Developed by FOSSEE group, IIT Bombay</p>
- </div>
- </footer>
+<br>
</html> \ No newline at end of file
diff --git a/fossee_manim/templates/fossee_manim/categorical_list.html b/fossee_manim/templates/fossee_manim/categorical_list.html
index a61ab40..c3bfacd 100644
--- a/fossee_manim/templates/fossee_manim/categorical_list.html
+++ b/fossee_manim/templates/fossee_manim/categorical_list.html
@@ -6,23 +6,30 @@
{% block content %}
<br>
- <div class="container" align="center">
+ <div class="container-fluid" >
<br>
- <div class="row">
+ <div class="row" align="center">
<div class="col-md-12">
<h1 style="float: left;">{{ categorial_list.0.animation.category }}</h1>
</div>
</div>
<hr>
<br>
- <div style="width:150px; float: left;">
- {% for video in categorial_list %}
- <div class="row">
- <a href="{% url 'video' video.id %}" ><img height="100%" width="200%" src="{{ video.thumbnail.url }}"></a>
+
+ {% for video in categorial_list %}
+ <div class="row">
+ <div class="col-md-4" >
+ <a href="{% url 'video' video.id %}" ><img height="90%" width="100%" src="{{ video.thumbnail.url }}"></a>
+ </div>
+ <div class="col-md-4">
+ <p style="color:#26A669; font-size: 300%;"> {{ video.animation.title }} </p>
+ <p style="color:#26A669; font-size: 100%;"> {{ video.animation.description | truncatewords:5}} </p>
+ <a target="_blank" href="{{ video.animation.github }}"><p style="font-size: 70%;"> {{ video.animation.github }} </p></a>
</div>
- <hr>
- {% endfor %}
- </div>
- <br>
- </div>
+ </div>
+ <hr>
+ {% endfor %}
+ <br>
+ </div>
+ <br>
{% endblock %} \ No newline at end of file
diff --git a/fossee_manim/templates/fossee_manim/edit_proposal.html b/fossee_manim/templates/fossee_manim/edit_proposal.html
index 3edad99..4ca98cd 100644
--- a/fossee_manim/templates/fossee_manim/edit_proposal.html
+++ b/fossee_manim/templates/fossee_manim/edit_proposal.html
@@ -23,7 +23,7 @@
</form>
<br>
- {% if proposal_form.instance.status == 'changes' %}
+ {% if proposal_form.instance.status == 'changes' and request.user.profile.position == 'coordinator' %}
<form method="POST" action="{% url 'upload_animation' proposal_form.instance.id %}" enctype="multipart/form-data">
{% csrf_token %}
<label class="btn btn-info">
@@ -31,6 +31,10 @@
<button class="btn btn-success" type="submit">Upload</button>
</label>
</form>
+ {% else %}
+ <video width="100%" height="100%" controls>
+ <source src="{{video.0.video_path.url}}" type="video/mp4">
+ </video>
{% endif %}
<br><br>
diff --git a/fossee_manim/templates/fossee_manim/search_results.html b/fossee_manim/templates/fossee_manim/search_results.html
index 2e70f78..5ade6d2 100644
--- a/fossee_manim/templates/fossee_manim/search_results.html
+++ b/fossee_manim/templates/fossee_manim/search_results.html
@@ -1,13 +1,31 @@
{% extends 'fossee_manim/base.html' %}
{% block title %}
- Login
+ Search Result
{% endblock %}
{% block content %}
- <br>
- <div class="container" align="center">
- {{ args }}
- </div>
+<br>
+<div class="container-fluid" >
+ <br>
+
+ <hr>
+ <br>
+ {% for anime in s_result %}
+ <div class="row">
+ <div class="col-md-4" >
+ <a href="{% url 'video' anime.id %}" ><img height="90%" width="100%" src="{{ anime.thumbnail.url }}"></a>
+ </div>
+ <div class="col-md-4">
+ <p style="color:#26A669; font-size: 300%;"> {{ anime.title }} </p>
+ <p style="color:#26A669; font-size: 100%;"> {{ anime.description | truncatewords:5}} </p>
+ <a target="_blank" href="{{ anime.animation.github }}"><p style="font-size: 70%;"> {{ anime.github }} </p></a>
+ </div>
+ </div>
+ <hr>
+ {% endfor %}
+ <br>
+</div>
+<br>
{% endblock %} \ No newline at end of file
diff --git a/fossee_manim/templates/fossee_manim/video.html b/fossee_manim/templates/fossee_manim/video.html
index ff020e5..4ffcb47 100644
--- a/fossee_manim/templates/fossee_manim/video.html
+++ b/fossee_manim/templates/fossee_manim/video.html
@@ -5,20 +5,62 @@
{% endblock %}
{% block content %}
- <br>
- <div class="container" align="center">
- <br>
+ <div class="container" >
<div class="row" >
- <div class="col-md-8">
- <video width="100%" height="100%" controls>
+ <div class="col-md-12" >
+ <br>
+ <video width="100%" height="90%" controls >
<source src="{{video.0.video_path.url}}" type="video/mp4">
</video>
- <p style="float: left;"> {{ video.0.views }} views</p>
+ <div class="row">
+ <div class="col-md-8">
+ <p style="color:#26A669; font-size: 200%; float: left;"> {{ video.0.animation.title }} </p>
+ </div>
+ <div class="col-md-4">
+ <a target="_blank" href="{{ video.animation.github }}"><p style="font-size: 70%; float: right;"> {{ video.0.animation.github }} </p></a>
+ </div>
+ </div>
</div>
- <div class="col-md-4">
- </div>
-
+
+ </div>
+ <div class="row">
+ <div class="col-md-10">
+ <p style="color:#26A669; font-size: 100%; float: left;">
+ {{ video.0.animation.description }}
+ </p>
+ <br>
+ </div>
</div>
- <br>
+ <div>
+ <hr>
+ <br> <br>
+ <h2>Comments</h2>
+ <div>
+ <form method="POST">
+ <br>
+ {% csrf_token %}
+ {{ comment_form.as_p }}
+ <button type="submit" class="btn btn-default">Post</button>
+ </form>
+
+ </div>
+ <hr style="background-color: #fff;
+ border-top: 5px double #8c8b8b;">
+ <table>
+ {% for comment in comments %}
+ <tbody>
+ <tr>
+ <td>
+ <h5>{{ comment.commentor.profile.user.get_full_name }} | {{ comment.created_date | date }}</h5>
+ <h6 style="background-color: #ecf0f1; padding:10px;">{{ comment.comment }}</h6>
+ <hr style="border-top: 0.5px solid #8c8b8b;">
+ </td>
+ </tr>
+ </tbody>
+ {% endfor %}
+ </table>
+
+ <br>
+ </div>
</div>
{% endblock %} \ No newline at end of file
diff --git a/fossee_manim/views.py b/fossee_manim/views.py
index 58cc794..b274e63 100644
--- a/fossee_manim/views.py
+++ b/fossee_manim/views.py
@@ -20,7 +20,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.conf import settings
from django.core.files.uploadhandler import FileUploadHandler
from django.contrib import messages
-from django.db.models import F, Subquery, OuterRef
+from django.db.models import F, Subquery, OuterRef, Q
from zipfile import ZipFile
from textwrap import dedent
from requests import get
@@ -197,10 +197,12 @@ def user_register(request):
def view_profile(request):
""" view instructor and coordinator profile """
user = request.user
+ categories = Category.objects.all()
if is_superuser(user):
return redirect('/admin')
if is_email_checked(user) and user.is_authenticated():
- return render(request, "fossee_manim/view_profile.html")
+ return render(request, "fossee_manim/view_profile.html",
+ {'categories': categories})
else:
if user.is_authenticated():
return render(request, 'fossee_manim/activation.html')
@@ -217,6 +219,7 @@ def edit_profile(request):
""" edit profile details facility for reviewer and contributor """
user = request.user
+ categories = Category.objects.all()
if is_superuser(user):
return redirect('/admin')
if is_email_checked(user):
@@ -248,20 +251,23 @@ def edit_profile(request):
form_data.save()
return render(
- request, 'fossee_manim/profile_updated.html'
+ 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}
+ return render(request, 'fossee_manim/edit_profile.html', {'form': form,
+ 'categories': categories}
)
@login_required
def send_proposal(request):
user = request.user
+ categories = Category.objects.all()
if request.method == 'POST':
form = AnimationProposal(request.POST)
if form.is_valid():
@@ -275,12 +281,12 @@ def send_proposal(request):
else:
messages.warning(request, 'Please enter valid github details')
return render(request, 'fossee_manim/send_proposal.html',
- {'form': form})
+ {'form': form, 'categories': categories})
return redirect('/proposal_status/')
else:
form = AnimationProposal()
return render(request, 'fossee_manim/send_proposal.html',
- {'form': form})
+ {'form': form, 'categories': categories})
@login_required
@@ -289,12 +295,14 @@ def proposal_status(request):
profile = Profile.objects.get(user_id=user)
anime = {}
anime_list = {}
+ categories = Category.objects.all()
if profile.position == 'contributor':
anime = Animation.objects.filter(contributor_id=user)
else:
anime_list = Animation.objects.order_by('-created')
return render(request, 'fossee_manim/proposal_status.html',
- {'anime': anime, 'anime_list': anime_list})
+ {'anime': anime, 'anime_list': anime_list,
+ 'categories': categories})
@login_required
@@ -304,6 +312,8 @@ def edit_proposal(request, proposal_id=None):
proposal = Animation.objects.get(id=proposal_id)
proposal_form = AnimationProposal(instance=proposal)
upload_form = UploadAnimationForm()
+ categories = Category.objects.all()
+ video = AnimationStats.objects.filter(animation=proposal_id)
try:
comments = Comment.objects.filter(animation_id=proposal_id).order_by(
'-created_date'
@@ -334,6 +344,7 @@ def edit_proposal(request, proposal_id=None):
form_data = comment_form.save(commit=False)
form_data.commentor = user
form_data.animation = proposal
+ form_data.animation__status = proposal.status
if user.profile.position == 'reviewer':
proposal.status = 'changes'
proposal.save()
@@ -368,14 +379,21 @@ def edit_proposal(request, proposal_id=None):
return render(request, 'fossee_manim/edit_proposal.html',
{'proposal_form': proposal_form,
"comments": comments,
- "comment_form": comment_form,
- "upload_form": upload_form})
+ "comment_form": comment_form,
+ "upload_form": upload_form,
+ 'video': video,
+ 'categories': categories})
def search(request):
+ categories = Category.objects.all()
if request.method == 'POST':
word = request.POST.get('sbox')
- return render(request, 'fossee_manim/search_results.html')
+ anime_list = Animation.objects.filter(
+ Q(title__contains=word) | Q(description__contains=word))
+
+ return render(request, 'fossee_manim/search_results.html',
+ {'s_result': anime_list, 'categories': categories})
@login_required
@@ -408,18 +426,32 @@ def upload_animation(request, proposal_id=None):
return redirect('/view_profile/')
-def video(request, id=None):
- video = AnimationStats.objects.filter(id=id)
+def video(request, aid=None):
+ video = AnimationStats.objects.filter(id=aid)
+ comment_form = CommentForm()
# if views crosses limit comment the line below
video.update(views=F('views')+1)
video.update(like=F('like')+1)
- suggestion_list = AnimationStats.objects.filter()
- return render(request, 'fossee_manim/video.html', {'video': video})
+ 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 !=
+ ('pending' or 'changes')]
+ categories = Category.objects.all()
+ return render(request, 'fossee_manim/video.html',
+ {'video': video, 'categories': categories,
+ 'suggestion_list': suggestion_list,
+ "comment_form": comment_form,
+ 'comments': comments})
def search_category(request, cat=None):
cat_id = Category.objects.get(name=cat)
- anim_list = AnimationStats.objects.all()
+ anim_list = AnimationStats.objects.filter(animation__status="released")
cat_video_list = [x for x in anim_list if (x.animation.category == cat_id)]
+ categories = Category.objects.all()
return render(request, 'fossee_manim/categorical_list.html',
- {'categorial_list': cat_video_list})
+ {'categorial_list': cat_video_list, 'categories': categories
+ })