Esempio n. 1
0
def create_push(name=None):
    push = model.Push(name=name)

    push.put()
    query.bust_push_caches()

    return push
Esempio n. 2
0
def unlive(push):
    push.state = 'onstage'
    push.put()
    for request in push.requests:
        request.state = 'tested'
        request.put()
    push.bust_requests_cache()
    query.bust_push_caches()
Esempio n. 3
0
def force_live(push):
    for request in query.push_requests(push):
        request.state = 'live'

        request.put()
    push.bust_requests_cache()

    push.state = 'live'
    push.ltime = push.mtime

    push.put()
    query.bust_push_caches()

    return push
Esempio n. 4
0
def take_ownership(object):
    object.owner = users.get_current_user()

    object.put()

    if isinstance(object, model.Request):
        query.bust_request_caches()
        push = object.push
        if push is not None:
            object.push.bust_requests_cache()
    elif isinstance(object, model.Push):
        query.bust_push_caches()

    return object
Esempio n. 5
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_push_caches()
    query.bust_push_caches()
    query.bust_request_caches()
    push.bust_requests_cache()

    return push
Esempio n. 6
0
def send_to_live(push):
    assert push.state == 'onstage'
    requests = query.push_requests(push)
    for request in requests:
        assert request.state in ('tested', 'live')

    for request in requests:
        request.state = 'live'
        request.put()

    push.state = 'live'
    push.ltime = datetime.datetime.utcnow()

    push.put()
    query.bust_push_caches()
    push.bust_requests_cache()

    return push
Esempio n. 7
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
Esempio n. 8
0
 def put(self):
     try:
         return super(Push, self).put()
     finally:
         query.bust_push_caches()