# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and contributors
# License: MIT. See LICENSE

import frappe
from frappe.model.document import Document

class InstalledApplications(Document):
	def update_versions(self):
		self.delete_key("installed_applications")
		for app in frappe.utils.get_installed_apps_info():
			self.append("installed_applications", {
				"app_name": app.get("app_name"),
				"app_version": app.get("version") or "UNVERSIONED",
				"git_branch": app.get("branch") or "UNVERSIONED"
			})
		self.save()