def post(self, request):
		postData = request.POST
		state = False

		try:
			insertData = request.POST.dict()
			insertData.pop('csrfmiddlewaretoken')

			insertData['department'] = insertData['department'].replace(' ', '')

			if models.SysAssetPhone.objects.filter(asset_id = insertData.get('asset_id')).count() > 0:
				return HttpResponse(state)

			phoneNameInputMethod = insertData.get('phoneNameInputMethod')
			if phoneNameInputMethod == 'manual':
				insertData['phone_name'] = insertData.get('phone_name1')
			if phoneNameInputMethod == 'select':
				insertData['phone_name'] = insertData.get('phone_name2')

			insertData.pop('phoneNameInputMethod')
			insertData.pop('phone_name1')
			insertData.pop('phone_name2')

			newObj = models.SysAssetPhone.objects.create(**insertData)

			state = True
			Logger.warning(request, '添加新手机资产纪录, 新增记录数据ID为:%s' % newObj.id)
		except Exception as error:
			Logger.error(request, '手机资产插入新纪录时出现错误:%s' % error.__str__())

		return HttpResponse(state)
	def post(self, request):
		postData = request.POST
		state = False

		try:
			insertData = request.POST.dict()
			insertData.pop('csrfmiddlewaretoken')
			insertData.pop('assetType')

			insertData['department'] = insertData['department'].replace(' ', '')

			if models.SysAsset.objects.filter(Q(asset_id = insertData.get('asset_id')) | Q(ipphone_id = insertData.get('ipphone_id'))).count() > 0:
				return HttpResponse(state)

			if insertData.get('ipphone_number') == '' and insertData.get('ipphone_ip') == '' and insertData.get('ipphone_mac') == '':
				insertData.pop('ipphone_id')

			newObj = models.SysAsset.objects.create(**insertData)

			state = True
			Logger.warning(request, '添加新固定资产记录, 新增记录数据ID为:%s' % newObj.id)
		except Exception as error:
			Logger.error(request, '固定资产插入新记录时出现错误:%s' % error.__str__())

		return HttpResponse(state)
    def post(self, request):
        queryDict = request.POST.dict()
        queryDict.pop('csrfmiddlewaretoken')
        msg = ''
        try:
            newObj = models.SysModule.objects.create(**queryDict)
            if newObj:
                msg = True
                Logger.warning(request, '添加了新模块记录, 新增模块ID为:%s' % newObj.id)
        except Exception as error:
            Logger.error(request, '添加新模块记录时出现错误%s' % error.__str__())
            msg = error.__str__()

        return HttpResponse(msg)
Beispiel #4
0
    def post(self, request):
        status = False
        queryDict = request.POST.dict()
        queryDict.pop('csrfmiddlewaretoken')

        try:
            imageFile = request.FILES.get('image')
            if imageFile:
                if imageFile.size > (5 * 1024 * 1024):
                    return HttpResponse('上传的文件大小不得大于5M')

                fileName, dirName = basicUtils.fileWrite(imageFile.name,
                                                         fileStream=imageFile,
                                                         isImage=True,
                                                         mkdir=True,
                                                         hashFileName=True)
                queryDict['image_name'] = fileName
                queryDict['image_dir'] = dirName

            queryDict['create_time'] = basicUtils.getDatetimeNow()
            queryDict[
                'importance_status_text'] = settings.IMPORTANCE_STATUS_TEXT.get(
                    queryDict.get('importance_status'))
            queryDict['buy_status'] = 0
            queryDict['buy_process'] = 0
            queryDict['save_status'] = 0

            newObj = models.SysPurchase.objects.create(**queryDict)
            Logger.warning(
                request,
                '创建了新采购项, 新采购项ID:%s, 编号:%s' % (newObj.id, newObj.purchase_id))
            status = True
        except Exception as error:
            print(error)
            Logger.error(request, '创建新待采购项时出现错误:%s' % error.__str__())

        return HttpResponse(status)