diff options
-rw-r--r-- | devel/views.py | 23 | ||||
-rw-r--r-- | main/models.py | 28 | ||||
-rw-r--r-- | packages/views.py | 30 | ||||
-rw-r--r-- | templates/devel/index.html | 26 | ||||
-rw-r--r-- | templates/devel/siteindex.html | 2 | ||||
-rw-r--r-- | templates/feeds/news_description.html | 1 | ||||
-rw-r--r-- | templates/feeds/news_title.html | 1 | ||||
-rw-r--r-- | templates/feeds/packages_description.html | 1 | ||||
-rw-r--r-- | templates/feeds/packages_title.html | 1 | ||||
-rw-r--r-- | templates/packages/details.html | 20 | ||||
-rw-r--r-- | templates/packages/search.html | 18 | ||||
-rw-r--r-- | templates/todolists/view.html | 2 | ||||
-rw-r--r-- | todolists/views.py | 2 |
13 files changed, 88 insertions, 67 deletions
diff --git a/devel/views.py b/devel/views.py index 741b869..978837b 100644 --- a/devel/views.py +++ b/devel/views.py @@ -4,7 +4,7 @@ from django.contrib.auth.models import User from django.core import validators from archweb_dev.main.utils import render_response, validate from archweb_dev.main.models import Package, Repo, Todolist, TodolistPkg -from archweb_dev.main.models import UserProfile, News, Donor, Mirror +from archweb_dev.main.models import UserProfile, News, Donor, Mirror, Arch from django.http import HttpResponse from django.template import Context, loader @@ -26,6 +26,13 @@ def index(request): pkgs = Package.objects.filter(maintainer=thismaint.id).filter(needupdate=True).order_by('repo', 'pkgname') else: pkgs = None + arch_stats = [] + for arch in Arch.objects.all(): + arch_stats.append({ + 'name': arch.name, + 'count': Package.objects.filter(arch__exact = arch).count(), + 'flagged': Package.objects.filter(arch__exact = arch).filter(needupdate=True).count() + }) repo_stats = [] for repo in Repo.objects.all(): @@ -35,12 +42,10 @@ def index(request): 'flagged': Package.objects.filter(repo__exact = repo).filter(needupdate=True).count() }) - return render_response(request, 'devel/index.html', - {'stats':stats, - 'pkgs':pkgs, - 'todos':todos, - 'maint':thismaint, - 'repos': repo_stats}) + return render_response( + request, 'devel/index.html', + {'stats': stats, 'pkgs': pkgs, 'todos': todos, 'maint': thismaint, + 'repos': repo_stats, 'archs': arch_stats}) @login_required #@is_maintainer @@ -86,7 +91,9 @@ def siteindex(request): news = News.objects.order_by('-postdate', '-id')[:10] pkgs = Package.objects.exclude(repo__name__exact='Testing').order_by('-last_update')[:15] repos = Repo.objects.order_by('name') - return render_response(request, 'devel/siteindex.html', {'news_updates':news,'pkg_updates':pkgs,'repos':repos}) + return render_response( + request, 'devel/siteindex.html', + {'news_updates': news, 'pkg_updates': pkgs, 'repos': repos}) def cvs(request): return render_response(request, 'devel/cvs.html') diff --git a/main/models.py b/main/models.py index 1a6423c..7b31f07 100644 --- a/main/models.py +++ b/main/models.py @@ -137,6 +137,8 @@ class Arch(models.Model): class Meta: db_table = 'arch' ordering = ['name'] + def __str__(self): + return self.name class Repo(models.Model): id = models.AutoField(primary_key=True) @@ -154,8 +156,8 @@ class Repo(models.Model): class Package(models.Model): id = models.AutoField(primary_key=True) - repo = models.ForeignKey(Repo) - arch = models.ForeignKey(Arch) + repo = models.ForeignKey('Repo') + arch = models.ForeignKey('Arch') maintainer = models.ForeignKey(User, related_name='package_maintainer') needupdate = models.BooleanField(default=False) pkgname = models.CharField(maxlength=255) @@ -163,7 +165,7 @@ class Package(models.Model): pkgrel = models.CharField(maxlength=255) pkgdesc = models.CharField(maxlength=255) url = models.URLField() - depends = models.ForeignKey(PackageDepends) + depends = models.ForeignKey('PackageDepends') last_update = models.DateTimeField(null=True, blank=True) objects = PackageManager() class Meta: @@ -173,6 +175,16 @@ class Package(models.Model): def get_absolute_url(self): return '/packages/%i/' % self.id + def required_by_urlize(self): + urls = [] + requiredby = PackageDepends.objects.filter(depname=self.pkgname) + for req in requiredby.package_set.all(): + urls.append( + '<li><a href="/packages/%d">%s</a></li>' % \ + (req.id,req.pkgname)) + return ''.join(urls) + + def depends_urlize(self): urls = [] for dep in self.packagedepends_set.all(): @@ -181,7 +193,7 @@ class Package(models.Model): except IndexError: # couldn't find a package in the DB # it might be a virtual depend - urls.append('<li>%s</li>' % dep.depname) + urls.append('<li>%s (v)</li>' % dep.depname) continue urls.append( '<li><a href="/packages/%d">%s</a></li>' % (p.id,dep.depname)) @@ -189,14 +201,14 @@ class Package(models.Model): class PackageFile(models.Model): id = models.AutoField(primary_key=True) - pkg = models.ForeignKey(Package) + pkg = models.ForeignKey('Package') path = models.CharField(maxlength=255) class Meta: db_table = 'packages_files' class PackageDepends(models.Model): id = models.AutoField(primary_key=True) - pkg = models.ForeignKey(Package) + pkg = models.ForeignKey('Package') depname = models.CharField(db_index=True, maxlength=255) depvcmp = models.CharField(maxlength=255) class Meta: @@ -214,8 +226,8 @@ class Todolist(models.Model): class TodolistPkg(models.Model): id = models.AutoField(primary_key=True) - list = models.ForeignKey(Todolist) - pkg = models.ForeignKey(Package) + list = models.ForeignKey('Todolist') + pkg = models.ForeignKey('Package') complete = models.BooleanField(default=False) class Meta: db_table = 'todolists_pkgs' diff --git a/packages/views.py b/packages/views.py index 25bb342..fef5efc 100644 --- a/packages/views.py +++ b/packages/views.py @@ -7,7 +7,8 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from datetime import datetime from archweb_dev.main.utils import validate, render_response -from archweb_dev.main.models import Package, PackageFile, Repo, Category +from archweb_dev.main.models import Arch, Repo +from archweb_dev.main.models import Package, PackageFile, PackageDepends from django.core.exceptions import ObjectDoesNotExist @@ -45,18 +46,7 @@ def details(request, pkgid=0, name='', repo=''): pkgid = p[0].id pkg = get_object_or_404(Package, id=pkgid) - origin_repo = None - if pkg.repo.name == 'Testing': - try: - origin_repo = Package.objects.filter( - pkgname__exact = pkg.pkgname).exclude( - repo__name__exact = pkg.repo.name).get().repo.name - except ObjectDoesNotExist: - origin_repo = None - return render_response( - request, - 'packages/details.html', - {'pkg': pkg, 'origin_repo': origin_repo}) + return render_response(request, 'packages/details.html', {'pkg': pkg}) def search(request, query=''): if request.GET.has_key('q'): @@ -65,7 +55,7 @@ def search(request, query=''): # fetch the form vars repo = request.GET.get('repo', 'all') - category = request.GET.get('category', 'all') + arch = request.GET.get('arch', 'all') lastupdate = request.GET.get('lastupdate', '') limit = int(request.GET.get('limit', '50')) skip = int(request.GET.get('skip', '0')) @@ -74,10 +64,10 @@ def search(request, query=''): # build the form lists repos = Repo.objects.order_by('name') - cats = Category.objects.order_by('category') + archs = Arch.objects.order_by('name') # copy GET data over and add the lists c = request.GET.copy() - c['repos'], c['categories'] = repos, cats + c['repos'], c['archs'] = repos, archs c['limit'], c['skip'] = limit, skip c['lastupdate'] = lastupdate c['sort'] = sort @@ -100,18 +90,16 @@ def search(request, query=''): else: results = Package.objects.all() if repo != 'all': results = results.filter(repo__name__exact=repo) - if category != 'all': results = results.filter(category__category__exact=category) + if arch != 'all': results = results.filter(arch__name__exact=arch) if maint != 'all': results = results.filter(maintainer=maint) if lastupdate: results = results.filter(last_update__gte=datetime(int(lastupdate[0:4]),int(lastupdate[5:7]),int(lastupdate[8:10]))) - # select_related() shouldn't be needed -- we're working around a Django bug - #results = results.select_related().order_by('repos.name', 'category', 'pkgname') # sort results if sort == '': - results = results.order_by('repo', 'category', 'pkgname') + results = results.order_by('repo', 'arch', 'pkgname') else: # duplicate sort fields shouldn't hurt anything - results = results.order_by(sort, 'repo', 'category', 'pkgname') + results = results.order_by(sort, 'repo', 'arch', 'pkgname') qs = request.GET.copy() # build pagination urls diff --git a/templates/devel/index.html b/templates/devel/index.html index afbec25..091fcb9 100644 --- a/templates/devel/index.html +++ b/templates/devel/index.html @@ -23,11 +23,29 @@ {% endif %} <div class="greybox"> - <h3 class="title">Repository Package Stats</h3> + <h3 class="title">Stats by Architecture</h3> + <table class="results" width="100%"> + <tr> + <th width="50%">Arch</th> + <th># Packages</th> + <th># Flagged</th> + </tr> + {% for arch in archs %} + <tr class="{% cycle pkgr2,pkgr1 %}"> + <td><a href="/packages/?arch={{ arch.name }}">{{ arch.name }}</a></td> + <td><strong>{{ repo.count }}</strong> packages</td> + <td><strong>{{ repo.flagged }}</strong> packages</td> + </tr> + {% endfor %} + </table> + </div> + <br /><br /> + <div class="greybox"> + <h3 class="title">Stats by Repository</h3> <table class="results" width="100%"> <tr> <th width="50%">Repository</th> - <th># Package</th> + <th># Packages</th> <th># Flagged</th> </tr> {% for repo in repos %} @@ -42,11 +60,11 @@ <br /><br /> <div class="greybox"> - <h3 class="title">Maintainer Package Stats</h3> + <h3 class="title">Stats by Maintainer</h3> <table class="results" width="100%"> <tr> <th width="50%">Maintainer</th> - <th># Package</th> + <th># Packages</th> <th># Flagged</th> </tr> {% for maint in stats %} diff --git a/templates/devel/siteindex.html b/templates/devel/siteindex.html index 0c25fd8..e97d915 100644 --- a/templates/devel/siteindex.html +++ b/templates/devel/siteindex.html @@ -21,7 +21,7 @@ {% for pkg in pkg_updates %} <tr> <td><a href="{{ pkg.get_absolute_url }}">{{ pkg.pkgname }} {{ pkg.pkgver }}-{{ pkg.pkgrel }}</a></td> - <td style="text-align:right">{{ pkg.category.category }}</td> + <td style="text-align:right">{{ pkg.arch.name }}</td> </tr> {% endfor %} <tr> diff --git a/templates/feeds/news_description.html b/templates/feeds/news_description.html deleted file mode 100644 index 26e1cbb..0000000 --- a/templates/feeds/news_description.html +++ /dev/null @@ -1 +0,0 @@ -{{ obj.content }} diff --git a/templates/feeds/news_title.html b/templates/feeds/news_title.html deleted file mode 100644 index d355de5..0000000 --- a/templates/feeds/news_title.html +++ /dev/null @@ -1 +0,0 @@ -{{ obj.title }} diff --git a/templates/feeds/packages_description.html b/templates/feeds/packages_description.html deleted file mode 100644 index 6b9c47b..0000000 --- a/templates/feeds/packages_description.html +++ /dev/null @@ -1 +0,0 @@ -{{ obj.pkgdesc }} diff --git a/templates/feeds/packages_title.html b/templates/feeds/packages_title.html deleted file mode 100644 index a273162..0000000 --- a/templates/feeds/packages_title.html +++ /dev/null @@ -1 +0,0 @@ -{{ obj.pkgname }} {{ obj.pkgver }}-{{ obj.pkgrel }} diff --git a/templates/packages/details.html b/templates/packages/details.html index a0e7821..1435557 100644 --- a/templates/packages/details.html +++ b/templates/packages/details.html @@ -6,11 +6,6 @@ <h2 class="title">{{ pkg.pkgname }} {{ pkg.pkgver }}-{{ pkg.pkgrel }}</h2> <div style="float:right" class="listing"> <ul class="small"> - {% if origin_repo %} - <li><a href="http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/{{ pkg.category.category }}/{{ pkg.pkgname }}/?cvsroot={{ origin_repo }}&only_with_tag=TESTING">View CVS Entries</a></li> - {% else %} - <li><a href="http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/{{ pkg.category.category }}/{{ pkg.pkgname }}/?cvsroot={{ pkg.repo.name }}&only_with_tag=CURRENT">View CVS Entries</a></li> - {% endif %} <li><a href="/packages/files/{{ pkg.id }}/">View File List</a></li> <li> {% if pkg.needupdate %} @@ -37,12 +32,12 @@ </div> <table class="listing"> <tr> + <th>Architecture:</th> + <td>{{ pkg.arch.name }}</td> + </tr><tr> <th>Repository:</th> <td>{{ pkg.repo.name }}</td> </tr><tr> - <th>Category:</th> - <td>{{ pkg.category.category }}</td> - </tr><tr> <th>Description:</th> <td>{{ pkg.pkgdesc }}</td> </tr><tr> @@ -66,11 +61,14 @@ {{ pkg.depends_urlize }} </ul> </div> - </td><td colspan="2" valign="top"> + </td> + </tr> + <tr> + <td valign="top"> <div class="listing"> - <h4>Sources:</h4> + <h4>Required By:</h4> <ul style="font-size:small;list-style:none"> - {{ pkg.sources_urlize }} + {{ pkg.required_by_urlize }} </ul> </div> </td> diff --git a/templates/packages/search.html b/templates/packages/search.html index c5006cd..309f926 100644 --- a/templates/packages/search.html +++ b/templates/packages/search.html @@ -17,24 +17,24 @@ <form method="get" action="/packages/search/"> <table width="100%"> <tr> + <td><span class="smalltext">Arch</span></td> <td><span class="smalltext">Repository</span></td> - <td><span class="smalltext">Category</span></td> <td><span class="smalltext">Keywords</span></td> <td><span class="smalltext">Last Update</span></td> <td><span class="smalltext">Per Page</span></td> </tr><tr> <td> - <select name="repo"> + <select name="arch"> <option value="all">All</option> - {% for r in repos %} - <option value="{{ r.name }}"{% ifequal repo r.name %} selected{% endifequal %}>{{ r.name|capfirst }}</option> + {% for a in archs %} + <option value="{{ a.arch }}"{% ifequal arch a.name %} selected{% endifequal %}>{{ a.name }}</option> {% endfor %} </select> </td><td> - <select name="category"> + <select name="repo"> <option value="all">All</option> - {% for c in categories %} - <option value="{{ c.category }}"{% ifequal category c.category %} selected{% endifequal %}>{{ c.category|capfirst }}</option> + {% for r in repos %} + <option value="{{ r.name }}"{% ifequal repo r.name %} selected{% endifequal %}>{{ r.name|capfirst }}</option> {% endfor %} </select> </td><td> @@ -75,8 +75,8 @@ <form method="post" action="/packages/update/"> <th> </th> {% endif %} + <th><a href="{% buildsortqs "arch" %}">Arch</a></th> <th><a href="{% buildsortqs "repo" %}">Repo</a></th> - <th><a href="{% buildsortqs "category" %}">Category</a></th> <th><a href="{% buildsortqs "pkgname" %}">Name</a></th> <th>Version</th> <th>Description</th> @@ -87,8 +87,8 @@ {% if not user.is_anonymous %} <td><input type="checkbox" name="pkgid" value="{{ pkg.id }}" /></td> {% endif %} + <td>{{ pkg.arch.name }}</td> <td>{{ pkg.repo.name }}</td> - <td>{{ pkg.category.category }}</td> <td><a href="{{ pkg.get_absolute_url }}">{{ pkg.pkgname }}</a></td> {% if pkg.needupdate %} <td><span style="color:red">{{ pkg.pkgver }}-{{ pkg.pkgrel }}</span></td> diff --git a/templates/todolists/view.html b/templates/todolists/view.html index 7cd58dc..b77e6e7 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -6,6 +6,7 @@ <table class="results" width="100%"> <tr> <th>ID</th> + <th>Arch</th> <th>Repo</th> <th>Name</th> <th>Maintainer</th> @@ -14,6 +15,7 @@ {% for pkg in pkgs %} <tr class="{% cycle pkgr1,pkgr2 %}"> <td><a href="/packages/{{ pkg.pkg.id }}/">{{ pkg.pkg.id }}</a></td> + <td>{{ pkg.pkg.arch.name }}</td> <td>{{ pkg.pkg.repo.name }}</td> <td>{{ pkg.pkg.pkgname }}</td> <td>{{ pkg.pkg.maintainer.get_full_name }}</td> diff --git a/todolists/views.py b/todolists/views.py index 59dc5db..dbfd440 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -49,7 +49,7 @@ def add(request): todo.save() # now link in packages for p in request.POST.get('packages').split("\n"): - for pkg in Package.objects.filter(pkgname=p.strip()): + for pkg in Package.objects.filter(pkgname=p.strip()).order_by('arch'): todopkg = TodolistPkg( list = todo, pkg = pkg) |