Example #1
0
def get_posix_groups(request, pk):

    hu = get_object_or_404(Humen, pk=pk)
    hu_groups = hu.get_posix_groups()
    rv = OrderedDict()

    for pgroup in ALL_POSIX_GROUPS.exclude(name="bureau.user"):
        if request.user.is_superuser or pgroup.name.startswith('bureau'):
            rv[unicode(pgroup)] = pgroup.name in hu_groups
    return HttpJSONResponse(rv)
Example #2
0
    def __getattr__(self, attr_name, default=None):
        if attr_name.startswith('action_posix_group_'):
            # recall __getattr__ to get the real method
            # WARNING: do not call this method action_posix_group_xxxxx pay with an infinite recursion otherwise
            fun = self._do_action_posix_group
            kind, group_name = attr_name[len('action_posix_group_'):].split('_',1)
            group_name = group_name.replace('__','.')
            if kind == "add":
                verb_kind = "Aggiungi"
            elif kind == "remove":
                verb_kind = "Rimuovi"

            new_fun = lambda self, request, queryset: fun(request, queryset, kind, group_name)
            new_fun.short_description = "*** autorizzazione: %s %s" % (verb_kind, ALL_POSIX_GROUPS.get(name=group_name))
            new_fun.short_description = new_fun.short_description.upper()
            return new_fun

        else:
            return super(BaseHumenAdmin, self).__getattr__(attr_name, default)