1
0
Fork 0
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:
Correl Roush 2011-01-06 00:06:48 -05:00
parent e5b26613a7
commit 26ab7ce44c
5 changed files with 49 additions and 0 deletions
dashboard
templates/search
includes/dashboard
indexes/dashboard
search.html
urls.py

View 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)

View 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>

View file

@ -0,0 +1,3 @@
{{ commit.author }}
{{ commit.committer }}
{{ commit.message }}

View file

@ -0,0 +1,34 @@
{% extends 'layouts/default.html' %}
{% block content %}
<h2>Search</h2>
<form method="get" action=".">
<table>
{{ form.as_table }}
<tr>
<td>&nbsp;</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 }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
|
{% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
</div>
{% endif %}
{% else %}
{# Show some example queries to run, maybe query syntax, something else? #}
{% endif %}
</form>
{% endblock %}

View file

@ -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')),