def BulkUploadSOR(request): array = Event.objects.filter(bulk_upload_indicator='Y') serializer = EventSerializer(array, many=True) json_array = serializer.data api = ApiDomains() url = api.event + "/" + "upload" #url='https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataeventAPI' #post data to the API for backend connection resp = requests.post(url, json=json_array) print("status code " + str(resp.status_code)) if resp.status_code == 502: resp.status_code = 201 obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 201: # This means something went wrong. message = {'messages': mesg} return render(request, "messages.html", context=message) else: Event.objects.filter(bulk_upload_indicator='Y').update( bulk_upload_indicator=" ") return HttpResponseRedirect(reverse("events:all"))
def save(self, *args, **kwargs): if (self.eventid == None): var = str(uuid.uuid4()) self.eventid = var[26:36] self.response = 'Success' super().save(*args, **kwargs) #connect to backend if self.backend_SOR_connection != "Disconnected": #converty model object to json serializer = EventSerializer(self) json_data = serializer.data api = ApiDomains() url = api.event #url='https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataeventAPI' #post data to the API for backend connection resp = requests.post(url, json=json_data) print("status code " + str(resp.status_code)) if resp.status_code == 502: resp.status_code = 201 obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message self.response = str(resp.status_code) + " - " + status_message if resp.status_code == 201: self.commit_indicator = "Committed" else: self.commit_indicator = "Not Committed" super().save(*args, **kwargs) else: print("not connected to backend!")
def save(self, *args, **kwargs): if (self.transmissionid == None): var = str(uuid.uuid4()) self.transmissionid = var[26:36] #Log events event = Event() event.EventTypeCode = "TRA" event.EventSubjectId = self.transmissionid event.EventSubjectName = self.SenderName event.EventTypeReason = "Transmission added" event.source = "Web App" event.creator=self.creator event.save() if (self.bulk_upload_indicator == "Y" and self.backend_SOR_connection != "Disconnected"): self.bulk_upload_indicator="" self.response='Success' super().save(*args, **kwargs) #connect to backend if self.backend_SOR_connection != "Disconnected": #converty model object to json serializer = TransmissionSerializer(self) json_data = serializer.data api = ApiDomains() url=api.transmission #url='https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidatatransmissionAPI' #post data to the API for backend connection resp = requests.post(url, json=json_data) print("status code " + str(resp.status_code)) if resp.status_code == 502: resp.status_code = 201 obj = get_object_or_404(APICodes, http_response_code = resp.status_code) status_message=obj.http_response_message self.response=str(resp.status_code) + " - " + status_message if resp.status_code == 201: self.commit_indicator="Committed" else: self.commit_indicator="Not Committed" #Log events event = Event() event.EventTypeCode = "TRC" event.EventSubjectId = self.transmissionid event.EventSubjectName = self.SenderName event.EventTypeReason = "Transmission added to ODS" event.source = "Web App" event.creator=self.creator event.save() super().save(*args, **kwargs) else: print("not connected to backend!")
def ListProductsHistory(request, pk): context = {} prod_obj = get_object_or_404(Product, pk=pk) api = ApiDomains() url = api.product + "/" + "history" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataProductAPI/history' payload = {'ident': prod_obj.productid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] dict_data = [] obj_data = [] json_data = resp.json() #print(json_data[0]) #print(json_data[1]) for ix in range(len(json_data)): obj = Product() #dict_data.append(json.loads(json_data[ix])) obj.pk = int(json_data[ix]["LOCAL_ID"]) obj.productid = json_data[ix]["PRODUCT_ID"] obj.name = json_data[ix]["NAME"] obj.type = json_data[ix]["TYPE"] obj.coverage_limit = json_data[ix]["COVERAGE_LIMIT"] obj.price_per_1000_units = json_data[ix]["RATE"] obj.product_date = json_data[ix]["CREATE_DATE"] obj.description = json_data[ix]["DESCRIPTION"] obj.description_html = misaka.html(obj.description) #obj.photo = json_data[ix]["PHOTO"] obj.creator = User.objects.get(pk=int(json_data[ix]["CREATOR"])) obj.create_date = json_data[ix]["CREATE_DATE"] obj.backend_SOR_connection = json_data[ix]["CONNECTION"] obj.response = json_data[ix]["RESPONSE"] obj.record_status = json_data[ix]["RECORD_STATUS"] obj.commit_indicator = json_data[ix]["COMMIT_INDICATOR"] obj_data.append(obj) context = {'object_list': obj_data} return render(request, "products/product_list.html", context=context)
def ListEventsHistory(request, pk): context = {} prod_obj = get_object_or_404(Event, pk=pk) api = ApiDomains() url = api.event + "/" + "history" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataeventAPI/history' payload = {'ident': prod_obj.eventid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] dict_data = [] obj_data = [] json_data = resp.json() #print(json_data[0]) #print(json_data[1]) for ix in range(len(json_data)): obj = Event() #dict_data.append(json.loads(json_data[ix])) obj.pk = int(json_data[ix]["LOCAL_ID"]) obj.eventid = json_data[ix]["EVENT_ID"] obj.EventTypeCode = json_data[ix]["EVENT_TYPE_CODE"] obj.EventSubjectId = json_data[ix]["EVENT_SUBJECT_ID"] obj.EventSubjectName = json_data[ix]["EVENT_SUBJECT_NAME"] obj.EventTypeReason = json_data[ix]["EVENT_TYPE_REASON"] obj.creator = User.objects.get(pk=int(json_data[ix]["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj.EventDate = json_data[ix]["EVENT_DATE"] obj.TransactionDate = json_data[ix]["TRANSACTION_DATE"] obj.backend_SOR_connection = json_data[ix]["CONNECTION"] obj.response = json_data[ix]["RESPONSE"] obj.commit_indicator = json_data[ix]["COMMIT_INDICATOR"] obj.record_status = json_data[ix]["RECORD_STATUS"] obj_data.append(obj) context = {'object_list': obj_data} return render(request, "events/event_list.html", context=context)
def BackendPull(request, pk): # fetch the object related to passed id #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataTransmissionAPI/latest' prod_obj = get_object_or_404(Transmission, pk=pk) api = ApiDomains() url = api.transmission + "/" + "latest" payload = {'ident': prod_obj.transmissionid} resp = requests.get(url, params=payload) print(resp.text) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = json.loads(resp.text) # fetch the object related to passed id #obj = get_object_or_404(Transmission, pk = json_data["LOCAL_ID"]) # pass the object as instance in form #form = TransmissionForm(request.POST or None, instance = obj) #OVERRIDE THE OBJECT WITH API data obj.pk = int(json_data["LOCAL_ID"]) obj.transmissionid = json_data["TRANSMISSION_ID"] obj.SenderName = json_data["SENDER_NAME"] obj.BenefitAdministratorPlatform = json_data[ "BENEFIT_ADMINISTRATOR_PLATFORM"] obj.ReceiverName = json_data["RECEIVER_NAME"] obj.TestProductionCode = json_data["TEST_PRODUCTION_CODE"] obj.TransmissionTypeCode = json_data["TRANSMISSION_TYPE_CODE"] obj.SystemVersionIdentifier = json_data["SYSTEM_VERSION_IDENTIFIER"] obj.planadmin_email = json_data["PLANADMIN_EMAIL"] obj.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj.create_date = json_data["CREATE_DATE"] obj.backend_SOR_connection = json_data["CONNECTION"] obj.response = json_data["RESPONSE"] obj.commit_indicator = json_data["COMMIT_INDICATOR"] obj.record_status = json_data["RECORD_STATUS"] context = {'transmission_details': obj} return render(request, "transmissions/transmission_detail.html", context=context)
def BackendPull(request, pk): # fetch the object related to passed id #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataProductAPI/latest' prod_obj = get_object_or_404(Product, pk=pk) api = ApiDomains() url = api.product + "/" + "latest" payload = {'ident': prod_obj.productid} resp = requests.get(url, params=payload) print(resp.text) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = json.loads(resp.text) # fetch the object related to passed id #obj = get_object_or_404(Product, pk = json_data["LOCAL_ID"]) # pass the object as instance in form #form = ProductForm(request.POST or None, instance = obj) #OVERRIDE THE OBJECT WITH API data obj.pk = int(json_data["LOCAL_ID"]) obj.productid = json_data["PRODUCT_ID"] obj.name = json_data["NAME"] obj.type = json_data["TYPE"] obj.coverage_limit = json_data["COVERAGE_LIMIT"] obj.price_per_1000_units = json_data["RATE"] obj.product_date = json_data["CREATE_DATE"] obj.description = json_data["DESCRIPTION"] obj.description_html = misaka.html(obj.description) obj.photo = json_data["PHOTO"] obj.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj.create_date = json_data["CREATE_DATE"] obj.backend_SOR_connection = json_data["CONNECTION"] obj.response = json_data["RESPONSE"] obj.commit_indicator = json_data["COMMIT_INDICATOR"] obj.record_status = json_data["RECORD_STATUS"] context = {'product_details': obj} return render(request, "products/product_detail.html", context=context)
def RefreshEvent(request, pk): # fetch the object related to passed id context = {} prod_obj = get_object_or_404(Event, pk=pk) api = ApiDomains() url = api.event + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataeventAPI/history' payload = {'ident': prod_obj.eventid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] json_data = resp.json() obj1 = Event() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.eventid = json_data["EVENT_ID"] obj1.EventTypeCode = json_data["EVENT_TYPE_CODE"] obj1.EventSubjectId = json_data["EVENT_SUBJECT_ID"] obj1.EventSubjectName = json_data["EVENT_SUBJECT_NAME"] obj1.EventTypeReason = json_data["EVENT_TYPE_REASON"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.EventDate = json_data["EVENT_DATE"] obj1.TransactionDate = json_data["TRANSACTION_DATE"] obj1.backend_SOR_connection = json_data["CONNECTION"] obj1.response = json_data["RESPONSE"] obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] obj1.save() context = {'event_details': obj1} return render(request, "events/event_detail.html", context=context)
def BulkUploadSOR(request): array = Product.objects.filter(bulk_upload_indicator='Y') serializer = ProductSerializer(array, many=True) json_array = serializer.data api = ApiDomains() url = api.product + "/" + "upload" #url='https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataProductAPI' #post data to the API for backend connection resp = requests.post(url, json=json_array) print("status code " + str(resp.status_code)) if resp.status_code == 502: resp.status_code = 201 obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 201: # This means something went wrong. message = {'messages': mesg} return render(request, "messages.html", context=message) else: Product.objects.filter(bulk_upload_indicator='Y').update( bulk_upload_indicator=" ") #Log events event = Event() event.EventTypeCode = "PRO" event.EventSubjectId = "productodsupload" event.EventSubjectName = "Bulk upload to ODS" event.EventTypeReason = "Products uploaded to ODS in bulk" event.source = "Online Transaction" event.creator = request.user event.save() return HttpResponseRedirect(reverse("products:all"))
def get_queryset(self, **kwargs): # new query = self.request.GET.get('q', None) object_list = Product.objects.filter( Q(productid__icontains=query) | Q(name__icontains=query) | Q(type__icontains=query) | Q(description__icontains=query)) #change start for remote SearchProductsForm if not object_list: api = ApiDomains() url = api.product + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataProductAPI/history' payload = {'ident': query} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) #message={'messages':mesg} #return render(self.request, "messages.html", context=message) print("Status Code: " + str(resp.status_code)) else: json_data = [] json_data = resp.json() obj_data = [] obj1 = Product() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.productid = json_data["PRODUCT_ID"] obj1.name = json_data["NAME"] obj1.type = json_data["TYPE"] obj1.coverage_limit = json_data["COVERAGE_LIMIT"] obj1.price_per_1000_units = json_data["RATE"] obj1.product_date = json_data["CREATE_DATE"] obj1.description = json_data["DESCRIPTION"] obj1.description_html = misaka.html(obj1.description) #obj1.photo = json_data["PHOTO"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.create_date = json_data["CREATE_DATE"] obj1.backend_SOR_connection = "Disconnected" obj1.response = "Pulled From Backend" obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] obj1.save() #obj_data.append(obj1) #print(obj_data) #context = {'object_list':obj_data} #return render(self.request, "products/product_search_list.html", context=context) object_remote_list = Product.objects.filter(productid=query) print(object_remote_list) return object_remote_list else: #change end for remote SearchProductsForm return object_list
def RefreshProduct(request, pk): # fetch the object related to passed id context = {} prod_obj = get_object_or_404(Product, pk=pk) api = ApiDomains() url = api.product + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataProductAPI/history' payload = {'ident': prod_obj.productid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] json_data = resp.json() obj1 = Product() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.productid = json_data["PRODUCT_ID"] obj1.name = json_data["NAME"] obj1.type = json_data["TYPE"] obj1.coverage_limit = json_data["COVERAGE_LIMIT"] obj1.price_per_1000_units = json_data["RATE"] obj1.product_date = json_data["CREATE_DATE"] obj1.description = json_data["DESCRIPTION"] obj1.description_html = misaka.html(obj1.description) #obj1.photo = json_data["PHOTO"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.create_date = json_data["CREATE_DATE"] obj1.backend_SOR_connection = "Disconnected" obj1.response = json_data["RESPONSE"] obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] #Log events event = Event() event.EventTypeCode = "PRR" event.EventSubjectId = obj1.productid event.EventSubjectName = obj1.name event.EventTypeReason = "Product refreshed from ODS" event.source = "Online Transaction" event.creator = obj1.creator event.save() obj1.save() context = {'product_details': obj1} return render(request, "products/product_detail.html", context=context)
def save(self, *args, **kwargs): if (self.employeeid == None): var = str(uuid.uuid4()) self.employeeid = var[26:36] #Log events event = Event() event.EventTypeCode = "EEA" event.EventSubjectId = self.employeeid event.EventSubjectName = self.name event.EventTypeReason = "Employee added" event.source = "Web App" event.creator=self.creator event.save() self.slug = slugify(self.name) self.response='Success' if (self.bulk_upload_indicator == "Y" and self.backend_SOR_connection != "Disconnected"): self.bulk_upload_indicator="" # self.description_html = misaka.html(self.description) super().save(*args, **kwargs) #connect to backend if self.backend_SOR_connection != "Disconnected": #converty model object to json serializer = EmployeeSerializer(self) json_data = serializer.data api = ApiDomains() url=api.employee #post data to the API for backend connection resp = requests.post(url, json=json_data) print("status code " + str(resp.status_code)) if resp.status_code == 502: resp.status_code = 201 obj = get_object_or_404(APICodes, http_response_code = resp.status_code) status_message=obj.http_response_message self.response=str(resp.status_code) + " - " + status_message if resp.status_code == 201: self.commit_indicator="Committed" else: self.commit_indicator="Not Committed" #Log events event = Event() event.EventTypeCode = "EEC" event.EventSubjectId = self.employeeid event.EventSubjectName = self.name event.EventTypeReason = "Employee added to ODS" event.source = "Web App" event.creator=self.creator event.save() super().save(*args, **kwargs) else: print("not connected to backend!")
def get_queryset(self, **kwargs): # new query = self.request.GET.get('q', None) object_list = Event.objects.filter( Q(eventid__icontains=query) | Q(EventTypeCode__icontains=query) | Q(EventTypeReason__icontains=query)) #change start for remote SearcheventsForm if not object_list: api = ApiDomains() url = api.event + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataeventAPI/history' payload = {'ident': query} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) #message={'messages':mesg} #return render(self.request, "messages.html", context=message) print("Status Code: " + str(resp.status_code)) else: json_data = [] json_data = resp.json() obj_data = [] obj1 = Event() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.eventid = json_data["EVENT_ID"] obj1.EventTypeCode = json_data["EVENT_TYPE_CODE"] obj1.EventSubjectId = json_data["EVENT_SUBJECT_ID"] obj1.EventSubjectName = json_data["EVENT_SUBJECT_NAME"] obj1.EventTypeReason = json_data["EVENT_TYPE_REASON"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.EventDate = json_data["EVENT_DATE"] obj1.TransactionDate = json_data["TRANSACTION_DATE"] obj1.backend_SOR_connection = json_data["CONNECTION"] obj1.response = json_data["RESPONSE"] obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] obj1.save() #obj_data.append(obj1) #print(obj_data) #context = {'object_list':obj_data} #return render(self.request, "eventevents/event_search_list.html", context=context) object_remote_list = Event.objects.filter(eventid=query) print(object_remote_list) return object_remote_list else: #change end for remote SearcheventsForm return object_list
def get_queryset(self, **kwargs): # new query = self.request.GET.get('q', None) object_list = Transmission.objects.filter( Q(transmissionid__icontains=query) | Q(SenderName__icontains=query) | Q(BenefitAdministratorPlatform__icontains=query) | Q(ReceiverName__icontains=query) | Q(TestProductionCode__icontains=query) | Q(TransmissionTypeCode__icontains=query)) #change start for remote SearchTransmissionsForm if not object_list: api = ApiDomains() url = api.transmission + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidataTransmissionAPI/history' payload = {'ident': query} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) #message={'messages':mesg} #return render(self.request, "messages.html", context=message) print("Status Code: " + str(resp.status_code)) else: json_data = [] json_data = resp.json() obj_data = [] obj1 = Transmission() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.transmissionid = json_data["TRANSMISSION_ID"] obj1.SenderName = json_data["SENDER_NAME"] obj1.BenefitAdministratorPlatform = json_data[ "BENEFIT_ADMINISTRATOR_PLATFORM"] obj1.ReceiverName = json_data["RECEIVER_NAME"] obj1.TestProductionCode = json_data["TEST_PRODUCTION_CODE"] obj1.TransmissionTypeCode = json_data["TRANSMISSION_TYPE_CODE"] obj1.SystemVersionIdentifier = json_data[ "SYSTEM_VERSION_IDENTIFIER"] obj1.planadmin_email = json_data["PLANADMIN_EMAIL"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.create_date = json_data["CREATE_DATE"] obj1.backend_SOR_connection = "Disconnected" obj1.response = "Pulled From Backend" obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] obj1.save() #obj_data.append(obj1) #print(obj_data) #context = {'object_list':obj_data} #return render(self.request, "TransmissionTransmissions/Transmission_search_list.html", context=context) object_remote_list = Transmission.objects.filter( transmissionid=query) print(object_remote_list) return object_remote_list else: #change end for remote SearchtransmissionsForm return object_list
def RefreshTransmission(request, pk): # fetch the object related to passed id context = {} prod_obj = get_object_or_404(Transmission, pk=pk) api = ApiDomains() url = api.transmission + "/" + "refresh" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidatatransmissionAPI/history' payload = {'ident': prod_obj.transmissionid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] json_data = resp.json() obj1 = Transmission() #OVERRIDE THE OBJECT WITH API data obj1.pk = int(json_data["LOCAL_ID"]) obj1.transmissionid = json_data["TRANSMISSION_ID"] obj1.SenderName = json_data["SENDER_NAME"] obj1.BenefitAdministratorPlatform = json_data[ "BENEFIT_ADMINISTRATOR_PLATFORM"] obj1.ReceiverName = json_data["RECEIVER_NAME"] obj1.TestProductionCode = json_data["TEST_PRODUCTION_CODE"] obj1.TransmissionTypeCode = json_data["TRANSMISSION_TYPE_CODE"] obj1.SystemVersionIdentifier = json_data["SYSTEM_VERSION_IDENTIFIER"] obj1.planadmin_email = json_data["PLANADMIN_EMAIL"] obj1.creator = User.objects.get(pk=int(json_data["CREATOR"])) #obj.crerator = get_object_or_404(User, pk=obj.creatorid) obj1.create_date = json_data["CREATE_DATE"] obj1.backend_SOR_connection = "Disconnected" obj1.response = json_data["RESPONSE"] obj1.commit_indicator = json_data["COMMIT_INDICATOR"] obj1.record_status = json_data["RECORD_STATUS"] #Log events event = Event() event.EventTypeCode = "TRR" event.EventSubjectId = obj1.transmissionid event.EventSubjectName = obj1.SenderName event.EventTypeReason = "Transmission refreshed from ODS" event.source = "Online Transaction" event.creator = obj1.creator event.save() #save data obj1.save() context = {'transmission_details': obj1} return render(request, "transmissions/transmission_detail.html", context=context)
def ListTransmissionsHistory(request, pk): context = {} prod_obj = get_object_or_404(Transmission, pk=pk) api = ApiDomains() url = api.transmission + "/" + "history" #url = 'https://94q78vev60.execute-api.us-east-1.amazonaws.com/Prod/intellidatatransmissionAPI/history' payload = {'ident': prod_obj.transmissionid} resp = requests.get(url, params=payload) print(resp.status_code) obj = get_object_or_404(APICodes, http_response_code=resp.status_code) status_message = obj.http_response_message mesg = str(resp.status_code) + " - " + status_message if resp.status_code != 200: # This means something went wrong. #raise ApiError('GET /tasks/ {}'.format(resp.status_code)) #raise APIError(resp.status_code) message = {'messages': mesg} return render(request, "messages.html", context=message) else: json_data = [] dict_data = [] obj_data = [] json_data = resp.json() #print(json_data[0]) #print(json_data[1]) for ix in range(len(json_data)): obj = Transmission() #dict_data.append(json.loads(json_data[ix])) obj.pk = int(json_data[ix]["LOCAL_ID"]) obj.transmissionid = json_data[ix]["TRANSMISSION_ID"] obj.SenderName = json_data[ix]["SENDER_NAME"] obj.BenefitAdministratorPlatform = json_data[ix][ "BENEFIT_ADMINISTRATOR_PLATFORM"] obj.ReceiverName = json_data[ix]["RECEIVER_NAME"] obj.TestProductionCode = json_data[ix]["TEST_PRODUCTION_CODE"] obj.TransmissionTypeCode = json_data[ix]["TRANSMISSION_TYPE_CODE"] obj.SystemVersionIdentifier = json_data[ix][ "SYSTEM_VERSION_IDENTIFIER"] obj.planadmin_email = json_data[ix]["PLANADMIN_EMAIL"] #obj.photo = json_data[ix]["PHOTO"] obj.creator = User.objects.get(pk=int(json_data[ix]["CREATOR"])) obj.create_date = json_data[ix]["CREATE_DATE"] obj.backend_SOR_connection = json_data[ix]["CONNECTION"] obj.response = json_data[ix]["RESPONSE"] obj.record_status = json_data[ix]["RECORD_STATUS"] obj.commit_indicator = json_data[ix]["COMMIT_INDICATOR"] obj_data.append(obj) context = {'object_list': obj_data} return render(request, "transmissions/transmission_list.html", context=context)