from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils.functional import update_wrapper
+from django.utils.translation import ugettext_lazy as _
from philo.admin import EntityAdmin
from philo.contrib.sobol.models import Search, ResultURL, SearchView
qs = self.queryset(request).filter(pk__in=object_ids)
opts = self.model._meta
+ if len(object_ids) == 1:
+ title = _(u"Search results for %s" % qs[0])
+ else:
+ title = _(u"Search results for multiple objects")
+
context = {
+ 'title': title,
'queryset': qs,
'opts': opts,
'root_path': self.admin_site.root_path,
self._favored_results = []
for value, subresults in grouped_results.items():
- cost = error * sum([(value - result.weight)**2 for result in results])
+ cost = error * sum([(value - result.weight)**2 for result in self._favored_results])
if value > cost:
self._favored_results += subresults
else:
<!-- LOADING -->
{% load i18n %}
+<!-- EXTRASTYLES -->
+{% block extrastyle %}<style type="text/css">.favored{font-weight:bold;}</style>{% endblock %}
+
<!-- BREADCRUMBS -->
{% block breadcrumbs %}
<div id="breadcrumbs">
+ {% if queryset|length > 1 %}
<a href="../../">{% trans "Home" %}</a> ›
<a href="../">{{ app_label|capfirst }}</a> ›
<a href="./">{{ opts.verbose_name_plural|capfirst }}</a> ›
{% trans 'Search results for multiple objects' %}
+ {% else %}
+ <a href="../../../../">{% trans "Home" %}</a> ›
+ <a href="../../../">{{ app_label|capfirst }}</a> ›
+ <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> ›
+ <a href="../">{{ queryset|first|truncatewords:"18" }}</a> ›
+ {% trans 'Results' %}
+ {% endif %}
</div>
{% endblock %}
{% block content %}
<div class="container-grid delete-confirmation">
{% for search in queryset %}
- <h1>{{ search.string }}</h1>
- <div class="module">
+ {% if not forloop.first and not forloop.last %}<h1>{{ search.string }}</h1>{% endif %}
+ <div class="group tabular">
<h2>{% blocktrans %}Results{% endblocktrans %}</h2>{% comment %}For the favored results, add a class?{% endcomment %}
- {% for result in search.get_weighted_results %}
- <div class="row cell-2">
- <div class="cell span-4">{{ result.url }}</div>
- <div class="cell span-flexible">{{ result.weight }}</div>
+ <div class="module table">
+ <div class="module thead">
+ <div class="tr">
+ <div class="th">Weight</div>
+ <div class="th">URL</div>
+ </div>
+ </div>
+ <div class="module tbody">
+ {% for result in search.get_weighted_results %}
+ <div class="tr{% if result in search.get_favored_results %} favored{% endif %}">
+ <div class="td">{{ result.weight }}</div>
+ <div class="td">{{ result.url }}</div>
+ </div>
+ {% endfor %}
+ </div>
</div>
- {% endfor %}
</div>
{% endfor %}
</div>
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block extrastyle %}<style type="text/css">.favored{font-weight:bold;}</style>{% endblock %}
+
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+ {% if queryset|length > 1 %}
+ <a href="../../">{% trans "Home" %}</a> ›
+ <a href="../">{{ app_label|capfirst }}</a> ›
+ <a href="./">{{ opts.verbose_name_plural|capfirst }}</a> ›
+ {% trans 'Search results for multiple objects' %}
+ {% else %}
+ <a href="../../../../">{% trans "Home" %}</a> ›
+ <a href="../../../">{{ app_label|capfirst }}</a> ›
+ <a href="../../">{{ opts.verbose_name_plural|capfirst }}</a> ›
+ <a href="../">{{ queryset|first|truncatewords:"18" }}</a> ›
+ {% trans 'Results' %}
+ {% endif %}
+</div>
+{% endblock %}
+
+
+{% block content %}
+ {% for search in queryset %}
+ {% if not forloop.first and not forloop.last %}<h1>{{ search.string }}</h1>{% endif %}
+ <fieldset class="module">
+ <h2>{% blocktrans %}Results{% endblocktrans %}</h2>{% comment %}For the favored results, add a class?{% endcomment %}
+ <table>
+ <thead>
+ <tr>
+ <th>Weight</th>
+ <th>URL</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for result in search.get_weighted_results %}
+ <tr{% if result in search.favored_results %} class="favored"{% endif %}>
+ <td>{{ result.weight }}</td>
+ <td>{{ result.url }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </fieldset>
+ {% endfor %}
+{% endblock %}
\ No newline at end of file