Exemplo n.º 1
0
def update_skill(slug: str, **kwargs):
    with SkillRepository() as repo:
        skill: Skill = repo.filter_one(Skill.slug == slug)
        if skill:
            update_from(skill, **kwargs)
            skill.updated_at = get_current_time(get_request_timezone())
            return '', HTTPStatus.NO_CONTENT
        else:
            raise SkillFoundError(ErrorMessages.NoSkillsFound, ErrorCodes.NoSkillsFound,
                                  http_status_code=HTTPStatus.NOT_FOUND)
Exemplo n.º 2
0
def modify_category(slug: str, **kwargs):
    with CategoryRepository() as repo:
        category: Category = repo.filter_one(Category.slug == slug)
        if category:

            update_time = get_current_time(get_request_timezone())
            update_from(category, **kwargs)
            category.updated_at = update_time

            return '', HTTPStatus.NO_CONTENT
        else:
            raise CategoryListError(ErrorMessages.NoCategoryFound, ErrorCodes.NoService,
                                    http_status_code=HTTPStatus.NOT_FOUND)
Exemplo n.º 3
0
def modify_service(slug: str, **kwargs):
    with ServiceRepository() as repo:
        service: Service = repo.filter_one(Service.slug == slug)
        if service:

            update_time = get_current_time(get_request_timezone())
            update_from(service, **kwargs)
            service.updated_at = update_time

            return '', HTTPStatus.NO_CONTENT
        else:
            raise ServiceListError(ErrorMessages.NoServicesFound,
                                   ErrorCodes.NoService,
                                   http_status_code=HTTPStatus.NOT_FOUND)
Exemplo n.º 4
0
def update_zone(slug: str, city_slug: str, **kwargs):
    with ZoneRepository() as repo:
        with CityRepository() as city_repo:
            zone: Zone = repo.filter_one(Zone.slug == slug)
            if zone:
                update_from(zone, **kwargs)
                zone.city = city_repo.filter_one(City.slug == city_slug)
                zone.city_id = zone.city.city_id
                zone.updated_at = get_current_time(get_request_timezone())
                return '', HTTPStatus.NO_CONTENT
            else:
                raise ZoneFoundError(ErrorMessages.NoZonesFound,
                                     ErrorCodes.NoZonesFound,
                                     http_status_code=HTTPStatus.NOT_FOUND)
Exemplo n.º 5
0
def update_provide(slug: str, city_slug: str, service_slug: str, **kwargs):
    with ProvideRepository() as repo:
        provide: Provide = repo.filter_one(Provide.slug == slug)
        if provide:
            update_from(provide, **kwargs)
            provide.updated_at = get_current_time(get_request_timezone())

            with CityRepository() as cityRepository:
                provide.city = cityRepository.filter_one(
                    City.slug == city_slug)
                provide.city_id = provide.city.city_id
            with ServiceRepository() as serviceRepository:
                provide.service = serviceRepository.filter_one(
                    Service.slug == service_slug)
                provide.service_id = provide.service.service_id

            return '', HTTPStatus.NO_CONTENT
        else:
            raise ProvideFoundError(ErrorMessages.NoProvidesFound,
                                    ErrorCodes.NoProvidesFound,
                                    http_status_code=HTTPStatus.NOT_FOUND)