Commit 611e3017 authored by Dan McGee's avatar Dan McGee
Browse files

Rename 'packagedepend_set' attribute to 'depends'



We do this for every other related package attribute, so do it here too.

Signed-off-by: default avatarDan McGee <dan@archlinux.org>
parent 493092f8
......@@ -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)
......
......@@ -288,7 +288,7 @@ def get_depends(self):
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 Meta:
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)
......
......@@ -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 @@ def default(self, obj):
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 ''
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment