Ejemplo n.º 1
0
def update_url(request, url_id, *args, **kwargs):
    """update url"""
    body = json.loads(request.body)
    user = request.user
    project_id = body.get("project")
    project = Projects.get_by_id(project_id)
    if not project:
        return dict(error="No such project "+ str(project_id))
    kwds = UrlService._parse_keywords(**body)
    url = UrlService.update_url(user.key, project.key, url_id, **kwds)
    return url.to_dict()
Ejemplo n.º 2
0
def create_url(request, *args, **kwargs):
    """create a new url"""
    body = json.loads(request.body)
    user = request.user
    log.info(user)
    project_id = body.get("project")
    log.info(project_id)
    project = Projects.get_by_id(id=project_id)
    log.info(project)
    if not project:
        return dict(error="No such project "+ str(project_id))
    url = UrlService.create_url(user.key, project.key, **body)
    return url.to_dict()
Ejemplo n.º 3
0
def delete_url(request, url_id, *args, **kwargs):
    """delete url"""
    user = request.user
    result = UrlService.delete_url(user, url_id)
    return dict(success=True if result else False)
Ejemplo n.º 4
0
def get_urls(request, *args, **kwargs):
    """get all the urls for the project"""
    user = request.user
    urls = UrlService.get_url(user)
    return dict(urls=urls)