From ac63cc4101da73e5b1b4424c53f29033557c6596 Mon Sep 17 00:00:00 2001 From: Dusty Phillips Date: Sat, 16 Aug 2008 13:36:15 -0400 Subject: #10340 Integrated Signoffs completed but untested --- main/models.py | 18 ++++++++++++------ media/arch.css | 10 ++++++++++ migrate_signoff.sql | 10 +++------- packages/views.py | 28 +++++++++++++++++++++++++--- templates/packages/signoffs.html | 19 +++++++++++++++++-- urls.py | 6 ++++-- 6 files changed, 71 insertions(+), 20 deletions(-) diff --git a/main/models.py b/main/models.py index 7cd00bff..49df21eb 100644 --- a/main/models.py +++ b/main/models.py @@ -225,6 +225,17 @@ def get_absolute_url(self): return '/packages/%s/%s/%s/' % (self.repo.name.lower(), self.arch.name, self.pkgname) + @property + def signoffs(self): + return Signoff.objects.filter( + pkg=self, + pkgver=self.pkgver, + pkgrel=self.pkgrel) + + def approved_for_signoff(self): + return self.signoffs.count() >= 2 + + def get_requiredby(self): """ Returns a list of package objects. @@ -270,12 +281,7 @@ class Signoff(models.Model): pkg = models.ForeignKey(Package) pkgver = models.CharField(maxlength=255) pkgrel = models.CharField(maxlength=255) - signed_off = models.ManyToManyField(User) - - def is_approved(self): - if signed_off.all().count() > 2: - return True - return False + packager = models.ForeignKey(User) class PackageFile(models.Model): id = models.AutoField(primary_key=True) diff --git a/media/arch.css b/media/arch.css index da4ef937..f1419fce 100644 --- a/media/arch.css +++ b/media/arch.css @@ -371,6 +371,16 @@ div.wikifoot_r { border: 1px solid black; } +td.signoff_yes { + font-size: large; + color: green; + font-weight: bold; +} +td.signoff_no { + font-size: large; + color: red; +} + /* Used by Django's FormWrappers */ textarea.vLargeTextField { width: 450px; diff --git a/migrate_signoff.sql b/migrate_signoff.sql index ed2ceef5..800062a7 100644 --- a/migrate_signoff.sql +++ b/migrate_signoff.sql @@ -2,13 +2,9 @@ CREATE TABLE `main_signoff` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `pkg_id` integer NOT NULL, `pkgver` varchar(255) NOT NULL, - `pkgrel` varchar(255) NOT NULL -); -CREATE TABLE `main_signoff_signed_off` ( - `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, - `signoff_id` integer NOT NULL REFERENCES `main_signoff` (`id`), - `user_id` integer NOT NULL REFERENCES `auth_user` (`id`), - UNIQUE (`signoff_id`, `user_id`) + `pkgrel` varchar(255) NOT NULL, + `packager_id` integer NOT NULL REFERENCES `auth_user` (`id`) ); CREATE INDEX main_signoff_pkg_id ON `main_signoff` (`pkg_id`); +CREATE INDEX main_signoff_packager_id ON `main_signoff` (`packager_id`); diff --git a/packages/views.py b/packages/views.py index 4fec2558..8210353e 100644 --- a/packages/views.py +++ b/packages/views.py @@ -7,7 +7,7 @@ from datetime import datetime from archweb_dev.main.utils import validate, render_response from archweb_dev.main.models import Package, PackageFile, PackageDepend -from archweb_dev.main.models import Arch, Repo +from archweb_dev.main.models import Arch, Repo, Signoff from django.core.exceptions import ObjectDoesNotExist @@ -145,10 +145,32 @@ def unflag(request, pkgid): pkg.save() return HttpResponseRedirect('/packages/%d/' % (pkg.id)) -def signoffs(request): +def signoffs(request, message=None): packages = Package.objects.filter(repo__name="Testing").order_by("pkgname") return render_response(request, 'packages/signoffs.html', - {'packages': packages}) + {'packages': packages, 'message': message}) + +def signoff_package(request, arch, pkgname): + pkg = get_object_or_404(Package, + arch__name=arch, + pkgname=pkgname, + repo__name="Testing") + + signoff, created = Signoff.objects.get_or_create( + pkg=pkg, + pkgver=pkg.pkgver, + pkgrel=pkg.pkgrel, + packager=request.user) + + if created: + message = "You have successfully signed off for %s on %s" % ( + pkg.pkgname, pkg.arch) + else: + message = "You have already signed off for %s on %s" % ( + pkg.pkgname, pkg.arch) + + return signoffs(request, message) + # vim: set ts=4 sw=4 et: diff --git a/templates/packages/signoffs.html b/templates/packages/signoffs.html index 5c40006e..85c217de 100644 --- a/templates/packages/signoffs.html +++ b/templates/packages/signoffs.html @@ -8,6 +8,12 @@ {% endblock %} {% block content %} + {% if message %} +
+ {{message}} +
+
+ {% endif %} {% if packages %}
@@ -27,8 +33,17 @@ - - + + {% endfor %}
{{ pkg.maintainer|default:"Orphan" }} {{ pkg.pkgver }}-{{ pkg.pkgrel }} {{ pkg.last_update }}{{ pkg.approved_for_signoff|yesno:"Yes,No" }} +
    + {% for signoff in pkg.signoffs %} +
  • {{signoff.packager}}
  • + {% endfor %} +
  • + Signoff +
  • +
+
diff --git a/urls.py b/urls.py index 3c2fa9fd..2d21d02d 100644 --- a/urls.py +++ b/urls.py @@ -10,14 +10,16 @@ (r'^packages/unflag/(\d+)/$', 'archweb_dev.packages.views.unflag'), (r'^packages/files/(\d+)/$', 'archweb_dev.packages.views.files'), (r'^packages/signoffs/$', 'archweb_dev.packages.views.signoffs'), + (r'^packages/signoff_package/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', + 'archweb_dev.packages.views.signoff_package'), (r'^packages/search/$', 'archweb_dev.packages.views.search'), (r'^packages/search/([A-z0-9]+)/$', 'archweb_dev.packages.views.search'), (r'^packages/update/$', 'archweb_dev.packages.views.update'), (r'^packages/(?P\d+)/$', 'archweb_dev.packages.views.details'), (r'^packages/(?P[A-z0-9]+)/$', 'archweb_dev.packages.views.details'), - (r'^packages/(?P[A-z0-9]+)/(?P[A-z0-9]+)/$', + (r'^packages/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', 'archweb_dev.packages.views.details'), - (r'^packages/(?P[A-z0-9]+)/(?P[A-z0-9]+)/(?P[A-z0-9-]+)/$', + (r'^packages/(?P[A-z0-9]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', 'archweb_dev.packages.views.details'), (r'^packages/$', 'archweb_dev.packages.views.search'), -- cgit v1.2.3-54-g00ecf