diff options
author | Dusty Phillips <buchuki@gmail.com> | 2008-06-21 18:48:48 -0400 |
---|---|---|
committer | Dusty Phillips <buchuki@gmail.com> | 2008-06-21 18:48:48 -0400 |
commit | 4e7dfdd6631c5f00553eda8cc10cd83c959dd76f (patch) | |
tree | 2bbc5a957f335504bb4a2c3107e5e21a9caee5c8 | |
parent | de85d8177b7ae53acac1e11f68dc211e30be3920 (diff) |
make the package model part of the admin
-rw-r--r-- | main/models.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py index bc236296..cab6a9cb 100644 --- a/main/models.py +++ b/main/models.py @@ -194,12 +194,34 @@ class Package(models.Model): objects = PackageManager() class Meta: db_table = 'packages' - get_latest_by = 'last_update' - ordering = ('-last_update',) + #get_latest_by = 'last_update' + #ordering = ('-last_update',) + + class Admin: + list_display = ('pkgname', '_reponame', '_archname', '_maintainername', + 'last_update') + list_filter = ('repo', 'arch', 'maintainer') + ordering = ['pkgname'] + search_fields = ('pkgname', 'maintainer__username') + pass def __str__(self): return self.pkgname + # According to http://code.djangoproject.com/ticket/2583 we have "bad data" + # The problem is the queries constructed by the admin to retrieve foreign + # keys are empty. This allows us to display items in the list but kills + # sorting + def _reponame(self): + return self.repo.name + _reponame.short_description='Repo' + def _archname(self): + return self.arch.name + _archname.short_description='Arch' + def _maintainername(self): + return self.maintainer.username + _maintainername.short_description = 'Maintainer' + def get_absolute_url(self): return '/packages/%i/' % self.id |