summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--devel/management/commands/rematch_developers.py (renamed from devel/management/commands/rematch_packager.py)47
-rw-r--r--devel/management/commands/reporead.py8
-rw-r--r--devel/utils.py21
-rw-r--r--main/models.py11
-rw-r--r--packages/models.py5
-rw-r--r--packages/views/flag.py6
-rw-r--r--requirements.txt3
-rw-r--r--requirements_prod.txt4
-rw-r--r--sitestatic/archweb.css5
-rw-r--r--templates/packages/details.html5
-rw-r--r--templates/todolists/view.html14
11 files changed, 110 insertions, 19 deletions
diff --git a/devel/management/commands/rematch_packager.py b/devel/management/commands/rematch_developers.py
index 461d83ab..8383cc8d 100644
--- a/devel/management/commands/rematch_packager.py
+++ b/devel/management/commands/rematch_developers.py
@@ -1,20 +1,25 @@
# -*- coding: utf-8 -*-
"""
-rematch_packager command
+rematch_developers command
Match all packages with a packager_str but NULL packager_id to a packager if we
can find one.
-Usage: ./manage.py rematch_packager
+Also, match all flag requests with a NULL user_id that have a user_email
+matching up to a developer if we can find one.
+
+Usage: ./manage.py rematch_developers
"""
from django.core.management.base import NoArgsCommand
+from django.db import transaction
import sys
import logging
from devel.utils import UserFinder
from main.models import Package
+from packages.models import FlagRequest
logging.basicConfig(
level=logging.INFO,
@@ -24,7 +29,7 @@ logging.basicConfig(
logger = logging.getLogger()
class Command(NoArgsCommand):
- help = "Match all packages with a packager_str but NULL packager_id to a packager if we can find one."
+ help = "Match and map objects in database to developer emails"
def handle_noargs(self, **options):
v = int(options.get('verbosity', None))
@@ -35,15 +40,19 @@ class Command(NoArgsCommand):
elif v == 2:
logger.level = logging.DEBUG
- return match_packager()
+ finder = UserFinder()
+ match_packager(finder)
+ match_flagrequest(finder)
-def match_packager():
- finder = UserFinder()
+@transaction.commit_on_success
+def match_packager(finder):
logger.info("getting all unmatched packages")
package_count = matched_count = 0
unknown = set()
for package in Package.objects.filter(packager__isnull=True):
+ if package.packager_str in unknown:
+ continue
logger.debug("package %s, packager string %s",
package.pkgname, package.packager_str)
package_count += 1
@@ -56,9 +65,33 @@ def match_packager():
else:
unknown.add(package.packager_str)
- logger.info("%d packages checked, %d newly matched",
+ logger.info("%d packager strings checked, %d newly matched",
package_count, matched_count)
logger.debug("unknown packagers:\n%s",
"\n".join(unknown))
+
+@transaction.commit_on_success
+def match_flagrequest(finder):
+ logger.info("getting all non-user flag requests")
+ req_count = matched_count = 0
+ unknown = set()
+
+ for request in FlagRequest.objects.filter(user__isnull=True):
+ if request.user_email in unknown:
+ continue
+ logger.debug("email %s", request.user_email)
+ req_count += 1
+ user = finder.find_by_email(request.user_email)
+ if user:
+ request.user = user
+ logger.debug(" found user %s" % user.username)
+ request.save()
+ matched_count += 1
+ else:
+ unknown.add(request.user_email)
+
+ logger.info("%d request emails checked, %d newly matched",
+ req_count, matched_count)
+
# vim: set ts=4 sw=4 et:
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 2558d228..30c09c5e 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -193,6 +193,13 @@ def create_multivalued(dbpkg, repopkg, db_attr, repo_attr):
finder = UserFinder()
def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
+ # we reset the flag date only if the upstream version components change;
+ # e.g. epoch or pkgver, but not pkgrel
+ if dbpkg.epoch is None or dbpkg.epoch != repopkg.epoch:
+ dbpkg.flag_date = None
+ elif dbpkg.pkgver is None or dbpkg.pkgver != repopkg.ver:
+ dbpkg.flag_date = None
+
if repopkg.base:
dbpkg.pkgbase = repopkg.base
else:
@@ -215,7 +222,6 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
dbpkg.pgp_signature = repopkg.pgpsig
if timestamp:
- dbpkg.flag_date = None
dbpkg.last_update = timestamp
dbpkg.save()
diff --git a/devel/utils.py b/devel/utils.py
index 62b12cd5..ec035d13 100644
--- a/devel/utils.py
+++ b/devel/utils.py
@@ -48,6 +48,7 @@ class UserFinder(object):
def __init__(self):
self.cache = {}
self.username_cache = {}
+ self.email_cache = {}
@staticmethod
def user_email(name, email):
@@ -110,6 +111,7 @@ class UserFinder(object):
pass
self.cache[userstring] = user
+ self.email_cache[email] = user
return user
def find_by_username(self, username):
@@ -126,8 +128,27 @@ class UserFinder(object):
self.username_cache[username] = user
return user
+ def find_by_email(self, email):
+ if not email:
+ return None
+ if email in self.email_cache:
+ return self.email_cache[email]
+
+ user = None
+ try:
+ user = self.user_email(None, email)
+ except User.DoesNotExist:
+ try:
+ user = self.profile_email(None, email)
+ except User.DoesNotExist:
+ pass
+
+ self.email_cache[email] = user
+ return user
+
def clear_cache(self):
self.cache = {}
self.username_cache = {}
+ self.email_cache = {}
# vim: set ts=4 sw=4 et:
diff --git a/main/models.py b/main/models.py
index d72f2c05..15a92662 100644
--- a/main/models.py
+++ b/main/models.py
@@ -312,6 +312,17 @@ class Package(models.Model):
repo__testing=self.repo.testing, repo__staging=self.repo.staging,
pkgbase=self.pkgbase).exclude(id=self.id)
+ def flag_request(self):
+ if not self.flag_date:
+ return None
+ from packages.models import FlagRequest
+ try:
+ request = FlagRequest.objects.filter(pkgbase=self.pkgbase,
+ repo=self.repo).latest()
+ return request
+ except FlagRequest.DoesNotExist:
+ return None
+
def is_same_version(self, other):
'is this package similar, name and version-wise, to another'
return self.pkgname == other.pkgname \
diff --git a/packages/models.py b/packages/models.py
index f63d6db0..820e61ba 100644
--- a/packages/models.py
+++ b/packages/models.py
@@ -184,6 +184,9 @@ class FlagRequest(models.Model):
is_legitimate = models.BooleanField(default=True,
help_text="Is this actually an out-of-date flag request?")
+ class Meta:
+ get_latest_by = 'created'
+
def who(self):
if self.user:
return self.user.get_full_name()
@@ -258,7 +261,7 @@ class Replacement(models.Model):
# hook up some signals
-for sender in (PackageRelation, SignoffSpecification, Signoff, FlagRequest):
+for sender in (PackageRelation, SignoffSpecification, Signoff):
pre_save.connect(set_created_field, sender=sender,
dispatch_uid="packages.models")
diff --git a/packages/views/flag.py b/packages/views/flag.py
index f74a718a..ad1b04db 100644
--- a/packages/views/flag.py
+++ b/packages/views/flag.py
@@ -61,9 +61,11 @@ def flag(request, name, repo, arch):
@transaction.commit_on_success
def perform_updates():
- pkgs.update(flag_date=datetime.utcnow())
+ now = datetime.utcnow()
+ pkgs.update(flag_date=now)
# store our flag request
- flag_request = FlagRequest(user_email=email, message=message,
+ flag_request = FlagRequest(created=now,
+ user_email=email, message=message,
ip_address=ip_addr, pkgbase=pkg.pkgbase,
version=version, repo=pkg.repo,
num_packages=len(flagged_pkgs))
diff --git a/requirements.txt b/requirements.txt
index 1e262f6b..56bd1618 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,4 @@
Django==1.3.1
-Markdown>=2.0.3
+Markdown>=2.1.1
South>=0.7.3
-pyinotify>=0.9.2
pytz>=2011n
diff --git a/requirements_prod.txt b/requirements_prod.txt
index 78eb5125..f8b738e3 100644
--- a/requirements_prod.txt
+++ b/requirements_prod.txt
@@ -1,7 +1,7 @@
Django==1.3.1
-Markdown>=2.0.3
+Markdown>=2.1.1
psycopg2
South>=0.7.3
pyinotify>=0.9.2
-python-memcached>=1.47
+python-memcached>=1.48
pytz>=2011n
diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css
index a3ed2cf1..198eb083 100644
--- a/sitestatic/archweb.css
+++ b/sitestatic/archweb.css
@@ -728,6 +728,11 @@ div#pkglist-about {
padding: 0.25em 0 0.25em 1.5em;
}
+ #pkgdetails #pkginfo .userdata {
+ font-size: 0.85em;
+ padding: 0.5em;
+ }
+
/* pkgdetails: flag package */
form#flag-pkg-form label {
width: 10em;
diff --git a/templates/packages/details.html b/templates/packages/details.html
index 9372a231..fb379df4 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -156,6 +156,11 @@
<th>Last Updated:</th>
<td>{{ pkg.last_update|date }}</td>
</tr>
+ {% if user.is_authenticated %}{% with pkg.flag_request as flag_request %}{% if flag_request %}<tr>
+ <th>Last Flag Request:</th>
+ <td>From {{ flag_request.who }} on {{ flag_request.created|date }}:<br/>
+ <div class="userdata">{{ flag_request.message|linebreaksbr|default:"{no message}" }}</div></td>
+ </tr>{% endif %}{% endwith %}{% endif %}
</table>
<div id="metadata">
diff --git a/templates/todolists/view.html b/templates/todolists/view.html
index 612f2902..fb06ebdd 100644
--- a/templates/todolists/view.html
+++ b/templates/todolists/view.html
@@ -31,9 +31,10 @@
<table id="dev-todo-pkglist" class="results todo-table">
<thead>
<tr>
- <th>Name</th>
<th>Arch</th>
- <th>Repo</th>
+ <th>Repository</th>
+ <th>Name</th>
+ <th>Current Version</th>
<th>Maintainers</th>
<th>Status</th>
</tr>
@@ -41,9 +42,14 @@
<tbody>
{% for pkg in list.packages %}
<tr class="{% cycle 'odd' 'even' %}">
- <td>{% pkg_details_link pkg.pkg %}</td>
<td>{{ pkg.pkg.arch.name }}</td>
<td>{{ pkg.pkg.repo.name|capfirst }}</td>
+ <td>{% pkg_details_link pkg.pkg %}</td>
+ {% if pkg.pkg.flag_date %}
+ <td><span class="flagged">{{ pkg.pkg.full_version }}</span></td>
+ {% else %}
+ <td>{{ pkg.pkg.full_version }}</td>
+ {% endif %}
<td>{{ pkg.pkg.maintainers|join:', ' }}</td>
<td>
{% if perms.main.change_todolistpkg %}
@@ -71,7 +77,7 @@ $(document).ready(function() {
$('a.status-link').click(todolist_flag);
$(".results").tablesorter({
widgets: ['zebra'],
- sortList: [[0,0], [1,0]],
+ sortList: [[2,0], [0,0]],
headers: { 4: { sorter: 'todostatus' } }
});
});