summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/models.py18
-rw-r--r--media/arch.css10
-rw-r--r--migrate_signoff.sql10
-rw-r--r--packages/views.py28
-rw-r--r--templates/packages/signoffs.html19
-rw-r--r--urls.py6
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 @@ class Package(models.Model):
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 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, 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 %}
+ <div class="greybox">
+ {{message}}
+ </div>
+ <br />
+ {% endif %}
{% if packages %}
<div class="greybox">
<table class="results" width="100%">
@@ -27,8 +33,17 @@
<td>{{ pkg.maintainer|default:"Orphan" }}</td>
<td>{{ pkg.pkgver }}-{{ pkg.pkgrel }}</td>
<td>{{ pkg.last_update }}</td>
- <td></td>
- <td></td>
+ <td class="signoff_{{pkg.approved_for_signoff|yesno}}">{{ pkg.approved_for_signoff|yesno:"Yes,No" }}</td>
+ <td>
+ <ul>
+ {% for signoff in pkg.signoffs %}
+ <li>{{signoff.packager}}</li>
+ {% endfor %}
+ <li>
+ <a href="/packages/signoff_package/{{pkg.arch}}/{{pkg.pkgname}}/">Signoff</a>
+ </li>
+ </ul>
+ </td>
</tr>
{% endfor %}
</table>
diff --git a/urls.py b/urls.py
index 3c2fa9fd..2d21d02d 100644
--- a/urls.py
+++ b/urls.py
@@ -10,14 +10,16 @@ urlpatterns = patterns('',
(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<arch>[A-z0-9]+)/(?P<pkgname>[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<pkgid>\d+)/$', 'archweb_dev.packages.views.details'),
(r'^packages/(?P<name>[A-z0-9]+)/$', 'archweb_dev.packages.views.details'),
- (r'^packages/(?P<repo>[A-z0-9]+)/(?P<name>[A-z0-9]+)/$',
+ (r'^packages/(?P<repo>[A-z0-9]+)/(?P<name>[A-z0-9\-+.]+)/$',
'archweb_dev.packages.views.details'),
- (r'^packages/(?P<repo>[A-z0-9]+)/(?P<arch>[A-z0-9]+)/(?P<name>[A-z0-9-]+)/$',
+ (r'^packages/(?P<repo>[A-z0-9]+)/(?P<arch>[A-z0-9]+)/(?P<name>[A-z0-9\-+.]+)/$',
'archweb_dev.packages.views.details'),
(r'^packages/$', 'archweb_dev.packages.views.search'),