From 1b76ccc6984333c96fbe4c40b5ed538cbec039ff Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Mon, 17 May 2010 13:37:10 +0100 Subject: [PATCH] Standardised the URLs and enabled search function on applications --- hr/urls.py | 22 +++++++++---------- hr/views.py | 14 ++++++++++-- .../hr/applications/admin/view_list.html | 10 +++++++-- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/hr/urls.py b/hr/urls.py index fff6654..af2d98c 100644 --- a/hr/urls.py +++ b/hr/urls.py @@ -4,17 +4,17 @@ from hr import views urlpatterns = patterns('', ('^$', views.index), - (r'^recommendations/$', views.view_recommendations), - (r'^recommendations/(?P.*)/$', views.view_recommendation), - (r'^applications/$', views.view_applications), - (r'^applications/(?P\d+)/$', views.view_application), - (r'^applications/(?P\d+)/update/(?P\d+)/$', views.update_application), - (r'^applications/(?P\d+)/note/$', views.add_note), - (r'^applications/(?P\d+)/reject/$', views.reject_application), - (r'^applications/(?P\d+)/accept/$', views.accept_application), + (r'^recommendation/$', views.view_recommendations), + (r'^recommendation/(?P.*)/$', views.view_recommendation), + (r'^application/$', views.view_applications), + (r'^application/(?P\d+)/$', views.view_application), + (r'^application/(?P\d+)/update/(?P\d+)/$', views.update_application), + (r'^application/(?P\d+)/note/$', views.add_note), + (r'^application/(?P\d+)/reject/$', views.reject_application), + (r'^application/(?P\d+)/accept/$', views.accept_application), - (r'^add/application/$', views.add_application), - (r'^add/recommendation/$', views.add_recommendation), + (r'^application/add/$', views.add_application), + (r'^recommendation/add/$', views.add_recommendation), - (r'^admin/applications/$', views.admin_applications), + (r'^application/admin$', views.admin_applications), ) diff --git a/hr/views.py b/hr/views.py index c7768a0..b914905 100644 --- a/hr/views.py +++ b/hr/views.py @@ -151,8 +151,18 @@ def admin_applications(request): if not (request.user.is_staff or Group.objects.get(name=settings.HR_STAFF_GROUP) in request.user.groups.all()): return HttpResponseRedirect(reverse('hr.views.index')) - view_status = [APPLICATION_STATUS_AWAITINGREVIEW, APPLICATION_STATUS_ACCEPTED, APPLICATION_STATUS_QUERY] - apps = Application.objects.filter(status__in=view_status) + if 'q' in request.GET: + query = request.GET['q'] + if 'l' in request.GET: + limit = request.get['l'] + else: + limit = 10 + print query, limit + apps = Application.objects.filter(character__name__icontains=query)[:limit] + else: + view_status = [APPLICATION_STATUS_AWAITINGREVIEW, APPLICATION_STATUS_ACCEPTED, APPLICATION_STATUS_QUERY] + apps = Application.objects.filter(status__in=view_status) + return render_to_response('hr/applications/admin/view_list.html', locals(), context_instance=RequestContext(request)) @login_required diff --git a/templates/hr/applications/admin/view_list.html b/templates/hr/applications/admin/view_list.html index 8e68f22..753102b 100644 --- a/templates/hr/applications/admin/view_list.html +++ b/templates/hr/applications/admin/view_list.html @@ -3,7 +3,13 @@ {% block title %}Applications{% endblock %} {% block content %} -

This list shows all current applications open for review.

+ +

Search All Applications

+
+ + +
+ {% if apps %} @@ -16,7 +22,7 @@ {% endfor %}
Application IDCharacterCorporationApplication Status
{% else %} -

No current open applications

+

No applications found.

{% endif %} {% endblock %}