def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'nombre') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter(**{column_contains: self.q}).order_by(self.o)
def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'ciclo') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter(**{column_contains: self.q}).order_by(self.o)
def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'name') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter( enterprise_id=UserToken.get_enterprise_id(self.request.session) ).filter(**{column_contains: self.q}).order_by(self.o).distinct()
def index(request): """ """ o = empty(request, 'o', 'enterprise__name') f = empty(request, 'f', 'enterprise__name') q = empty(request, 'q', '') column_contains = u'%s__%s' % (f, 'contains') headquar_list_by_user = [] headquar_list = [] if request.user.is_superuser: headquar_list = Headquar.objects.filter(**{ column_contains: q }).order_by("-association__name", "-enterprise__name", "-id").distinct() # Trae todo else: if request.user.id: # print "--%s" % request.user.id headquar_list = Headquar.objects.filter(**{ column_contains: q }).filter(userheadquar__user__id=request.user.id).order_by( "-association__name", "-enterprise__name", "-id").distinct() # request.user.id for headquar in headquar_list: group_list = Group.objects.filter( userheadquar__headquar__id=headquar.id, userheadquar__user__id=request.user.id).distinct() module_list = Module.objects.filter(groups__in=group_list).distinct() if request.user.is_superuser: """ permitir ingresar al módulo:Django Backend """ if len(module_list) == 0: module_list = Module.objects.filter(module=BACKEND).distinct() print("entro al modo_backend") else: if Module.objects.get(module=BACKEND) not in module_list: module_list = Module.objects.filter( Q(groups__in=group_list) | Q(module=BACKEND)).distinct() headquar_list_by_user.append({ "association": headquar.association, "enterprise": headquar.enterprise, "headquar": headquar, "modules": module_list, "groups": group_list, }) c = { 'opts': _('Home'), 'cmi': 'accounts:index', 'title': _('Select %s to change') % _('Module'), "object_list": headquar_list_by_user, 'o': o, 'f': f, 'q': q.replace('/', '-'), } return render(request, 'accounts/index.html', c)
def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'name') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter( enterprise_id=UserToken.get_enterprise_id( self.request.session)).filter(**{ column_contains: self.q }).order_by(self.o).distinct()
def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'name') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter( headquar__association_id=UserToken.get_association_id( self.request.session) ).annotate(num_sedes=Count("headquar")).filter( **{column_contains: self.q}).order_by(self.o).distinct()
def get_queryset(self): self.o = empty(self.request, 'o', '-id') self.f = empty(self.request, 'f', 'name') self.q = empty(self.request, 'q', '') column_contains = u'%s__%s' % (self.f, 'contains') return self.model.objects.filter( headquar__association_id=UserToken.get_association_id( self.request.session)).annotate( num_sedes=Count("headquar")).filter(**{ column_contains: self.q }).order_by(self.o).distinct()
def index(request): """ """ o = empty(request, 'o', 'enterprise__name') f = empty(request, 'f', 'enterprise__name') q = empty(request, 'q', '') column_contains = u'%s__%s' % (f, 'contains') headquar_list_by_user = [] headquar_list = [] if request.user.is_superuser: headquar_list = Headquar.objects.filter(**{column_contains: q}).order_by( "-association__name", "-enterprise__name", "-id").distinct() # Trae todo else: if request.user.id: # print "--%s" % request.user.id headquar_list = Headquar.objects.filter(**{column_contains: q}).filter(userheadquar__user__id=request.user.id).order_by( "-association__name", "-enterprise__name", "-id").distinct() # request.user.id for headquar in headquar_list: group_list = Group.objects.filter( userheadquar__headquar__id=headquar.id, userheadquar__user__id=request.user.id).distinct() module_list = Module.objects.filter(groups__in=group_list).distinct() if request.user.is_superuser: """ permitir ingresar al módulo:Django Backend """ if len(module_list) == 0: module_list = Module.objects.filter( module=BACKEND).distinct() else: if Module.objects.get(module=BACKEND) not in module_list: module_list = Module.objects.filter( Q(groups__in=group_list) | Q(module=BACKEND)).distinct() headquar_list_by_user.append({ "association": headquar.association, "enterprise": headquar.enterprise, "headquar": headquar, "modules": module_list, "groups": group_list, }) c = { 'opts': _('Home'), 'cmi': 'accounts:index', 'title': _('Select %s to change') % _('Module'), "object_list": headquar_list_by_user, 'o': o, 'f': f, 'q': q.replace('/', '-'), } return render(request, 'accounts/index.html', c)