def request_temp_log_more_details(request): try: constraint = helpers.constraint(request, "POST"); data = constraint.safe({ "log_id": True, }); of_user = UserProfile.objects.get(user_id=request.user.id); of_log = Log.objects.get( id=data['log_id'], added_by__department_id=of_user.department_id ); return render(request, "ajax_temp/log_details.html", { 'data': of_log, 'out': of_log.out(), "is_out": of_log.is_out_provided(), "LOG" : Log }); except Log.DoesNotExist: raise Log.DoesNotExist("Index id of Log object does not exists"); except UserProfile.DoesNotExist: raise UserProfile.DoesNotExist("Index id of UserProfile object does not exists"); except helpers.InvalidRequest: raise helpers.InvalidRequest("Parameters does not supply required fields") pass; pass;
def database_save_as_out(request): try: constraint = helpers.constraint(request, "POST"); data = constraint.safe({ "log_id": True, "receiver_name": False, "description": False }); of_user = UserProfile.objects.get(user_id=request.user.id); of_log = Log.objects.get( id=data['log_id'], added_by__department_id=of_user.department_id, ); of_out = Out( receiver_name=data['receiver_name'], log=of_log, description=data['description'], added_by=of_user ); of_out.full_clean(); of_out.clean(); of_out.save(); of_log.is_out = True; of_log.save(); return render(request, "ajax_temp/log_details.html", { 'data': of_log, 'out': of_log.out(), "is_out": of_log.is_out_provided(), "LOG" : Log }); except Log.DoesNotExist: raise Log.DoesNotExist("Index id of Log object does not exists"); except UserProfile.DoesNotExist: raise UserProfile.DoesNotExist("Index id of UserProfile object does not exists"); except helpers.InvalidRequest: raise helpers.InvalidRequest("Parameters does not supply required fields") pass;
def get_tracing_code_info(request): try: constraint = helpers.constraint(request, "POST"); data = constraint.safe({ "tracing_code": True }); of_user_profile = UserProfile.objects.get(id=request.user.id); of_log_details = Log_details.objects.get( tracing_code=data['tracing_code'] ); is_department_log = of_log_details\ .added_by\ .department_id == of_user_profile.department_id; return render(request, "ajax_temp/action_tracking_code_info.html", { 'log_details': of_log_details, 'is_department_log' : is_department_log, "obj_log" : Log, "log_details_person" : of_log_details.person_visitor }); except Log_details.DoesNotExist: raise Log.DoesNotExist("Log details id does not exists"); except UserProfile.DoesNotExist: raise UserProfile.DoesNotExist("Index id of UserProfile object does not exists"); except helpers.InvalidRequest: raise helpers.InvalidRequest("Parameters does not supply required fields") pass; pass;
def database_add_new_log(request): constraint = helpers.constraint(request, "POST"); data = constraint.safe({ "contact_number2": False, "purpose": False, "type": True, "visitor_id": True, "document_from": False, "document_type" : False }); try: of_user = UserProfile.objects.get(user=request.user.id); of_person = Person.objects.get(id=data['visitor_id']); log_details_params = { "person_visitor": of_person, "contact_number":data['contact_number2'], "added_by" : of_user }; if data['document_type']: log_details_params['document_type'] = Document_type.objects.get(id=data['document_type']); if data['document_from']: log_details_params['document_from'] = Department.objects.get(id=data['document_from']); of_log_details = Log_details(**log_details_params); of_log_details.full_clean(); of_log_details.clean(); of_log_details.save(); of_log = Log( type=data['type'], purpose=data['purpose'], details=of_log_details, added_by=of_user ); try: of_log.full_clean(); of_log.clean(); of_log.save(); except e : of_log_details.delete(); raise Exception(e); pass; return render(request, "ajax_temp/after_added_new_log.html", { 'log': of_log, "obj_log" : Log, "log_details_person" : of_log.details.person_visitor }); except Person.DoesNotExist: raise UserProfile.DoesNotExist("Index id of Person object does not exists"); except UserProfile.DoesNotExist: raise UserProfile.DoesNotExist("Index id of UserProfile object does not exists"); except helpers.InvalidRequest: return HttpResponse('Invalid Request'); pass;