我需要你们的帮助,我有一些模型:
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
因此,当用户(管理员和“个人”组中的某个用户)在视图上进行交互时,我无法查看 action_checkbox ...
我不知道有什么问题。
我们的想法是只为管理员用户或个人组中的用户和 qs.count > 1 提供操作“baja”。