def create_post(): deviceType = request.forms.get('type') deviceSNID = request.forms.get('snid') deviceModel = request.forms.get('model') devicePurchaseDate = request.forms.get('purchase-date') deviceCost = request.forms.get('cost') deviceDependsOn = request.forms.get('depends-on') deviceAssignedTo = request.forms.get('assigned-to') devicePhysicalLocation = request.forms.get('physical-location') deviceStatus = request.forms.get('status') deviceName = deviceSNID devices = get_data() devices[deviceName] = {} devices[deviceName]['Type'] = deviceType devices[deviceName]['SNID'] = deviceSNID devices[deviceName]['Model'] = deviceModel devices[deviceName]['Purchase Date'] = devicePurchaseDate devices[deviceName]['Cost'] = deviceCost devices[deviceName]['Depends On'] = deviceDependsOn devices[deviceName]['Assigned To'] = deviceAssignedTo devices[deviceName]['Physical Location'] = devicePhysicalLocation devices[deviceName]['Status'] = deviceStatus write_data(devices) if 'software' in deviceType.lower(): redirect('/create/software/' + deviceSNID) elif 'desktop' in deviceType.lower(): redirect('/create/pc/' + deviceSNID) elif 'laptop' in deviceType.lower(): redirect('/create/pc/' + deviceSNID) elif 'phone' in deviceType.lower(): redirect('/create/phone/' + deviceSNID) else: redirect('/')
def create_post_more(name): devices = get_data() deviceSNID = request.forms.get('snid') if name == 'phone': devicePhone = request.forms.get('phone-number') for value in devices.values(): if value['SNID'] == deviceSNID: value['Phone Number'] == 'devicePhone' write_data(devices) redirect('/') elif name == 'pc': deviceIP = request.forms.get('ip_address') deviceMAC = request.forms.get('mac_address') deviceOS = request.forms.get('operating_system') for value in devices.values(): if value['SNID'] == deviceSNID: value['IP'] = deviceIP value['MAC'] = deviceMAC value['Operating System'] = deviceOS write_data(devices) redirect('/') elif name == 'software': deviceLicense = request.forms.get('license') deviceExpiry = request.forms.get('expiry_date') for value in devices.values(): if value['SNID'] == deviceSNID: value['License'] = deviceLicense value['Expiry Date'] = deviceExpiry write_data(devices) redirect('/') else: redirect('/')