Ejemplo n.º 1
0
def reject_request(request, rejector, reason=None):
    push = request.push

    request.push = None
    request.state = 'rejected'
    if reason:
        request.reject_reason = reason

    request.put()
    query.bust_request_caches()
    if push is not None:
        push.bust_requests_cache()

    im_fields = dict(
        rejector_email=html_escape(rejector.email()),
        rejector_name=html_escape(rejector.nickname()),
        request_subject=html_escape(request.subject),
        uri=html_escape(config.url(request.uri)),
        reason=html_escape(reason),
        )
    send_im(request.owner.email(), '<a href="mailto:%(rejector_email)s">%(rejector_name)s</a> rejected your request <a href="%(uri)s">%(request_subject)s</a>: %(reason)s' % im_fields)

    send_mail(
        to=[request.owner.email(), config.mail_to],
        subject='Re: ' + request.subject,
        body="""This request was rejected.\n\n%s\n\n%s""" % (reason, config.url(request.uri)),
        )

    return request
Ejemplo n.º 2
0
def set_request_properties(request, subject, message=None, push_plans=False, no_testing=False, urgent=False, js_serials=False, target_date=None, branch=None, img_serials=False, tests_pass=False):
    assert len(subject) > 0
    target_date = target_date or datetime.date.today()

    request.state = request.default_state
    request.reject_reason = None
    request.push = None
    request.subject = subject
    request.branch = branch
    request.push_plans = push_plans
    request.no_testing = no_testing
    request.js_serials = js_serials
    request.img_serials = img_serials
    request.tests_pass = tests_pass
    request.urgent = urgent
    request.target_date = target_date
    if message:
        assert len(message) > 0
        request.message = message

    request.put()
    query.bust_request_caches()

    send_request_mail(request)

    return request
Ejemplo n.º 3
0
def take_ownership(object):
    object.owner = users.get_current_user()

    object.put()

    if isinstance(object, Request):
        query.bust_request_caches()
        object.push.bust_requests_cache()
    elif isinstance(object, Push):
        query.bust_push_caches()
    
    return object
Ejemplo n.º 4
0
def abandon_request(request):
    assert request.state in ('requested', 'accepted', 'rejected')
    request.state = 'abandoned'
    push = request.push
    request.push = None
    
    request.put()
    query.bust_request_caches()
    if push is not None:
        push.bust_requests_cache()

    return request
Ejemplo n.º 5
0
def accept_request(push, request):
    assert push.state in ('accepting', 'onstage')
    assert request.state == 'requested'
    assert not request.push

    request.push = push
    request.state = 'accepted'

    request.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    return request
Ejemplo n.º 6
0
def abandon_push(push):
    assert push.state in ('accepting', 'onstage')

    push.state = 'abandoned'
    for request in query.push_requests(push):
        request.state = 'requested'
        request.push = None
        request.put()

    push.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    return push
Ejemplo n.º 7
0
def withdraw_request(request):
    assert request.state in ('accepted', 'checkedin', 'onstage', 'tested')
    push = request.push
    assert push
    assert request.push.state in ('accepting', 'onstage')

    push_owner_email = request.push.owner.email()
    request.push = None
    request.state = 'requested'

    request.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    send_mail(
        to=[push_owner_email, config.mail_to],
        subject='Re: ' + request.subject,
        body='I withdrew my request.\n' + config.url(request.uri))

    return request