summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshen2019-05-16 17:35:53 +0530
committerGitHub2019-05-16 17:35:53 +0530
commitc0f97aa92b159c7ccf9399e7dbe8cba590823003 (patch)
treebe85293b61de0e5e8e9fa30878c94a7eab9b78b6
parent10766f3627f1f013913c6ef9680c7d5f4e12f433 (diff)
parentedad33a7c2439c1206de77242df750a0d4007fd6 (diff)
downloadFOSSEE_animations-c0f97aa92b159c7ccf9399e7dbe8cba590823003.tar.gz
FOSSEE_animations-c0f97aa92b159c7ccf9399e7dbe8cba590823003.tar.bz2
FOSSEE_animations-c0f97aa92b159c7ccf9399e7dbe8cba590823003.zip
Merge pull request #17 from Akshen/develop
Pagination on proposal status page
-rw-r--r--fossee_manim/templates/fossee_manim/proposal_status.html48
-rw-r--r--fossee_manim/views.py31
2 files changed, 71 insertions, 8 deletions
diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html
index 4a1b7ed..c53ecc0 100644
--- a/fossee_manim/templates/fossee_manim/proposal_status.html
+++ b/fossee_manim/templates/fossee_manim/proposal_status.html
@@ -65,5 +65,53 @@
</table>
</div>
+
+
+ <!-- Page Navigation -->
+ <div class="container">
+ <div class="Page-Nav" align="center">
+ <nav aria-label="Page navigation">
+ <ul class="pagination pagination-sm">
+ <li class="page-item">
+ {% if request.user.profile.position == 'contributor' %}
+ {% if anime.has_previous %}
+ <a class="page-link" tabindex="-1"
+ href="?page={{ anime.previous_page_number }}">Prev</a>
+ {% endif %}
+ </li>
+ <li class="page-item">
+ <span class="current" >
+ Page {{ anime.number }} of {{ anime.paginator.num_pages }}
+ </span>
+ </li>
+ <li class="page-item">
+ {% if anime.has_next %}
+ <a class="page-link" href="?page={{ anime.next_page_number }}"> Next
+ </a>
+ {% endif %}
+
+ {% else %}
+ {% if anime_list.has_previous %}
+ <a class="page-link" tabindex="-1"
+ href="?page={{ anime_list.previous_page_number }}"> Prev </a>
+ {% endif %}
+ </li>
+ <li class="page-item">
+ <span class="current">
+ Page {{ anime_list.number }} of {{ anime_list.paginator.num_pages }}
+ </span>
+ </li>
+ <li class="page-item">
+ {% if anime_list.has_next %}
+ <a class="page-link" href="?page={{ anime_list.next_page_number }}"> Next
+ </a>
+ {% endif %}
+
+ {% endif %}
+ </li>
+ </ul>
+ </nav>
+ </div>
+ </div>
{% endblock %} \ No newline at end of file
diff --git a/fossee_manim/views.py b/fossee_manim/views.py
index ae3d90a..60d2f1e 100644
--- a/fossee_manim/views.py
+++ b/fossee_manim/views.py
@@ -79,9 +79,7 @@ def index(request):
user = request.user
form = UserLoginForm()
if user.is_authenticated() and is_email_checked(user):
- if user.groups.filter(name='reviewer').exists:
- return redirect('/proposal_status/')
- return redirect('/view_profile/')
+ return redirect('/proposal/')
elif request.method == "POST":
form = UserLoginForm(request.POST)
if form.is_valid():
@@ -89,9 +87,7 @@ def index(request):
login(request, user)
if is_superuser(user):
return redirect("/admin")
- if user.groups.filter(name='reviewer').exists():
- return redirect('/proposal_status/')
- return redirect('/view_profile/')
+ return redirect('/proposal/')
anime = AnimationStats.objects.filter(animation__status='released').order_by('-id')[:5]
return render(request, "fossee_manim/index.html", {"form": form,
"anime" : anime
@@ -120,7 +116,7 @@ def user_login(request):
user = form.cleaned_data
login(request, user)
if user.groups.filter(name='reviewer').count() > 0:
- return redirect('/view_profile/')
+ return redirect('/proposal_status/')
return redirect('/proposal_status/')
else:
return render(request, 'fossee_manim/login.html', {"form": form})
@@ -132,8 +128,10 @@ def user_login(request):
def user_logout(request):
'''Logout'''
+ categories = Category.objects.all()
logout(request)
- return render(request, 'fossee_manim/logout.html')
+ return render(request, 'fossee_manim/logout.html',
+ {'categories': categories })
def activate_user(request, key=None):
@@ -313,6 +311,23 @@ def proposal_status(request):
anime = Animation.objects.filter(contributor_id=user)
else:
anime_list = Animation.objects.order_by('-created')
+
+ # Show upto 9 proposals per page
+ paginator_c = Paginator(list(anime), 9)
+ paginator_r = Paginator(list(anime_list), 9)
+ page = request.GET.get('page')
+ try:
+ anime = paginator_c.page(page)
+ anime_list = paginator_r.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ anime = paginator_c.page(1)
+ anime_list = paginator_r.page(1)
+ except EmptyPage:
+ # If page is out of range(e.g 999999), deliver last page.
+ anime = paginator_c.page(paginator_c.num_pages)
+ anime_list = paginator_r.page(paginator_r.num_pages)
+
return render(request, 'fossee_manim/proposal_status.html',
{'anime': anime, 'anime_list': anime_list,
'categories': categories})