summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvangelos Foutras <foutrelis@gmail.com>2010-01-31 06:53:27 +0100
committerDan McGee <dan@archlinux.org>2010-01-31 20:44:03 +0100
commit09a3a08144fd14fcd905cdf3e86dcc240458040c (patch)
tree72a03516cf3fa888d57cdca5b1fb18717532849f
parent2c3c6cc2e1dc070395481f92f5499113b9e5a6bf (diff)
downloadarchweb-09a3a08144fd14fcd905cdf3e86dcc240458040c.tar.gz
archweb-09a3a08144fd14fcd905cdf3e86dcc240458040c.tar.xz
Adjust models and views for nullable maintainer
Signed-off-by: Evangelos Foutras <foutrelis@gmail.com> [Dan: made a few other small touchups] Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/views.py2
-rw-r--r--main/models.py2
-rw-r--r--packages/views.py16
-rwxr-xr-xscripts/reporead.py7
-rw-r--r--todolists/views.py2
5 files changed, 12 insertions, 17 deletions
diff --git a/devel/views.py b/devel/views.py
index 29dfcd0..78c466a 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -21,7 +21,7 @@ def index(request):
'todos': Todolist.objects.incomplete(),
'repos': Repo.objects.all(), 'arches': Arch.objects.all(),
'maintainers': [
- User(id=0, username="orphan", first_name="Orphans")
+ User(id=None, username="orphan", first_name="Orphans")
] + list(User.objects.filter(is_active=True).order_by('last_name'))
}
diff --git a/main/models.py b/main/models.py
index 7a3496a..98547a3 100644
--- a/main/models.py
+++ b/main/models.py
@@ -162,7 +162,7 @@ class Package(models.Model):
id = models.AutoField(primary_key=True)
repo = models.ForeignKey(Repo, related_name="packages")
arch = models.ForeignKey(Arch, related_name="packages")
- maintainer = models.ForeignKey(User, related_name="maintained_packages")
+ maintainer = models.ForeignKey(User, related_name="maintained_packages", null=True, blank=True)
needupdate = models.BooleanField(default=False)
pkgname = models.CharField(max_length=255)
pkgbase = models.CharField(max_length=255, null=True, blank=True)
diff --git a/packages/views.py b/packages/views.py
index d696b7e..aa66271 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -21,10 +21,10 @@ def update(request):
mode = None
if request.POST.has_key('adopt'):
mode = 'adopt'
- maint_id = request.user.id
+ maint = request.user
if request.POST.has_key('disown'):
mode = 'disown'
- maint_id = 0
+ maint = None
if mode:
pkgs = Package.objects.filter(
@@ -35,7 +35,7 @@ def update(request):
repo__in=request.user.userprofile_user.all(
)[0].allowed_repos.all())
for pkg in pkgs:
- pkg.maintainer_id = maint_id
+ pkg.maintainer = maint
pkg.save()
request.user.message_set.create(message="%d packages %sed" % (
@@ -65,8 +65,8 @@ def getmaintainer(request, name, repo, arch):
pkg= get_object_or_404(Package,
pkgname=name, repo__name__iexact=repo, arch__name=arch)
- return HttpResponse(str(pkg.maintainer if pkg.maintainer_id else 'None'))
-
+ return HttpResponse(str(pkg.maintainer))
+
class PackageSearchForm(forms.Form):
repo = forms.ChoiceField(required=False)
arch = forms.ChoiceField(required=False)
@@ -132,7 +132,7 @@ def search(request, page=None):
packages = packages.filter(
arch__name=form.cleaned_data['arch'])
if form.cleaned_data['maintainer'] == 'orphan':
- packages=packages.filter(maintainer__id = 0)
+ packages=packages.filter(maintainer=None)
elif form.cleaned_data['maintainer']:
packages = packages.filter(
maintainer__username=form.cleaned_data['maintainer'])
@@ -251,8 +251,8 @@ def flag(request, pkgid):
for package in pkgs:
package.needupdate = 1
package.save()
-
- if pkg.maintainer_id == 0:
+
+ if not pkg.maintainer:
toemail = 'arch-notifications@archlinux.org'
subject = 'Orphan %s package [%s] marked out-of-date' % (pkg.repo.name, pkg.pkgname)
else:
diff --git a/scripts/reporead.py b/scripts/reporead.py
index 5d0ff26..c346afa 100755
--- a/scripts/reporead.py
+++ b/scripts/reporead.py
@@ -236,12 +236,7 @@ def db_update(archname, pkgs):
for p in [x for x in pkgs if x.name in in_sync_not_db]:
logger.info("Adding package %s", p.name)
- ## note: maintainer is being set to orphan for now
- ## maybe later we can add logic to match pkgbuild maintainers
- ## to db maintainer ids
- pkg = Package(
- pkgname = p.name, arch = architecture, repo = repository,
- maintainer_id = 0)
+ pkg = Package(pkgname = p.name, arch = architecture, repo = repository)
populate_pkg(pkg, p, timestamp=now)
# packages in database and not in syncdb (remove from database)
diff --git a/todolists/views.py b/todolists/views.py
index c06397e..00236c6 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -124,7 +124,7 @@ def delete_todolist(request, object_id):
def send_todolist_email(todo):
'''Sends an e-mail to the maintainer of a package notifying them that the
package has been added to a to-do list'''
- if todo.pkg.maintainer_id == 0:
+ if not todo.pkg.maintainer:
return
page_dict = {