我需要你的帮助,我有一些模特:
class VerificableAdmin(admin.ModelAdmin):
def get_actions(self, request):
actions = super(VerificableAdmin, self).get_actions(request)
op = Operador.get_by_user(request)
if not op is None:
del actions['delete_selected']
return actions
class CallcenterAdmin(VerificableAdmin):
list_display = ['id']
search_fields = ['ani']
actions = ['baja']
def baja(self, request, queryset):
print "hola"
baja.short_description = 'Baja'
def get_actions(self, request):
actions = super(VerificableAdmin, self).get_actions(request)
if not request.user.is_superuser and request.user.groups.filter(name='Personal').count() and 'delete_selected' in actions:
del actions['delete_selected']
return actions
def queryset(self, request):
qs = super(CallcenterAdmin, self).queryset(request)
if not request.user.is_superuser and request.user.groups.filter(name='Personal').count():
qs = qs.filter(ani=request.GET.get('q'))
if qs.count() and qs[0].accion == 'baja':
self.actions = None
因此,当用户(管理员和组“Personal”中的某些用户)在视图上进行交互时,我无法查看action_checkbox ...
我不知道这是什么问题。
我们的想法是仅为管理员用户或个人群组中的用户提供“baja”操作,并且qs.count> 1。