diff --git a/euscanwww/djeuscan/helpers.py b/euscanwww/djeuscan/helpers.py
index fb93a94..f7a6b82 100644
--- a/euscanwww/djeuscan/helpers.py
+++ b/euscanwww/djeuscan/helpers.py
@@ -74,3 +74,35 @@ class catch_and_return(object):
except self.err:
return self.response
return wrapper
+
+
+def get_account_categories(user):
+ from djeuscan.models import Package, CategoryAssociation
+
+ # TODO: This is quite ugly
+ category_names = [obj.category for obj in
+ CategoryAssociation.objects.filter(user=user)]
+ return [c for c in Package.objects.categories()
+ if c["category"] in category_names]
+
+
+def get_account_herds(user):
+ from djeuscan.models import Package, HerdAssociation
+
+ ids = [obj.herd.pk for obj in
+ HerdAssociation.objects.filter(user=user)]
+ return Package.objects.herds(ids=ids)
+
+
+def get_account_maintainers(user):
+ from djeuscan.models import Package, MaintainerAssociation
+
+ ids = [obj.maintainer.pk for obj in
+ MaintainerAssociation.objects.filter(user=user)]
+ return Package.objects.maintainers(ids=ids)
+
+
+def get_account_packages(user):
+ from djeuscan.models import PackageAssociation
+ return [obj.package for obj in
+ PackageAssociation.objects.filter(user=user)]
diff --git a/euscanwww/djeuscan/templates/euscan/accounts/index.html b/euscanwww/djeuscan/templates/euscan/accounts/index.html
index 46ba5c7..d2acf33 100644
--- a/euscanwww/djeuscan/templates/euscan/accounts/index.html
+++ b/euscanwww/djeuscan/templates/euscan/accounts/index.html
@@ -1,5 +1,6 @@
{% extends "_base.html" %}
{% load url from future %}
+{% load sub %}
{% block title %}
{{ block.super }} - Welcome {{ user }}
@@ -8,4 +9,88 @@
{% block content %}
Welcome {{ user }}
+
+
+ Summary
+
+
+
+ {% with categories|length as num_categories %}
+ Watching {{ num_categories }} categor{{ num_categories|pluralize:"y,es"}}
+
+ - {{ categories_upstream }} new upstream version{{ categories_upstream|pluralize:"s"}}
+ {% if categories_upstream %}
+ -
+ Hot categories:
+
+ {% for c in categories|slice:":3" %}
+ - {{ c.category }} ({{ c.n_versions|sub:c.n_packaged }})
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% endwith %}
+
+
+
+ {% with herds|length as num_herds %}
+ Watching {{ num_herds }} herd{{ num_herds|pluralize:"s"}}
+
+ - {{ herds_upstream }} new upstream version{{ herds_upstream|pluralize:"s"}}
+ {% if herds_upstream %}
+ -
+ Hot herds:
+
+ {% for c in herds|slice:":3" %}
+ - {{ c.herds__herd }} ({{ c.n_versions|sub:c.n_packaged }})
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% endwith %}
+
+
+
+
+
+
+ {% with maintainers|length as num_maintainers %}
+ Watching {{ num_maintainers }} maintainer{{ num_maintainers|pluralize:"s"}}
+
+ - {{ maintainers_upstream }} new upstream version{{ maintainers_upstream|pluralize:"s"}}
+ {% if maintainers_upstream %}
+ -
+ Hot maintainers:
+
+
+ {% endif %}
+
+ {% endwith %}
+
+
+
+ {% with packages|length as num_packages %}
+ Watching {{ num_packages }} package{{ num_packages|pluralize:"s"}}
+
+ - {{ packages_upstream }} new upstream version{{ packages_upstream|pluralize:"s"}}
+ {% if packages_upstream %}
+ -
+ Hot packages:
+
+ {% for c in packages|slice:":3" %}
+ - {{ c }} ({{ c.n_versions|sub:c.n_packaged }})
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% endwith %}
+
+
{% endblock %}
diff --git a/euscanwww/djeuscan/templates/registration/login.html b/euscanwww/djeuscan/templates/registration/login.html
index c1bf3ae..c198676 100644
--- a/euscanwww/djeuscan/templates/registration/login.html
+++ b/euscanwww/djeuscan/templates/registration/login.html
@@ -36,6 +36,6 @@
-
+
{% endblock %}
diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py
index d2a4fc5..09f48b9 100644
--- a/euscanwww/djeuscan/views.py
+++ b/euscanwww/djeuscan/views.py
@@ -8,7 +8,9 @@ from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_POST
-from djeuscan.helpers import version_key, packages_from_names
+from djeuscan.helpers import version_key, packages_from_names, \
+ get_account_categories, get_account_herds, get_account_maintainers, \
+ get_account_packages
from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \
VersionLog, RefreshPackageQuery, HerdAssociation, MaintainerAssociation, \
CategoryAssociation, PackageAssociation, OverlayAssociation, ProblemReport
@@ -359,43 +361,50 @@ def refresh_package(request, category, package):
@login_required
@render_to('euscan/accounts/index.html')
def accounts_index(request):
- return {}
+ upstream_k = lambda c: c["n_versions"] - c["n_packaged"]
+
+ categories = sorted(get_account_categories(request.user),
+ key=upstream_k, reverse=True)
+ c_upstream = sum([c["n_versions"] - c["n_packaged"] for c in categories])
+ herds = sorted(get_account_herds(request.user),
+ key=upstream_k, reverse=True)
+ h_upstream = sum([c["n_versions"] - c["n_packaged"] for c in herds])
+ maintainers = sorted(get_account_maintainers(request.user),
+ key=upstream_k, reverse=True)
+ m_upstream = sum([c["n_versions"] - c["n_packaged"] for c in maintainers])
+ packages = sorted(get_account_packages(request.user),
+ key=lambda p: p.n_versions - p.n_packaged, reverse=True)
+ p_upstream = sum([c.n_versions - c.n_packaged for c in packages])
+ return {
+ "categories": categories, "categories_upstream": c_upstream,
+ "herds": herds, "herds_upstream": h_upstream,
+ "maintainers": maintainers, "maintainers_upstream": m_upstream,
+ "packages": packages, "packages_upstream": p_upstream,
+ }
@login_required
@render_to('euscan/accounts/categories.html')
def accounts_categories(request):
- category_names = [obj.category for obj in
- CategoryAssociation.objects.filter(user=request.user)]
- categories = [c for c in Package.objects.categories()
- if c["category"] in category_names]
- return {"categories": categories}
+ return {"categories": get_account_categories(request.user)}
@login_required
@render_to('euscan/accounts/herds.html')
def accounts_herds(request):
- ids = [obj.herd.pk for obj in
- HerdAssociation.objects.filter(user=request.user)]
- herds = Package.objects.herds(ids=ids)
- return {"herds": herds}
+ return {"herds": get_account_herds(request.user)}
@login_required
@render_to('euscan/accounts/maintainers.html')
def accounts_maintainers(request):
- ids = [obj.maintainer.pk for obj in
- MaintainerAssociation.objects.filter(user=request.user)]
- maintainers = Package.objects.maintainers(ids=ids)
- return {"maintainers": maintainers}
+ return {"maintainers": get_account_maintainers(request.user)}
@login_required
@render_to('euscan/accounts/packages.html')
def accounts_packages(request):
- packages = [obj.package for obj in
- PackageAssociation.objects.filter(user=request.user)]
- return {"packages": packages}
+ return {"packages": get_account_packages(request.user)}
@login_required
diff --git a/euscanwww/htdocs/css/style.css b/euscanwww/htdocs/css/style.css
index 4a5e5d5..61736d4 100644
--- a/euscanwww/htdocs/css/style.css
+++ b/euscanwww/htdocs/css/style.css
@@ -234,6 +234,10 @@ th {
border-radius: 10px;
}
+.padded {
+ padding: 10px;
+}
+
textarea {
width: inherit;
}