Beispiel #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()

    util.send_im(
        to=request.owner.email(),
        message='<a href="mailto:%(rejector_email)s">%(rejector_name)s</a> rejected your request <a href="%(request_uri)s">%(request_subject)s</a>: %(reason)s',
        rejector_email=rejector.email(),
        rejector_name=user_info(rejector).full_name,
        request_subject=request.subject,
        request_uri=config.url(request.uri),
        reason=reason,
        )

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

    return request
Beispiel #2
0
def set_request_checkedin(request):
    assert request.state == 'accepted'
    push = request.push
    assert push

    request.state = 'checkedin'

    request.put()
    push.bust_requests_cache()

    util.send_mail(
        to=[push.owner.email(), config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Changes are checked in.\n' + config.url(push.uri))

    im_fields = dict(

        )
    util.send_im(
        to=request.owner.email(),
        message='Changes for <a href="%(request_uri)s">%(request_subject)s</a> are checked into <a href="%(push_uri)s">%(push_name)s</a>.',
        request_uri=config.url(request.uri),
        request_subject=request.subject,
        push_name=push.name or 'the push',
        push_uri=config.url(push.uri),
        )

    return request
Beispiel #3
0
def set_request_tested(request, bust_caches=True):
    assert request.state == 'onstage'
    push = request.push
    assert push

    request.state = 'tested'
    request.put()

    if bust_caches:
        push.bust_requests_cache()

    push_owner_email = push.owner.email()

    util.send_mail(
        to=[push_owner_email, config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Looks good to me.\n' + config.url(push.uri))

    if all(request.state == 'tested' for request in query.push_requests(push)):
        util.send_im(push_owner_email, 'All changes for <a href="%s">the push</a> are verified on stage.' % config.url(push.uri))

    return request
Beispiel #4
0
def send_to_stage(push, stage):
    assert push.state in ('accepting', 'onstage')
    assert stage in model.Push.all_stages

    checkedin_requests = query.push_requests(push, state='checkedin')
    if checkedin_requests:
        if push.state != 'onstage' or push.stage != stage:
            push.state = 'onstage'
            push.stage = stage

            push.put()
            query.bust_push_caches()

        for request in checkedin_requests:
            request.state = 'onstage'
            owner_email = request.owner.email()

            util.send_mail(
                to=[owner_email, config.mail_to],
                subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
                body=('Please verify your changes on %s.\n%s' % (push.stage, config.url(push.uri)))
                )

            util.send_im(
                to=owner_email,
                message='<a href="mailto:%(pushmaster_email)s">%(pushmaster_name)s</a> requests that you verify your changes on %(stage)s for <a href="%(push_uri)s">%(request_subject)s</a>.',
                pushmaster_email=push.owner.email(),
                pushmaster_name=user_info(push.owner).full_name,
                request_subject=request.subject,
                push_uri=config.url(push.uri),
                stage=push.stage,
                )
            request.put()

        push.bust_requests_cache()

    return push
Beispiel #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()

    util.send_im(
        to=request.owner.email(),
        message='<a href="mailto:%(pushmaster_email)s">%(pushmaster_name)s</a> accepted <a href="%(request_uri)s">%(request_subject)s</a> into <a href="%(push_uri)s">%(push_name)s</a>.',
        pushmaster_email=push.owner.email(),
        pushmaster_name=user_info(push.owner).full_name,
        request_uri=config.url(request.uri),
        request_subject=request.subject,
        push_uri=config.url(push.uri),
        push_name=push.name or 'the push',
        )

    return request