diff options
author | Magnus Hagander | 2014-07-14 16:11:17 +0000 |
---|---|---|
committer | Magnus Hagander | 2014-07-14 16:11:17 +0000 |
commit | 4bc1290965b39a0e09285c7e9235257fd1d16efe (patch) | |
tree | 75707ff51ba6d5afa4408ee07abd693e7b688c33 | |
parent | a34c78278bf6128a489530bf3ef2d6560ac799ce (diff) |
Add ability to do global searches
-rw-r--r-- | pgcommitfest/commitfest/models.py | 1 | ||||
-rw-r--r-- | pgcommitfest/commitfest/templates/home.html | 8 | ||||
-rw-r--r-- | pgcommitfest/commitfest/templates/patchsearch.html | 28 | ||||
-rw-r--r-- | pgcommitfest/commitfest/views.py | 14 | ||||
-rw-r--r-- | pgcommitfest/urls.py | 1 |
5 files changed, 52 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/models.py b/pgcommitfest/commitfest/models.py index 39e2d34..284c3d5 100644 --- a/pgcommitfest/commitfest/models.py +++ b/pgcommitfest/commitfest/models.py @@ -168,6 +168,7 @@ class PatchOnCommitFest(models.Model): class Meta: unique_together = (('patch', 'commitfest',),) + ordering = ('-commitfest__startdate', ) class PatchHistory(models.Model): patch = models.ForeignKey(Patch, blank=False, null=False) diff --git a/pgcommitfest/commitfest/templates/home.html b/pgcommitfest/commitfest/templates/home.html index 522ae0a..461bc28 100644 --- a/pgcommitfest/commitfest/templates/home.html +++ b/pgcommitfest/commitfest/templates/home.html @@ -10,4 +10,12 @@ The following commitfests exist in the system. <li><a href="/{{c.id}}/">{{c}}</a> ({{c.statusstring}})</li> {%endfor%} </ul> +<br/> +<h3>Commands</h3> +<form method="GET" action="/https/git.postgresql.org/search/" class="form-inline" role="form"> + <div class="form-group"> + <input type="text" class="form-control" id="searchterm" name="searchterm" placeholder="Global search"> + </div> + <button type="submit" class="btn btn-default">Search</button> +</form> {%endblock%} diff --git a/pgcommitfest/commitfest/templates/patchsearch.html b/pgcommitfest/commitfest/templates/patchsearch.html new file mode 100644 index 0000000..4db2949 --- /dev/null +++ b/pgcommitfest/commitfest/templates/patchsearch.html @@ -0,0 +1,28 @@ +{%extends "base.html"%} +{%load commitfest %} +{%block contents%} + +<table class="table table-striped table-bordered table-hover table-condensed"> + <thead> + <tr> + <th>Patch</th> + <th>Status</th> + <th>Author</th> + </tr> + </thead> + <tbody> +{%for p in patches %} + {%with p.patchoncommitfest_set.all as cfs %} + <tr> + <td>{%with cfs|first as firstcf%}<a href="/{{firstcf.commitfest_id}}/{{p.id}}/">{{p}}</a>{%endwith%}</td> + <td>{%for c in cfs %} + <div style="margin-bottom: 3px;">{{c.commitfest}}: <span class="label label-default">{{c.statusstring}}</span></div> + {%endfor%}</td> + <td>{{p.author_names|default:''}}</td> + </tr> + {%endwith%} +{%endfor%} + </tbody> +</table> + +{%endblock%} diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index a7d7498..9abf91e 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -106,6 +106,20 @@ def commitfest(request, cfid): 'openpatchids': [p.id for p in patches if p.is_open], }, context_instance=RequestContext(request)) +def global_search(request): + if not request.GET.has_key('searchterm'): + print request.GET.keys() + return HttpResponseRedirect('/') + searchterm = request.GET['searchterm'] + + patches = Patch.objects.select_related().filter(name__icontains=searchterm).order_by('created',) + + print patches + return render_to_response('patchsearch.html', { + 'patches': patches, + 'title': 'Patch search results', + }, context_instance=RequestContext(request)) + def patch(request, cfid, patchid): cf = get_object_or_404(CommitFest, pk=cfid) patch = get_object_or_404(Patch.objects.select_related(), pk=patchid, commitfests=cf) diff --git a/pgcommitfest/urls.py b/pgcommitfest/urls.py index b9e063c..fb32e67 100644 --- a/pgcommitfest/urls.py +++ b/pgcommitfest/urls.py @@ -18,6 +18,7 @@ urlpatterns = patterns('', url(r'^(\d+)/(\d+)/(comment|review)/', 'commitfest.views.comment'), url(r'^(\d+)/send_email/$', 'commitfest.views.send_email'), url(r'^(\d+)/\d+/send_email/$', 'commitfest.views.send_email'), + url(r'^search/$', 'commitfest.views.global_search'), url(r'^ajax/(\w+)/$', 'commitfest.ajax.main'), url(r'^selectable/', include('selectable.urls')), |