[damned-lies] Also try to obtain maintainer by uid
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Also try to obtain maintainer by uid
- Date: Sat, 23 Oct 2010 15:28:42 +0000 (UTC)
commit 0f762dba47fecb292a0dc596c7af931ead1d45db
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Oct 23 17:28:38 2010 +0200
Also try to obtain maintainer by uid
people/models.py | 10 ++++++++++
stats/doap.py | 8 ++++----
stats/models.py | 2 +-
3 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/people/models.py b/people/models.py
index 380d679..4f95660 100644
--- a/people/models.py
+++ b/people/models.py
@@ -55,6 +55,16 @@ class Person(User):
for account in accounts:
account.delete()
+ @classmethod
+ def get_by_attr(cls, key, val):
+ if not val:
+ return None
+ try:
+ person = Person.objects.get(**{key: val})
+ except Person.DoesNotExist:
+ return None
+ return person
+
def save(self, *args, **kwargs):
if not self.password or self.password == "!":
self.password = None
diff --git a/stats/doap.py b/stats/doap.py
index d859ceb..e3f7e04 100644
--- a/stats/doap.py
+++ b/stats/doap.py
@@ -51,10 +51,10 @@ def update_doap_infos(module):
del current_maintainers[maint_key]
else:
# Add new maintainer
- query_param = {maint['email'] and 'email' or 'username': maint_key }
- try:
- pers = Person.objects.get(**query_param)
- except Person.DoesNotExist:
+ pers = Person.get_by_attr('email', maint['email'])
+ if not pers:
+ pers = Person.get_by_attr('username', maint['account'] or slugify(maint['name']))
+ if not pers:
pers = Person(username=maint['account'] or slugify(maint['name']), email=maint['email'] or '',
password='!', svn_account=maint['account'], last_name=maint['name'])
pers.save()
diff --git a/stats/models.py b/stats/models.py
index 5fda25d..4000ec9 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -479,7 +479,7 @@ class Branch(models.Model):
for err in langstats['errors']:
stat.information_set.add(Information(type=err[0], description=err[1]))
# Check if doap file changed
- if self.file_changed("%s.doap" % self.module.name):
+ if self.is_head() and self.file_changed("%s.doap" % self.module.name):
update_doap_infos(self.module)
def _exists(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]