Esempio n. 1
0
def read(name):
    try:
        data = get_doc_as_dict("IOT Application", name, include_tags=True)
        data.installed = frappe.get_value("IOT Application Counter", name,
                                          "installed") or 0
        frappe.response.update({"ok": True, "data": data})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 2
0
def read(name):
    try:
        valid_auth_code()

        frappe.response.update({
            "ok": True,
            "data": get_doc_as_dict('App Category', name)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 3
0
def read(name):
    try:
        valid_auth_code()
        frappe.response.update({
            "ok":
            True,
            "data":
            get_doc_as_dict("IOT Application Conf Version", name)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 4
0
def read(name):
	try:
		frappe.response.update({
			"ok": True,
			"data": get_doc_as_dict("IOT Application Conf", name, keep_owner=True)
		})
	except Exception as ex:
		frappe.response.update({
			"ok": False,
			"error": str(ex)
		})
Esempio n. 5
0
def read(name):
    try:
        valid_auth_code()

        frappe.response.update({
            "ok":
            True,
            "data":
            get_doc_as_dict("Cloud Company Group", name)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 6
0
def list(developer=None, tags=None):
    try:
        apps = []
        if not developer:
            developer = ["!=", "Administrator"]
        filters = {"developer": developer, "published": 1}
        if tags is None:
            for d in frappe.get_all("IOT Application",
                                    "name",
                                    filters=filters,
                                    order_by="modified desc"):
                '''
				for tag in frappe.get_value("IOT Application Tag", ["name", "tag"], {"parent": d[0]}):
					if tag[0] in tags:
						apps.append(as_dict(frappe.get_doc("IOT Application", d.name)))
				'''
                apps.append(
                    get_doc_as_dict("IOT Application",
                                    d.name,
                                    include_tags=True))
        else:
            tag_filters = {"tag", ["in", tags]}
            for d in frappe.get_all("Tag Link",
                                    "document_name",
                                    filters=tag_filters):
                if frappe.get_value("IOT Application", d.document_name,
                                    "published") == 1:
                    apps.append(
                        get_doc_as_dict("IOT Application",
                                        d.name,
                                        include_tags=True))

        for app in apps:
            app.installed = frappe.get_value("IOT Application Counter",
                                             app.name, "installed") or 0

        frappe.response.update({"ok": True, "data": apps})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 7
0
def read(name):
    try:
        valid_auth_code()
        if frappe.get_value("IOT Batch Task", name,
                            "owner_id") != frappe.session.user:
            throw("has_no_permission")

        frappe.response.update({
            "ok": True,
            "data": get_doc_as_dict("IOT Batch Task", name)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 8
0
def list():
    try:
        valid_auth_code()

        ret = []
        for d in frappe.get_all("IOT Batch Task",
                                {"owner_id": frappe.session.user},
                                order_by="modified desc"):
            ret.append(get_doc_as_dict("IOT Batch Task", d.name))

        frappe.response.update({"ok": True, "data": ret})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 9
0
def list():
    try:
        valid_auth_code()

        data = []
        for d in frappe.get_all("Cloud Employee",
                                "company",
                                filters={"user": frappe.session.user}):
            data.append(get_doc_as_dict('Cloud Company', d.company))

        frappe.response.update({"ok": True, "data": data})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 10
0
def read(name):
	try:
		valid_auth_code()

		frappe.response.update({
			"ok": True,
			"data": get_doc_as_dict("App Developer Requisition", name, keep_owner=True, keep_docstatus=True)
		})
	except Exception as ex:
		frappe.response.update({
			"ok": False,
			"error": str(ex)
		})
Esempio n. 11
0
def read(name):
    try:
        if 'Company Admin' not in frappe.get_roles():
            throw("not_company_admin")

        validate_owner(name)

        frappe.response.update({
            "ok":
            True,
            "data":
            get_doc_as_dict("IOT User Application", name)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
def list():
    try:
        valid_auth_code()

        data = []
        for d in frappe.get_all("Cloud Employee Invitation",
                                "name",
                                filters={"user": frappe.session.user}):
            data.append(
                get_doc_as_dict('Cloud Employee Invitation',
                                d.name,
                                keep_docstatus=True))

        frappe.response.update({"ok": True, "data": data})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 13
0
def read(user=None):
    try:
        valid_auth_code()

        user = user or frappe.session.user
        name = frappe.get_value('App Developer', user)

        if not name:
            throw("not_developer")

        frappe.response.update({
            "ok": True,
            "data": get_doc_as_dict('App Developer', user)
        })
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 14
0
def list(name):
    try:
        valid_auth_code()

        if not frappe.has_permission(
                doctype="IOT Device", doc=name, ptype='write'):
            throw("has_no_permission")

        share_list = []
        for d in frappe.db.get_values("IOT Device Share", {"device": name},
                                      "name"):
            share_list.append(
                get_doc_as_dict("IOT Device Share",
                                d[0],
                                keep_creation=True,
                                keep_owner=True))

        frappe.response.update({"ok": True, "data": share_list})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 15
0
def list():
    try:
        valid_auth_code()
        apps = []
        companies = list_admin_companies(frappe.session.user)
        filters = {"company": ["in", companies]}

        for d in frappe.get_all("IOT Application",
                                "name",
                                filters=filters,
                                order_by="modified desc"):
            apps.append(
                get_doc_as_dict("IOT Application", d.name, include_tags=True))

        for app in apps:
            app.installed = frappe.get_value("IOT Application Counter",
                                             app.name, "installed") or 0

        frappe.response.update({"ok": True, "data": apps})
    except Exception as ex:
        frappe.response.update({"ok": False, "error": str(ex)})
Esempio n. 16
0
def list(app, conf_type='Template', developer=None, tags=None):

	try:
		apps = []
		filters = {"app": app, "type": conf_type, "public": 1}
		if developer:
			filters.update({"developer": developer})
		for d in frappe.get_all("IOT Application Conf", "name", filters=filters, order_by="modified desc"):
			'''
			for tag in frappe.get_value("IOT Application Conf Tag", ["name", "tag"], {"parent": d[0]}):
				if tag[0] in tags:
					apps.append(as_dict(frappe.get_doc("IOT Application Conf", d.name)))
			'''
			apps.append(get_doc_as_dict("IOT Application Conf", d.name, keep_owner=True))

		frappe.response.update({
			"ok": True,
			"data": apps
		})
	except Exception as ex:
		frappe.response.update({
			"ok": False,
			"error": str(ex)
		})