euscanwww: category, categories and package views

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary 2011-04-15 00:24:45 +02:00
parent 25964491dd
commit 2dee08dfb7
13 changed files with 173 additions and 64 deletions

View File

@ -138,7 +138,7 @@ class Command(BaseCommand):
sys.stdout.write('[u] %s/%s-%s %s\n' % (package.category, package.name,
ver, url))
obj.url = url
obj.urls = url
obj.packaged = False
obj.save()

View File

@ -0,0 +1,8 @@
from django import template
register = template.Library()
def mul(value, arg=None):
return value*arg
register.filter('mul', mul)

View File

@ -4,10 +4,10 @@ urlpatterns = patterns('euscan.views',
(r'^$', 'index'),
(r'^logs/$', 'logs'),
(r'^categories/$', 'categories'),
(r'^category/(?P<category>\w+)/packages/$', 'category'),
(r'^category/(?P<category>[\w+][\w+.-]*)/packages/$', 'category'),
(r'^herds/$', 'herds'),
(r'^herd/(?P<herd>\w+)/packages/$', 'herd'),
(r'^herd/(?P<herd>[\w+][\w+.-]*)/packages/$', 'herd'),
(r'^maintainers/$', 'maintainers'),
(r'^maintainer/(?P<maintainer_id>\d+)/packages/$', 'maintainer'),
(r'^package/(?P<category>\w+)/(?P<package>\w+)/$', 'package'),
(r'^package/(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/$', 'package'),
)

Binary file not shown.

View File

@ -1,5 +1,6 @@
from annoying.decorators import render_to
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.db.models import Sum, Max
from euscan.models import Version, Package, Herd, Maintainer, EuscanResult
@ -9,7 +10,8 @@ def index(request):
ctx = {}
ctx['n_packaged'] = Package.objects.aggregate(Sum('n_packaged'))['n_packaged__sum']
ctx['n_versions'] = Package.objects.aggregate(Sum('n_versions'))['n_versions__sum']
ctx['n_upstream'] = ctx['n_versions'] - ctx['n_packaged']
if ctx['n_versions'] is not None and ctx['n_pacaged'] is not None:
ctx['n_upstream'] = ctx['n_versions'] - ctx['n_packaged']
ctx['n_packages'] = Package.objects.count()
ctx['n_herds'] = Herd.objects.count()
ctx['n_maintainers'] = Maintainer.objects.count()
@ -27,7 +29,10 @@ def categories(request):
@render_to('euscan/category.html')
def category(request, category):
return {}
packages = Package.objects.filter(category=category)
if not packages:
raise Http404
return { 'category' : category, 'packages' : packages }
@render_to('euscan/herds.html')
def herds(request):
@ -47,4 +52,7 @@ def maintainer(request, maintainer_id):
@render_to('euscan/package.html')
def package(request, category, package):
return {}
package = get_object_or_404(Package, category=category, name=package)
packaged = Version.objects.filter(package=package, packaged=True)
upstream = Version.objects.filter(package=package, packaged=False)
return { 'package' : package, 'packaged' : packaged, 'upstream' : upstream }

Binary file not shown.

View File

@ -137,43 +137,6 @@ dd {
padding: 5px;
}
table {
border:3px solid #55534E;
border-collapse:collapse;
width:90%;
margin:auto;
}
thead, tfoot {
border:1px solid #55534E;
}
tbody {
background-color:#FFFFFF;
border:1px solid #55534E;
}
tbody tr.even {
background-color: #eee;
}
tbody tr.odd {
background-color: #fff;
}
tbody tr:hover {
background: #DFD9CD;
}
th {
border:1px dotted #55534E;
padding:5px;
background-color: #DFD9CD;
}
td {
border:1px solid #55534E;
padding:5px;
text-align:left;
}
h1 {
width: 20em;
@ -184,9 +147,11 @@ h1 {
.ok {
color:#15B100;
}
.bad {
color:#FFFFFF;
}
hr
{
margin: 0.3em 1em 0.3em 1em;

View File

@ -463,43 +463,43 @@ tr.even.gradeU td.sorting_3 {
/*
* Row highlighting example
*/
.ex_highlight #example tbody tr.even:hover, #example tbody tr.even td.highlighted {
tbody tr.even:hover, #example tbody tr.even td.highlighted {
background-color: #ECFFB3;
}
.ex_highlight #example tbody tr.odd:hover, #example tbody tr.odd td.highlighted {
tbody tr.odd:hover, #example tbody tr.odd td.highlighted {
background-color: #E6FF99;
}
.ex_highlight_row #example tr.even:hover {
tr.even:hover {
background-color: #ECFFB3;
}
.ex_highlight_row #example tr.even:hover td.sorting_1 {
tr.even:hover td.sorting_1 {
background-color: #DDFF75;
}
.ex_highlight_row #example tr.even:hover td.sorting_2 {
tr.even:hover td.sorting_2 {
background-color: #E7FF9E;
}
.ex_highlight_row #example tr.even:hover td.sorting_3 {
tr.even:hover td.sorting_3 {
background-color: #E2FF89;
}
.ex_highlight_row #example tr.odd:hover {
tr.odd:hover {
background-color: #E6FF99;
}
.ex_highlight_row #example tr.odd:hover td.sorting_1 {
tr.odd:hover td.sorting_1 {
background-color: #D6FF5C;
}
.ex_highlight_row #example tr.odd:hover td.sorting_2 {
tr.odd:hover td.sorting_2 {
background-color: #E0FF84;
}
.ex_highlight_row #example tr.odd:hover td.sorting_3 {
tr.odd:hover td.sorting_3 {
background-color: #DBFF70;
}

View File

@ -15,14 +15,15 @@
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
<div id="menus">
{% block menus %}
<div id="menu">
<ul>
{% block menu %}
<li><a href="categories/">Categories</a></li>
<li><a href="herds/">Herds</a></li>
<li><a href="maintainers/">Maintainers</a></li>
<li><a href="/categories/">Categories</a></li>
<li><a href="/herds/">Herds</a></li>
<li><a href="/maintainers/">Maintainers</a></li>
{% endblock %}
</ul>
</div>

View File

@ -1,8 +1,9 @@
?xml version="1.0" encoding="utf8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<?xml version="1.0" encoding="utf8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>{% block title %}euscan{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset="utf-8" />
{% block css %}
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}img/style.css" media="screen" title="Normal" />
{% endblock %}
@ -14,7 +15,9 @@
{% block header %}<h1>euscan</h1>{% endblock %}
</div>
<div id="content">
{% block content %}{% endblock %}
{% block content %}
{% endblock %}
</div>
<div id="menus">
{% block menus %}
<div id="menu">

View File

@ -1,21 +1,34 @@
{% extends "euscan/_datatable.html" %}
{% load sub %}
{% load mul %}
{% block title %}
{{ block.super }} - categories
{% endblock %}
{% block content %}
<h2>Categories</h2>
<table id="table">
<table id="table" class="display">
<thead>
<th>Category</th>
<th>Ebuilds</th>
<th>Unpackaged</th>
</thead>
<tbody>
{% for category in categories %}
<tr>
<td>{{ category.category }}</td>
{% if category.n_versions == category.n_packaged %}
<tr class="gradeA">
{% else %}{% if category.n_versions < category.n_packaged|mul:2 %}
<tr class="gradeC">
{% else %}
<tr class="gradeX">
{% endif %}{% endif %}
<td><a href="{% url euscan.views.category category.category %}">{{ category.category }}</a></td>
<td>{{ category.n_packaged }}</td>
<td>{{ category.n_versions|sub:category.n_packaged }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,38 @@
{% extends "euscan/_datatable.html" %}
{% load sub %}
{% load mul %}
{% block title %}
{{ block.super }} - {{ category }}
{% endblock %}
{% block content %}
<h2>Category: {{ category }}</h2>
<table id="table" class="display">
<thead>
<th>Package</th>
<th>Ebuilds</th>
<th>Unpackaged</th>
</thead>
<tbody>
{% for package in packages %}
{% if package.n_versions == package.n_packaged %}
<tr class="gradeA">
{% else %}{% if package.n_versions < package.n_packaged|mul:2 %}
<tr class="gradeC">
{% else %}
<tr class="gradeX">
{% endif %}{% endif %}
<td>
<a href="{% url euscan.views.package package.category package.name %}">
{{ package.category }}/{{ package.name }}
</a>
</td>
<td>{{ package.n_packaged }}</td>
<td>{{ package.n_versions|sub:package.n_packaged }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,73 @@
{% extends "euscan/_datatable.html" %}
{% load sub %}
{% block title %}
{{ block.super }} - {{ package.category }}/{{ package.name }}
{% endblock %}
{% block content %}
<h2>{{ package.category }}/{{ package.name }}</h2>
<dl>
{% if package.description %}
<dt>Description</dt>
<dd>{{ package.description }}</dd>
{% endif %}
{% if package.homepage %}
<dt>Homepage</dt>
<dd><a href="{{ package.homepage }}">{{ package.homepage }}</a></dd>
{% endif %}
{% if package.herds.all %}
<dt>Herds</dt>
<dd>
{% for herd in package.herds.all %}
<a href="{% url euscan.views.herd herd.herd %}">
{{ herd.herd }}
</a>
&lt;{{ herd.email }}&gt;
{% endfor %}
</dd>
{% endif %}
{% if package.maintainers.all %}
<dt>Maintainers</dt>
<dd>
{% for maintainer in package.maintainers.all %}
{% if maintainer.name != maintainer.email %}
<a href="{% url euscan.views.maintainer maintainer.id %}">
{{ maintainer.name }}
</a>
&lt;{{ maintainer.email }}&gt;
{% else %}
<a href="{% url euscan.views.maintainer maintainer.id %}">
{{ maintainer.email }}
</a>
{% endif %}
{% endfor %}
</dd>
{% endif %}
{% if packaged %}
<dt>Packaged Versions</dt>
<dd>
<ul>
{% for version in packaged %}
<li>
{{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}]
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
{% if upstream %}
<dt>Upstream versions</dt>
<dd>
<ul>
{% for version in upstream %}
<li>
{{ version.version }} - {{ version.url }}
</li>
{% endfor %}
</ul>
</dd>
{% endif %}
</dl>
{% endblock %}