|
|
@ -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] |