Пример #1
0
def task(request):
    job_id = request.matchdict['job']
    x = request.matchdict['x']
    y = request.matchdict['y']
    session = DBSession()
    tile = session.query(Tile).get((x, y, job_id))
    checkTask(tile)
    if tile is None:
        return HTTPNotFound()
    polygon=tile.to_polygon()
    username = authenticated_userid(request)
    user = session.query(User).get(username)
    time_left = 'null'
    if tile.user != user:
        request.session.flash('You cannot see this task.')
        return HTTPFound(location=request.route_url('job', job=job_id))
    if tile.checkout:
        time_left = (tile.checkout - (datetime.now() - EXPIRATION_DURATION)) \
            .seconds
    return dict(tile=tile,
            time_left=time_left,
            feature=dumps(polygon),
            user=user,
            job=tile.job,
            job_url=request.route_url('job', job=job_id),
            done_url=request.route_url('task_done', job=job_id, x=x, y=y))
Пример #2
0
def job(request):
    id = request.matchdict['job']
    session = DBSession()
    job = session.query(Job).get(id)
    if job is None:
        request.session.flash("Sorry, this job doesn't  exist")
        return HTTPFound(location = route_url('home', request))

    for tile in job.tiles:
        checkTask(tile)

    username = authenticated_userid(request)
    user = session.query(User).get(username)
    try:
        filter = and_(Tile.username==username, Tile.checkout==True, Tile.job_id==job.id)
        current_task = session.query(Tile).filter(filter).one()
    except NoResultFound, e:
        current_task = None
Пример #3
0
def job(request):
    id = request.matchdict['job']
    session = DBSession()
    job = session.query(Job).get(id)
    if job is None:
        request.session.flash("Sorry, this job doesn't  exist")
        return HTTPFound(location=route_url('home', request))

    for tile in job.tiles:
        checkTask(tile)

    username = authenticated_userid(request)
    user = session.query(User).get(username)
    try:
        filter = and_(Tile.username == username, Tile.checkout == True,
                      Tile.job_id == job.id)
        current_task = session.query(Tile).filter(filter).one()
    except NoResultFound, e:
        current_task = None
Пример #4
0
def job(request):
    id = request.matchdict["job"]
    session = DBSession()
    job = session.query(Job).get(id)
    tiles = []
    for tile in job.tiles:
        checkTask(tile)

    for tile in job.tiles:
        checkout = None
        if tile.checkout is not None:
            checkout = tile.checkout.isoformat()
        tiles.append(Feature(geometry=tile.to_polygon(), properties={"checkin": tile.checkin, "checkout": checkout}))
    try:
        username = authenticated_userid(request)
        filter = and_(Tile.username == username, Tile.job_id == job.id)
        current_task = session.query(Tile).filter(filter).one()
    except NoResultFound, e:
        current_task = None
Пример #5
0
def job(request):
    id = request.matchdict['job']
    session = DBSession()
    job = session.query(Job).get(id)
    if job is None:
        request.session.flash("Sorry, this job doesn't  exist")
        return HTTPFound(location = route_url('home', request))

    for tile in job.tiles:
        checkTask(tile)

    username = authenticated_userid(request)
    user = session.query(User).get(username)

    current_task = get_locked_task(id, username)

    admin = user.is_admin() if user else False
    return dict(job=job, user=user,
            bbox=loads(job.geometry).bounds,
            tile=current_task,
            admin=admin,
           )