Compare commits

...

5 Commits

  1. 24
      smart_service/apis/app_user_login.py
  2. 22
      smart_service/apis/master_api.py
  3. 3
      smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json
  4. 7
      smart_service/transactions/doctype/kilometer_mapping_items/kilometer_mapping_items.json

24
smart_service/apis/app_user_login.py

@ -414,6 +414,30 @@ def grant_user_access(userdata=None, iid=None):
except Exception as e1: except Exception as e1:
return {'status': 0, 'error': "Invalid Inputs"} return {'status': 0, 'error': "Invalid Inputs"}
@frappe.whitelist(allow_guest=True)
def data_invalidation(email, device_id, iid=None):
rate_res = custom_rate_limit(limit=5, seconds=15)
if rate_res != 1:
return rate_res
try:
# User validation
frappe.set_user("Administrator")
user_name = frappe.db.sql('''SELECT name FROM {0}.tabUser where email='{1}';'''.format(
current_db_name, email), as_dict=1)
token_details = []
if user_name:
""" New Refresh token update """
access_token = generate_access_token(user_name[0]['name'])
refresh_token = generate_refresh_token()
token_details = update_tokens_in_doc(
user_name[0]['name'], access_token, refresh_token)
return {'status': 1, 'data': token_details, 'error': None}
except Exception as e1:
return {'status': 0, 'data': [], 'error': 'Failed to verify user'}
@frappe.whitelist(allow_guest=True) @frappe.whitelist(allow_guest=True)
def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None): def new_app_user_validation(usr=None, pwd=None, iid=None, device_data=None):

22
smart_service/apis/master_api.py

@ -267,6 +267,8 @@ def masters(args=None, LSD=None,iid=None):
temp_api = frappe.get_doc( temp_api = frappe.get_doc(
"App Preference", "App Preference",
) )
time_val = datetime.datetime.strptime(
temp_api.auto_logout_time, '%H:%M:%S')
api = { api = {
"application_server_url": temp_api.application_server_url, "application_server_url": temp_api.application_server_url,
"update_server_url": temp_api.update_server_url, "update_server_url": temp_api.update_server_url,
@ -275,7 +277,7 @@ def masters(args=None, LSD=None,iid=None):
"masters_base_url": temp_api.masters_base_url, "masters_base_url": temp_api.masters_base_url,
"transactions_base_url": temp_api.transactions_base_url, "transactions_base_url": temp_api.transactions_base_url,
"addons_base_url": temp_api.addons_base_url, "addons_base_url": temp_api.addons_base_url,
"auto_logout_time": temp_api.auto_logout_time "auto_logout_time": time_val.strftime('%H:%M:%S.%f')
} }
else: else:
@ -296,3 +298,21 @@ def check_pub_type(iid):
if not device_pub_type: if not device_pub_type:
return False return False
return device_pub_type[0][0] return device_pub_type[0][0]
@frappe.whitelist(methods=['POST'])
def variant(LSD):
date_format = "%Y-%m-%d %H:%M:%S.%f"
if LSD != "":
try:
datetime.datetime.strptime(LSD, date_format)
except:
return {"status": 0, "error": " 'LSD' format error"}
try:
data = frappe.db.sql('''
select v.myid as variant_id,vm.name,vm.vehicle,vm.variant,vm.fuel,vm.transmission,vm.drive,vm.active_status
FROM `tabVariant Mapping` vm left join tabVariant v on v.name = vm.variant where vm.modified >='';''', as_dict=1)
return {"status": 1, "error": None, 'data': data}
except Exception as e:
frappe.local.response['http_status_code'] = 400
return {"status": 0, "error": e, 'data': None}

3
smart_service/transactions/doctype/kilometer_mapping/kilometer_mapping.json

@ -119,6 +119,7 @@
"label": "Filter By" "label": "Filter By"
}, },
{ {
"allow_bulk_edit": 1,
"fieldname": "config_kilometer", "fieldname": "config_kilometer",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Config Kilometer", "label": "Config Kilometer",
@ -173,7 +174,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2022-05-14 12:06:07.658115", "modified": "2023-10-26 16:59:55.910485",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Kilometer Mapping", "name": "Kilometer Mapping",

7
smart_service/transactions/doctype/kilometer_mapping_items/kilometer_mapping_items.json

@ -29,9 +29,10 @@
}, },
{ {
"fieldname": "sub_systems", "fieldname": "sub_systems",
"fieldtype": "Data", "fieldtype": "Link",
"in_list_view": 1, "in_list_view": 1,
"label": "Sub Systems", "label": "Sub Systems",
"options": "Sub Systems",
"read_only": 1 "read_only": 1
}, },
{ {
@ -39,7 +40,7 @@
"fieldname": "applicable", "fieldname": "applicable",
"fieldtype": "Check", "fieldtype": "Check",
"in_list_view": 1, "in_list_view": 1,
"label": "Applicable " "label": "Applicable"
}, },
{ {
"fieldname": "row_name", "fieldname": "row_name",
@ -51,7 +52,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2022-05-24 16:25:42.943208", "modified": "2023-10-26 16:59:40.075797",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Transactions", "module": "Transactions",
"name": "Kilometer Mapping_Items", "name": "Kilometer Mapping_Items",

Loading…
Cancel
Save