def device_summary(request): device = str(request.POST.get('device')) device_details = database_helper.get_details_by_deviceid(device) try: #if this device page does not exist, attempt to create one: if device_details.count() == 0: valid_device = database_helper.save_device_details_from_default( device) if valid_device: device_details = Devicedetails.objects.filter(deviceid=device) #failure usually is the result of an invalid mac address string else: return render_to_response('invalid_device.html', {'deviceid': device}) except: return render_to_response('invalid_device.html', {'deviceid': device}) #following a device edit: if (request.POST.get('edit')): try: database_helper.save_device_details_from_request(request, device) except: return render_to_response('invalid_edit.html', {'deviceid': hashing}) hashing = device_details[0].hashkey if (hashing == ''): database_helper.assign_hash(device) device_details = database_helper.get_details_by_deviceid(device) return views_helper.get_response_for_devicehtml(device_details[0])
def device_summary(request): device = str(request.POST.get('device')) device_details = database_helper.get_details_by_deviceid(device) try: #if this device page does not exist, attempt to create one: if device_details.count()==0: valid_device = database_helper.save_device_details_from_default(device) if valid_device: device_details = Devicedetails.objects.filter(deviceid=device) #failure usually is the result of an invalid mac address string else: return render_to_response('invalid_device.html', {'deviceid': device}) except: return render_to_response('invalid_device.html', {'deviceid': device}) #following a device edit: if(request.POST.get('edit')): try: database_helper.save_device_details_from_request(request,device) except: return render_to_response('invalid_edit.html', {'deviceid' : hashing}) hashing = device_details[0].hashkey if (hashing==''): database_helper.assign_hash(device) device_details = database_helper.get_details_by_deviceid(device) return views_helper.get_response_for_devicehtml(device_details[0])
def edit_device_page(request, device): device_details = database_helper.get_details_by_deviceid(device) try: if len(device_details) < 1: return render_to_response('device_not_found.html') except: return render_to_response('device_not_found.html') deviceid = str(device_details[0].deviceid) return render_to_response('edit_device.html', {'detail' : device_details[0], 'deviceid': deviceid})
def edit_device_page(request, device): device_details = database_helper.get_details_by_deviceid(device) try: if len(device_details) < 1: return render_to_response('device_not_found.html') except: return render_to_response('device_not_found.html') deviceid = str(device_details[0].deviceid) return render_to_response('edit_device.html', { 'detail': device_details[0], 'deviceid': deviceid })
def get_location(hash): device = database_helper.get_device_by_hash(hash) details = database_helper.get_details_by_deviceid(device) if details.count() > 0: return (details[0].city + ", " + details[0].country) return "unavailable"
def get_location(hash): device = database_helper.get_device_by_hash(hash) details = database_helper.get_details_by_deviceid(device) if details.count()>0: return (details[0].city + ", " + details[0].country) return "unavailable"