summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-26 12:33:28 -0500
committerDan McGee <dan@archlinux.org>2012-03-26 12:33:28 -0500
commit611e30172ae8db58fc2f6146fd1bee428e55ea6a (patch)
tree0e4630d36639d6f6f25e861803d35f48301de672
parent493092f88f03ae7ec385f76abeeb51516ff888e3 (diff)
Rename 'packagedepend_set' attribute to 'depends'
We do this for every other related package attribute, so do it here too. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--devel/management/commands/reporead.py2
-rw-r--r--main/models.py4
-rw-r--r--packages/views/__init__.py8
3 files changed, 5 insertions, 9 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index c5a2ece5..fd8e3979 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -229,7 +229,7 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
populate_files(dbpkg, repopkg, force=force)
- dbpkg.packagedepend_set.all().delete()
+ dbpkg.depends.all().delete()
deps = [create_depend(dbpkg, y) for y in repopkg.depends]
deps += [create_depend(dbpkg, y, True) for y in repopkg.optdepends]
PackageDepend.objects.bulk_create(deps)
diff --git a/main/models.py b/main/models.py
index 289cbb84..34cbcd17 100644
--- a/main/models.py
+++ b/main/models.py
@@ -288,7 +288,7 @@ class Package(models.Model):
if not self.arch.agnostic:
arches = self.applicable_arches()
# TODO: we can use list comprehension and an 'in' query to make this more effective
- for dep in self.packagedepend_set.order_by('optional', 'depname'):
+ for dep in self.depends.order_by('optional', 'depname'):
pkg = dep.get_best_satisfier(arches, testing=self.repo.testing,
staging=self.repo.staging)
providers = None
@@ -391,7 +391,7 @@ class PackageFile(models.Model):
db_table = 'package_files'
class PackageDepend(models.Model):
- pkg = models.ForeignKey(Package)
+ pkg = models.ForeignKey(Package, related_name='depends')
depname = models.CharField(max_length=255, db_index=True)
depvcmp = models.CharField(max_length=255, default='')
optional = models.BooleanField(default=False)
diff --git a/packages/views/__init__.py b/packages/views/__init__.py
index a915d58c..afb1de31 100644
--- a/packages/views/__init__.py
+++ b/packages/views/__init__.py
@@ -31,7 +31,7 @@ class PackageJSONEncoder(DjangoJSONEncoder):
'installed_size', 'build_date', 'last_update', 'flag_date',
'maintainers', 'packager' ]
pkg_list_attributes = [ 'groups', 'licenses', 'conflicts',
- 'provides', 'replaces', 'packagedepend_set' ]
+ 'provides', 'replaces', 'depends' ]
def default(self, obj):
if hasattr(obj, '__iter__'):
@@ -41,11 +41,7 @@ class PackageJSONEncoder(DjangoJSONEncoder):
data = dict((attr, getattr(obj, attr))
for attr in self.pkg_attributes)
for attr in self.pkg_list_attributes:
- values = getattr(obj, attr).all()
- # TODO: temporary rename becuase the name sucks
- if attr == 'packagedepend_set':
- attr = 'depends'
- data[attr] = values
+ data[attr] = getattr(obj, attr).all()
return data
if isinstance(obj, PackageFile):
filename = obj.filename or ''