mirror of
https://github.com/correl/codereview.git
synced 2025-04-01 19:07:49 -09:00
Added (ugly) commit search
This commit is contained in:
parent
e5b26613a7
commit
26ab7ce44c
5 changed files with 49 additions and 0 deletions
8
dashboard/search_indexes.py
Normal file
8
dashboard/search_indexes.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from haystack.indexes import *
|
||||
from haystack import site
|
||||
from codereview.dashboard.models import Commit
|
||||
|
||||
class CommitIndex(SearchIndex):
|
||||
text = CharField(document=True, use_template=True)
|
||||
|
||||
site.register(Commit, CommitIndex)
|
2
templates/search/includes/dashboard/commit.html
Normal file
2
templates/search/includes/dashboard/commit.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
<dt>Commit: <a href="{% url codereview.browser.views.commit repository=result.object.repository.name ref=result.object.ref %}">{{ result.object.ref }}</a></dt>
|
||||
<dd>{{ result.object.message }}</dt>
|
3
templates/search/indexes/dashboard/commit_text.txt
Normal file
3
templates/search/indexes/dashboard/commit_text.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{ commit.author }}
|
||||
{{ commit.committer }}
|
||||
{{ commit.message }}
|
34
templates/search/search.html
Normal file
34
templates/search/search.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
{% extends 'layouts/default.html' %}
|
||||
{% block content %}
|
||||
<h2>Search</h2>
|
||||
|
||||
<form method="get" action=".">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="Search" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if query %}
|
||||
<h3>Results</h3>
|
||||
{% for result in page.object_list %}
|
||||
{% if result.content_type == 'dashboard.commit' %}
|
||||
{% include 'search/includes/dashboard/commit.html' %}
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
<p>No results found.</p>
|
||||
{% endfor %}
|
||||
|
||||
{% if page.has_previous or page.has_next %}
|
||||
<div>
|
||||
{% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}« Previous{% if page.has_previous %}</a>{% endif %}
|
||||
|
|
||||
{% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}Next »{% if page.has_next %}</a>{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{# Show some example queries to run, maybe query syntax, something else? #}
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock %}
|
2
urls.py
2
urls.py
|
@ -13,6 +13,8 @@ urlpatterns = patterns('',
|
|||
(r'^dashboard/', include('codereview.dashboard.urls')),
|
||||
(r'^review/', include('codereview.review.urls')),
|
||||
|
||||
(r'^search/', include('haystack.urls')),
|
||||
|
||||
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
|
||||
# to INSTALLED_APPS to enable admin documentation:
|
||||
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
|
Loading…
Add table
Reference in a new issue