Skip to content

Commit

Permalink
Merge branch 'staging' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil28297 committed Apr 1, 2021
2 parents 8399ae7 + 6b2f9c9 commit da1a743
Show file tree
Hide file tree
Showing 20 changed files with 374 additions and 357 deletions.
2 changes: 1 addition & 1 deletion bloomstack_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

__version__ = '2.0.13'
__version__ = '2.1.0'
41 changes: 30 additions & 11 deletions bloomstack_core/bloomtrace/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Bloomstack Inc. and contributors
# For license information, please see license.txt

import frappe
from frappe.frappeclient import FrappeClient, AuthError

Expand All @@ -20,14 +24,29 @@ def get_bloomtrace_client():
return client


def make_integration_request(doctype, docname):
if frappe.conf.enable_bloomtrace:
integration_request = frappe.new_doc("Integration Request")
integration_request.update({
"integration_type": "Remote",
"integration_request_service": "BloomTrace",
"status": "Queued",
"reference_doctype": doctype,
"reference_docname": docname
})
integration_request.save(ignore_permissions=True)
def make_integration_request(doctype, docname, endpoint):
settings = frappe.get_cached_doc("Compliance Settings")
if not (frappe.conf.enable_bloomtrace and settings.is_compliance_enabled) or \
frappe.db.exists("Integration Request", {"reference_doctype": doctype, "reference_docname": docname, "endpoint": endpoint}):
return

doc = frappe.get_doc(doctype, docname)
company = settings.get("company", {"company": doc.company}) and settings.get("company", {"company": doc.company})[0]
fieldname = "push_{0}".format(frappe.scrub(endpoint))

if not company or not company.get(fieldname):
return

integration_request = frappe.get_doc({
"doctype": "Integration Request",
"integration_type": "Remote",
"integration_request_service": "BloomTrace",
"status": "Queued",
"reference_doctype": doctype,
"reference_docname": docname,
"endpoint": endpoint
}).save(ignore_permissions=True)


def create_integration_request(doc, method):
make_integration_request(doc.doctype, doc.name)
91 changes: 0 additions & 91 deletions bloomstack_core/compliance/item.py

This file was deleted.

174 changes: 0 additions & 174 deletions bloomstack_core/compliance/package.py

This file was deleted.

42 changes: 32 additions & 10 deletions bloomstack_core/hook_events/compliance_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import frappe
from bloomstack_core.bloomtrace import get_bloomtrace_client
from frappe.utils import get_host_name

Expand All @@ -11,16 +12,37 @@ def sync_bloomtrace(compliance_settings, method):
return

site_url = get_host_name()
frappe_client.update({
"doctype": "Bloomstack Site",
"name": site_url
})

for company in compliance_settings.company:
try:
frappe_client.update({
"doctype": "Bloomstack Company",
"name": company.company,
"metrc_push_data": company.push_data,
"metrc_pull_data": company.pull_data,
"pull_incoming_transfer": company.pull_incoming_transfer
"doctype": "Bloomstack Site",
"name": site_url,
"metrc_user_key": compliance_settings.get_password("metrc_user_key")
})
except Exception as e:
frappe.log_error(e)

for company in compliance_settings.company:
try:
frappe_client.update({
"doctype": "Bloomstack Company",
"name": company.company,
"push_item": company.push_item,
"pull_item": company.pull_item,
"push_package_tag": company.push_package_tag,
"pull_package_tag": company.pull_package_tag,
"pull_transfer": company.pull_transfer,
"push_transfer": company.push_transfer,
"pull_plant": company.pull_plant,
"push_plant": company.push_plant,
"pull_plant_batch": company.pull_plant_batch,
"push_plant_batch": company.push_plant_batch,
"pull_strain": company.pull_strain,
"push_strain": company.push_strain,
"pull_harvest": company.pull_harvest,
"push_harvest": company.push_harvest,
"pull_package": company.pull_package,
"push_package": company.push_package
})
except Exception as e:
frappe.log_error(e)
Loading

0 comments on commit da1a743

Please sign in to comment.