def non_administrative_locations_for_select2(request, domain): id = request.GET.get('id') query = request.GET.get('name', '').lower() if id: try: loc = SQLLocation.objects.get(location_id=id) if loc.domain != domain: raise SQLLocation.DoesNotExist() except SQLLocation.DoesNotExist: return json_response( {'message': 'no location with id %s found' % id}, status_code=404, ) else: return json_response(loc_to_payload(loc)) locs = [] user = request.couch_user user_loc = user.get_sql_location(domain) if user_can_edit_any_location(user, request.project): locs = SQLLocation.objects.filter(domain=domain, location_type__administrative=False) elif user_loc: locs = user_loc.get_descendants(include_self=True, location_type__administrative=False) if locs != [] and query: locs = locs.filter(name__icontains=query) return json_response(list(map(loc_to_payload, locs[:10])))
def non_administrative_locations_for_select2(request, domain): id = request.GET.get('id') query = request.GET.get('name', '').lower() if id: try: loc = SQLLocation.objects.get(location_id=id) if loc.domain != domain: raise SQLLocation.DoesNotExist() except SQLLocation.DoesNotExist: return json_response( {'message': 'no location with id %s found' % id}, status_code=404, ) else: return json_response(loc_to_payload(loc)) locs = [] user = request.couch_user user_loc = user.get_sql_location(domain) if user_can_edit_any_location(user, request.project): locs = SQLLocation.objects.filter(domain=domain, location_type__administrative=False) elif user_loc: locs = user_loc.get_descendants(include_self=True, location_type__administrative=False) if locs != [] and query: locs = locs.filter(name__icontains=query) return json_response(map(loc_to_payload, locs[:10]))
def can_bulk_edit_users(self): if not user_can_edit_any_location(self.request.couch_user, self.request.project): return False try: ensure_request_has_privilege(self.request, privileges.BULK_USER_MANAGEMENT) except PermissionDenied: return False return True
def can_bulk_edit_users(self): if not user_can_edit_any_location(self.request.couch_user, self.request.project): return False return has_privilege(self.request, privileges.BULK_USER_MANAGEMENT)
def can_bulk_edit_users(self): if not user_can_edit_any_location(self.request.couch_user, self.request.project): return False return has_privilege(self.request, privileges.BULK_USER_MANAGEMENT)