Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #412 from glogiotatidis/827514
Browse files Browse the repository at this point in the history
[fix bug 827514] Allow sorting users based on country, voucher and is_vouched.
  • Loading branch information
Sancus committed Feb 27, 2013
2 parents cf95a5a + 43a4845 commit 6fe47fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion apps/users/admin.py
Expand Up @@ -150,13 +150,20 @@ class UserAdmin(UserAdmin):

def country(self, obj):
return obj.userprofile.country
country.admin_order_field = 'userprofile__country'

def is_vouched(self, obj):
return obj.userprofile.is_vouched
is_vouched.boolean = True
is_vouched.admin_order_field = 'userprofile__is_vouched'

def vouched_by(self, obj):
return obj.userprofile.vouched_by
voucher = obj.userprofile.vouched_by
voucher_url = reverse('admin:auth_user_change', args=[voucher.id])
return '<a href="%s">%s</a> (%d)' % (voucher_url, voucher,
voucher.vouchees.count())
vouched_by.admin_order_field = 'userprofile__vouched_by'
vouched_by.allow_tags = True

def index_profiles(self, request):
"""Fire an Elastic Search Index Profiles task."""
Expand Down
3 changes: 2 additions & 1 deletion apps/users/models.py
Expand Up @@ -48,7 +48,8 @@ class UserProfile(models.Model, SearchMixin):
website = models.URLField(max_length=200, verbose_name=_lazy(u'Website'),
default='', blank=True)
vouched_by = models.ForeignKey('UserProfile', null=True, default=None,
on_delete=models.SET_NULL, blank=True)
on_delete=models.SET_NULL, blank=True,
related_name='vouchees')
groups = models.ManyToManyField(Group, blank=True)
skills = models.ManyToManyField(Skill, blank=True)
languages = models.ManyToManyField(Language, blank=True)
Expand Down

0 comments on commit 6fe47fc

Please sign in to comment.