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

Commit

Permalink
Merge pull request #250 from scomert/issue199
Browse files Browse the repository at this point in the history
Fix issue 199
  • Loading branch information
foxmask committed Oct 12, 2017
2 parents c762cde + e48f81a commit 802384e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions django_th/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class ServicesManagedAdmin(admin.ModelAdmin):

"""
get the list of the available services (the activated one)
"""
Expand Down Expand Up @@ -51,13 +50,30 @@ def get_form(self, request, obj=None, **args):
**defaults)


class UserServiceAdmin(admin.ModelAdmin):
class NameListFilter(admin.SimpleListFilter):
title = 'name'
parameter_name = 'name'

def lookups(self, request, model_admin):
if request.GET.get('user__id__exact'):
user_set = set([s.name.name for s in UserService.objects
.filter(user_id__exact=int(request.GET.get('user__id__exact')))])
else:
user_set = set([s.name.name for s in UserService.objects.all()])
return [(i, i) for i in user_set]

def queryset(self, request, queryset):
if self.value():
return queryset.filter(name=self.value())
return queryset


class UserServiceAdmin(admin.ModelAdmin):
"""
get the list of the User Service
"""
list_display = ('user', 'name', 'token')
list_filter = ['user', 'name']
list_filter = ['user', NameListFilter]


class ProviderServiceListFilter(admin.SimpleListFilter):
Expand Down Expand Up @@ -91,7 +107,6 @@ def queryset(self, request, queryset):


class TriggerServiceAdmin(admin.ModelAdmin):

"""
get the list of the User Service
"""
Expand Down
2 changes: 1 addition & 1 deletion django_th/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# ****************************************
# admin module
# ****************************************
# url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include(admin.site.urls)),
# ****************************************
# auth module
# ****************************************
Expand Down

0 comments on commit 802384e

Please sign in to comment.