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