diff --git a/smart_service/apis/app_user_login.py b/smart_service/apis/app_user_login.py
index 6031b0d..bc52261 100644
--- a/smart_service/apis/app_user_login.py
+++ b/smart_service/apis/app_user_login.py
@@ -859,13 +859,14 @@ def generate_refresh_token():
def refresh_token():
""" For Refresh API """
- rate_res = custom_rate_limit(limit=5, seconds=15)
- if rate_res != 1:
- return rate_res
+ # rate_res = custom_rate_limit(limit=5, seconds=15)
+ # if rate_res != 1:
+ # return rate_res
frappe.set_user("Administrator")
req = frappe.request.data
req = json.loads(req)
+
refresh_token= req['refresh_token']
if refresh_token:
device_id= req['DeviceID']
diff --git a/smart_service/apis/master_api.py b/smart_service/apis/master_api.py
index 075b921..34bea72 100644
--- a/smart_service/apis/master_api.py
+++ b/smart_service/apis/master_api.py
@@ -3,13 +3,10 @@
import frappe
-from frappe.model.document import Document
-import json
from frappe.utils import cstr
import datetime
from smart_service.apis.app_user_login import input_validation
import os
-import re
current_db_name = frappe.conf.get("db_name")
site_name = cstr(frappe.local.site)
@@ -40,7 +37,7 @@ def custom_rate_limit(limit, seconds):
@frappe.whitelist()
-def masters(args=None, LSD=None):
+def masters(args=None, LSD=None,iid=None):
rate = custom_rate_limit(limit=20, seconds=5)
if rate != 1:
return rate
@@ -49,13 +46,6 @@ def masters(args=None, LSD=None):
if val != '':
return {"status": 0, "error": "Parameter's missing:"+val}
- # if args == None and LSD == None:
- # return {"status": 0, "error": "Parameter's missing: args & LSD"}
- # if args == None:
- # return {"status": 0, "error": "Parameter missing: args"}
- # if LSD == None:
- # return {"status": 0, "error": "Parameter missing: LSD"}
-
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
@@ -66,21 +56,23 @@ def masters(args=None, LSD=None):
try:
if args == "vehicle":
- api = frappe.db.get_list(
- "Vehicle",
- fields=[
- "name as vehicle",
- "vehicle_segment",
- "vehicle_segment_id",
- "image",
- "active_status",
- "display_order",
- "myid as vechile_id",
- "display_order",
- "modified",
- ],
- filters={"modified": [">", LSD]},
- )
+ val = input_validation(iid=iid)
+ if val != '':
+ return {"status": 0, "error": "Parameter's missing:"+val}
+ publish_type = check_pub_type(iid)
+ api = []
+ if publish_type == 'Global':
+ api = frappe.db.sql(f'''
+ select name as vehicle,vehicle_segment,vehicle_segment_id,image,active_status,display_order,
+ myid as vechile_id,display_order,modified from _a9b9faaf89312ce4.tabVehicle
+ where modified > '{LSD}' and global_publish = 1;
+ ''',as_dict=1)
+ else:
+ api = frappe.db.sql(f'''
+ select name as vehicle,vehicle_segment,vehicle_segment_id,image,active_status,display_order,
+ myid as vechile_id,display_order,modified from _a9b9faaf89312ce4.tabVehicle
+ where modified > '{LSD}' and internal_publish = 1;
+ ''',as_dict=1)
for i in api:
if i["active_status"] == "Active":
i["active_status"] = True
@@ -287,3 +279,14 @@ def masters(args=None, LSD=None):
api = {"status": 0, "error": e}
return api
+
+
+def check_pub_type(iid):
+ if not iid:
+ return False
+ device_pub_type = frappe.db.sql(f'''
+ select publish_type from `tabApp Device` where name = '{iid}' and active_status = 'Active';''')
+
+ if not device_pub_type:
+ return False
+ return device_pub_type[0][0]
\ No newline at end of file
diff --git a/smart_service/apis/publish_api.py b/smart_service/apis/publish_api.py
index e480e56..be1cd8f 100644
--- a/smart_service/apis/publish_api.py
+++ b/smart_service/apis/publish_api.py
@@ -482,11 +482,14 @@ def new_publish(args, publish_type, vehicle, language, version):
file_flag, final_update_file = merge_json_files(
prev_full_update_file, file_name, full_update_file_name)
get_step_total_count(final_update_file)
+ set_publish_flag(publish_type,vehicle)
if file_flag:
return True, file_name.split("public")[1]
# return True, file_name
else:
return False, "File save issue"
+
+ set_publish_flag(publish_type,vehicle)
return True, file_name.split("public")[1]
# return True, file_name
@@ -496,6 +499,30 @@ def new_publish(args, publish_type, vehicle, language, version):
return False, str(frappe.get_traceback())
+def set_publish_flag(publish_type,vehicle):
+ try:
+ if publish_type == 'Internal':
+ data = frappe.db.sql(f'''
+ SELECT * FROM tabVehicle where vehicle = '{vehicle}' and internal_publish=1;
+ ''')
+ if not data:
+ frappe.db.sql(f'''
+ update tabVehicle set internal_publish = 1 where vehicle = '{vehicle}';
+ ''')
+ frappe.db.commit()
+ else:
+ data = frappe.db.sql(f'''
+ SELECT * FROM tabVehicle where vehicle = '{vehicle}' and global_publish = 1;
+ ''')
+ if not data:
+ frappe.db.sql(f'''
+ update tabVehicle set global_publish=1 where vehicle = '{vehicle}';
+ ''')
+ frappe.db.commit()
+
+ except Exception as e:
+ frappe.log_error(str(e))
+
@frappe.whitelist()
def old_merge_json_files(old_json_path, new_json_path, out_file_path):
try:
@@ -769,7 +796,7 @@ def merge_json_files(old_json_path, new_json_path, out_file_path):
outfile.write(json_object)
return True, out_file_path
except:
- return False,frappe.log_error("Merge JSON:",frappe.get_traceback())
+ return False, frappe.log_error("Merge JSON:",frappe.get_traceback())
def check_key(key_name, old_data, type=None):
diff --git a/smart_service/masters/doctype/vehicle/vehicle.json b/smart_service/masters/doctype/vehicle/vehicle.json
index 03f0065..ee91744 100644
--- a/smart_service/masters/doctype/vehicle/vehicle.json
+++ b/smart_service/masters/doctype/vehicle/vehicle.json
@@ -19,8 +19,8 @@
"myid",
"display_order",
"service_kilometers",
- "global_publish_flag",
- "internal_publish_flag"
+ "internal_publish",
+ "global_publish"
],
"fields": [
{
@@ -103,24 +103,19 @@
},
{
"default": "0",
- "fieldname": "global_publish_flag",
+ "fieldname": "internal_publish",
"fieldtype": "Check",
- "hidden": 1,
- "label": "Global Publish Flag",
- "read_only": 1
+ "label": "Internal Publish"
},
{
- "default": "0",
- "fieldname": "internal_publish_flag",
- "fieldtype": "Check",
- "hidden": 1,
- "label": "Internal Publish Flag",
- "read_only": 1
+ "fieldname": "global_publish",
+ "fieldtype": "Data",
+ "label": "Global Publish"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2022-04-01 17:41:13.606316",
+ "modified": "2023-07-11 10:29:42.916784",
"modified_by": "Administrator",
"module": "Masters",
"name": "Vehicle",
diff --git a/smart_service/transactions/doctype/publish/publish.js b/smart_service/transactions/doctype/publish/publish.js
index f43d1c6..e0753ba 100644
--- a/smart_service/transactions/doctype/publish/publish.js
+++ b/smart_service/transactions/doctype/publish/publish.js
@@ -124,28 +124,28 @@ frappe.ui.form.on('Publish', {
},
callback: function (r) {
// if (r.message[0]) {
- frm.set_value('publish_status', 'Published');
- frm.page.clear_primary_action("Publish");
- frm.set_value('actual_published_date', frappe.datetime.nowdate());
- frappe.call({
- method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
- args: {
- "name": frm.doc.name,
- "file_path": r.message[1],
- },
- callback: (r) => {
- // frm.save('Update');
+ frm.set_value('publish_status', 'Published');
+ frm.page.clear_primary_action("Publish");
+ frm.set_value('actual_published_date', frappe.datetime.nowdate());
+ frappe.call({
+ method: "smart_service.transactions.doctype.publish.publish.update_procedure_value",
+ args: {
+ "name": frm.doc.name,
+ "file_path": r.message[1],
+ },
+ callback: (r) => {
+ // frm.save('Update');
+ }
+ })
+ frappe.msgprint({
+ title: __('Notification'),
+ message: __('Successfully Published: ' + r.message[1]),
+ primary_action: {
+ action(values) {
+ frm.save('Update');
}
- })
- frappe.msgprint({
- title: __('Notification'),
- message: __('Successfully Published: ' + r.message[1]),
- primary_action: {
- action(values) {
- frm.save('Update');
- }
- }
- });
+ }
+ });
// }
// else {
// frappe.msgprint({