# -*- coding: utf-8 -*-
# Copyright (c) 2019, JINGROW
# For license information, please see license.txt


import jingrow


def execute():
	jingrow.reload_pagetype("App Release")
	benches = jingrow.get_all(
		"Bench", fields=["name", "candidate"], filters={"status": ("!=", "Archived")}
	)
	candidates = list(set(bench.candidate for bench in benches))
	for candidate in candidates:
		for app in jingrow.get_pg("Deploy Candidate", candidate).apps:
			jingrow.db.set_value("App Release", app.release, "status", "Approved")
			jingrow.db.set_value("App Release", app.release, "deployable", 1)
