Esempio n. 1
0
def _update_tree_status(session, tree, status=None, reason=None, tags=[],
                        message_of_the_day=None):
    '''Update the given tree's status; note that this does not commit
       the session.  Supply a tree object or name.
    '''
    if status is not None:
        tree.status = status
    if reason is not None:
        tree.reason = reason
    if message_of_the_day is not None:
        tree.message_of_the_day = message_of_the_day

    # log it if the reason or status have changed
    if status or reason:
        if status is None:
            status = 'no change'
        if reason is None:
            reason = 'no change'
        log = Log(tree=tree.tree,
                  when=_now(),
                  who=str(current_user),
                  status=status,
                  reason=reason,
                  tags=tags)
        session.add(log)

    cache.delete_memoized(v0_get_tree, tree.tree)
Esempio n. 2
0
def _kill_tree(tree):
    session = current_app.db.session
    t = session.query(Tree).get(tree)
    if not t:
        raise NotFound('No such tree')
    session.delete(t)
    # delete from logs and change stack, too
    Log.query.filter_by(tree=tree).delete()
    StatusChangeTree.query.filter_by(tree=tree).delete()
    session.commit()
    cache.delete_memoized(v0_get_tree, tree)