diff options
author | Alwin1847207 | 2019-10-04 11:37:37 +0530 |
---|---|---|
committer | Alwin1847207 | 2019-10-04 11:37:37 +0530 |
commit | 56ecd86e40d5e1b609e19725fea84c1d959d8727 (patch) | |
tree | b181f3789e0c2c0ac8e07d319dd7fb0dee3f902a | |
parent | 1a42123ca12eb45e0163cfb0d1637fdfe805b658 (diff) | |
download | FOSSEE_animations-56ecd86e40d5e1b609e19725fea84c1d959d8727.tar.gz FOSSEE_animations-56ecd86e40d5e1b609e19725fea84c1d959d8727.tar.bz2 FOSSEE_animations-56ecd86e40d5e1b609e19725fea84c1d959d8727.zip |
search option for proposal page
-rw-r--r-- | fossee_manim/templates/fossee_manim/proposal_status.html | 13 | ||||
-rw-r--r-- | fossee_manim/urls.py | 1 | ||||
-rw-r--r-- | 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 @@ <h2> Proposal Status </h2> <hr> <div class="row"> - <div class="col-md-2"> - <h2>Sort by :</h2> + <div class="col-md-4"> + <form class="form-inline" method="POST" action="/search_proposal/"> + {% csrf_token %} + <input class="form-control mr-sm-2" type="search" id="sbox" name="sbox" + placeholder="Search for proposals"> + <button class="btn btn-primary my-2 my-sm-0" id="btnblue" type="submit"> + Search + </button> + </form> </div> <div class="col-md-2"> - <a href="{% url 'sortproposal_rejected' %}"> + <a href="{% url 'sortproposal_rejected' %}"> <button type="button" class="btn btn-info" id="btnred">Rejected</button> </a> </div> 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): |