def region_permission(region_id): if current_user.is_super_admin(): return True if region_id in current_user.region_ids: return True elif current_user.city_ids: city_id = region_brand.get(region_id)['city_id'] if city_permission(city_id): return True return False
def get(pk): pk = int(pk) if not region_permission(pk): raise_auth_exc(AUTH_FAILED_ERROR) rb = region_brand.get(pk) if not rb: return {} return { 'id': rb.id, 'name': rb.name, 'type_code': rb.type_code, 'city_id': rb.city_id, 'area': rb.area, 'created_at': rb.created_at }