def get(self, request, *args, **kwargs): if self.action == 'nonceStr': data = tools.getNonceStr(request) return tools.genErrorStatusResponse(error.status_200, **data) elif self.action == 'verifyCode': return tools.getVerifyCode(request) elif self.action == 'logout': return generic.userLogout(request) elif self.action == 'notification': return generic.userNotification(request) elif self.action == 'notificationDetail': return generic.notificationDetail(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): # if self.action == 'streets': # return common.getAllStreets(request) if self.action == 'communities': return common.getAllCommunites(request) elif self.action == 'conditions': return common.olderConditions(request) elif self.action == 'genAposChart': return common.genderAndPolitics_statistic(request) elif self.action == 'nationalityChart': return common.nationality_statistic(request) elif self.action == 'streetsChart': return common.peopleOfStreet_statistic(request) elif self.action == 'communityChart': return common.peopleOfCommunity_statistic(request) elif self.action == 'ageScope_statistic': return common.insurance_statistic(request) elif self.action == 'olderList': return common.olderList(request) elif self.action == 'olderDetail': return common.olderDetail(request) elif self.action == 'olderEditDetail': return common.olderInfoGetEdit(request) elif self.action == 'districtLevel': return common.olderDistrictLevel(request) elif self.action == 'olderForm': return common.olderBasicForm(request) elif self.action == "downLoadExportedData": return common.downLoadExportData(request) elif self.action == 'checkTaskStatus': return common.checkTaskStatus(request) elif self.action == 'exportDataCondition': return common.exportElderDataConditions(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if self.action == 'numericID': return tools.genErrorStatusResponse(error.status_200, **{'id': tools.ID.genUniqueid(), "this": id(self)}) elif self.action == 'menu': return tools.genErrorStatusResponse(error.status_200, **{"id": id(common.menus)}) elif self.action == 'identity': return generic.identityCheckInfo(request) elif self.action == 'download': response = downloadServer(request, path='186014102512110微信图片_20191017133828.png', document_root=settings.ACCESSORIES, show_indexes=True) response['Content-Disposition'] = 'attachment; filename={!s}'.format('测试中使用.zip') return response elif self.action == 'message': return common.messageDebug(request) return HttpResponse(status=404, content="not found ....")
def getSundries(request): """ 系统全局默认参数 :param request: :return: """ class Detail(tools.BaseData): pass dt = Detail() dt.pageSize = [i for i in default.defaultPageSize] # dt.status = [{'lable': v.value, 'value': k} for k, v in default.status.items()] # genre = request.user.groups.all()[0].genre # if genre in {local.super.name, local.systemAdmin.name}: # dt.districtLevel = [{"label": v.value, "value": k} for k, v in default.belongs.items()] # dt.roles = [{'label': k.value, 'value': k.name} for k in default.basicRoleGroup] # else: # dt.districtLevel = [] # dt.roles = [] # found = False # # 角色获取 # for group in request.user.groups.all(): # for item in common.menus.funcs: # if found or item.name == group.genre: # found = True # dt.roles.append({'label': item.value, 'value': item.name}) # found = False # # 行政级别获取 # for k, v in default.belongs.items(): # if found or k >= request.user.locate.ora_level: # found = True # dt.districtLevel.append({"label": v.value, "value": k}) return tools.genErrorStatusResponse(error.status_200, **dt.toJson)
def get(self, request, *args, **kwargs): if self.action == 'districtLevel': return common.policyArticleDistrictLevel(request) elif self.action == 'download': return common.policyDownloadAccessories(request) elif self.action == 'preview': return common.policyArticlePreview(request) elif self.action == 'articleList': return common.policyArticleList(request) elif self.action == 'publish': return common.policyArticlePublish(request) elif self.action == 'revocation': return common.policyArticleRevocation(request) elif self.action == 'statisticChart': return common.policyArticleChart(request) elif self.action == 'statisticList': return common.policyArticleStatisticList(request) elif self.action == 'lastArticles': return common.policyPublishList(request) elif self.action == 'articleDetail': return common.policyArticleDetail(request) elif self.action == "editPage": return common.policyArticleEditPage(request) elif self.action == 'dynamic': # 丰管理页的搜索 return common.policyDynamicSearch(request) elif self.action == 'manageDynamic': # 管理页的搜索 return common.policyDynamicSearch(request, managed=True) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if not self.action: return common.logList(request) elif self.action == 'detail': return common.detailLog(request) elif self.action == 'dynamic': return common.logDynamicSearch(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def dispatch(self, request, *args, **kwargs): self.actions = kwargs['path'].split('/') if kwargs['path'] else None if self.actions: self.actions = [*filter(lambda x: True if x else False, self.actions)] try: self.actions, self.tail = self.checkActions() except Exception as e: if default.debug: print(f"in the ItemProcess dispatch found error {e} ") return tools.genErrorStatusResponse(error.status_unAuthorized) kwargs['tail'] = self.tail if default.debug: print(f"in the ItemProcess dispatch actions:{self.actions}, tail:{self.tail}") with dbRouter.in_database('slave'): for group in request.user.groups.all(): objs = group.permissions.filter(codename__in=self.actions) if objs.count() != len(self.actions): return tools.genErrorStatusResponse(error.status_unAuthorized) return super(ItemProcess, self).dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs): if self.action == 'lastArticles': return common.policyPublishList(request) elif self.action == 'articleDetail': return common.policyArticleDetail(request) elif self.action == 'download': return common.policyDownloadAccessories(request) elif self.action == "activities": return common.homeGetActivities(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if self.action == 'recordList': return common.callCenterRecordList(request) elif self.action == "recordDetail": return common.callcenterRecordDetail(request) elif self.action == 'dynamic': return common.callcenterDynamicSearch(request) elif self.action == "downLoadExportedData": return common.downLoadExportData(request) elif self.action == 'checkTaskStatus': return common.checkTaskStatus(request) elif self.action == 'exportDataCondition': return common.exportElderDataConditions(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def userNotification(request): """ 通知消息 :param request: :return: """ genre = request.user.groups.all()[0].genre if genre in {local.super.name, local.systemAdmin.name}: return tools.genErrorStatusResponse(error.status_200) else: ret_list = [] for it in models.PolicyArt.objects.filter( Q(distribution__district__ora_index=request.user.locate. ora_index) & Q(articleStatus=2)).exclude( distribution__readers__user=request.user).values( 'title', 'articleid', "createTime"): data = tools.BaseData() data.title = it['title'] data.articleid = it['articleid'] data.createTime = it['createTime'].strftime( "%Y-%m-%d %H:%M") if it['createTime'] else None ret_list.append(data.toJson) return tools.genErrorStatusResponse(error.status_200, ret_list)
def notificationDetail(request): """ 通知查看内容 :param request: :return: """ need = [ local.polices.name, local.elderPolicy.name, local.lastestPolicy.name ] for group in request.user.groups.all(): ct = group.permissions.filter(codename__in=need) if len(ct) != len(need): return tools.genErrorStatusResponse(error.status_unAuthorized) return common.policyArticlePreview(request, detail=True)
def get(self, request, *args, **kwargs): if not self.action: return common.userLists(request) elif self.action == 'roles': return common.getUserRoles(request) elif self.action == "district": return common.getDistrictHierarchyForCreateUser(request) elif self.action == 'dynamic': return common.usersDynamicSearch(request) elif self.action == 'advancedDynamic': return common.userDynamicAdvancedSearch(request) elif self.action == 'advancedDynamicParam': return common.userAdvancedDynamicParam(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if not self.action: return common.getDistrictList(request) else: if self.action == 'hierarchy': return common.getDistrictHierarchy(request) elif self.action == "level": return common.getDistrictLevel(request) elif self.action == 'detail': return common.detailDistrict(request) elif self.action == 'order': return common.districtOrder(request) elif self.action == 'dynamic': return common.districtDynamicSearch(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def userLogin(request): """ 用户登录 :param request: :return: """ form = requestForms.Login(request.POST) if not form.is_valid(): print(f"in the form found error {form.errors}") return tools.genErrorStatusResponse(error.status_formError) username, password, verifyCode = form.cleaned_data[ 'username'], form.cleaned_data['password'], form.cleaned_data[ 'verifyCode'] cap = Captcha(request) if not cap.check(verifyCode): if default.debug: print(f"code check is invalid now {verifyCode}") return tools.genErrorStatusResponse(error.status_checkValueError) relPassword = tools.parsePassword(request, password) if default.debug: print("the username %s password %s %s" % (username, relPassword, password)) if not relPassword: return tools.genErrorStatusResponse(error.status_needRedo) user = authenticate(username=username, password=relPassword) if user: if user.is_authenticated and user.is_active: if default.debug: print("in index user %s will login now " % (user.username)) login(request, user) log = tools.BaseData() log.username, log.action = user.username, local.log_login.value tasks.logRecord.delay(log.toJson) return tools.genErrorStatusResponse( error.status_200, data=common.userPermission(user)) return tools.genErrorStatusResponse(error.status_usernameOrPasswordError)
def get(self, request, *args, **kwargs): if self.action == 'elder_lng_lat': return common.dataMapElderPosition(request) elif self.action == 'institution_lng_lat': return common.institutionMapPosition(request, {2, 1}, self.pageSize) elif self.action == 'careCenter_lng_lat': return common.institutionMapPosition(request, { 1, }, self.pageSize) elif self.action == 'elderStation_lng_lat': return common.institutionMapPosition(request, { 3, }, self.pageSize) elif self.action == 'stationList': return common.institutionMapPosition(request, {1, 2, 3}, self.pageSize) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if self.action == "condition": return common.financialCondition(request) elif self.action == "pineChart": return common.financialPineChart(request) elif self.action == 'histogramChart': return common.financialHistogramChart(request) elif self.action == 'projectList': return common.financialList(request) elif self.action == 'projectDetail': return common.financialDetail(request) elif self.action == 'basicForm': return common.FinancialBasicForm(request) elif self.action == 'projectEditDetail': return common.financialEditDetail(request) elif self.action == 'dynamic': return common.financialDynamicSearch(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def clearAllNotification(request): """ 清空用户通知 :param request: :return: """ if request.user.is_superuser: pass else: with dbRouter.in_database('slave'): for it in models.PolicyArt.objects.filter( Q(distribution__district__ora_index=request.user.locate. ora_index) & Q(articleStatus=2)).exclude( distribution__readers__user=request.user).values( 'articleid').iterator(): tasks.policyArticleStatistic.apply_async( args=[request.user.username, it['articleid']]) return tools.genErrorStatusResponse(error.status_200)
def get(self, request, *args, **kwargs): if self.action == 'conditions': return common.institutionCondition(request) elif self.action == 'institutionList': return common.institutionsList(request) elif self.action == 'institutionDetail': return common.institutionDetail(request) elif self.action == 'institutionEditDetail': return common.institutionEditDetail(request) elif self.action == 'districtLevel': return common.institutionDistrictLevel(request) elif self.action == 'institutionForm': return common.institutionBasicForm(request) elif self.action == 'exportDataCondition': return common.exportElderDataConditions(request) elif self.action == "downLoadExportedData": return common.downLoadExportInstitutionData(request) elif self.action == 'checkTaskStatus': return common.checkTaskStatusForInstitution(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def post(self, request, *args, **kwargs): if self.action == "exportTask": return common.exportCallcenterData(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def post(self, request, *args, **kwargs): if self.action == 'elder': return common.olderInfoUpdateOrCreate(request, created=True) elif self.action == 'exportTask': return common.exportElderData(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def identityCheckInfo(request): def getId(key, val): if not getattr(default, key, None): print(f"in the getId found {key} not in default") return None for k, v in getattr(default, key).items(): if k == val: return v return None form = requestForms.IdentityForm(request.GET) if not form.is_valid(): return tools.genErrorStatusResponse(error.status_formError) identity = form.cleaned_data['id'] for it in models.BasicInfoOfOlder.objects.select_related( 'pensions', 'flag', 'locate_county', 'locate_street', 'locate_community').filter(identityCard=identity): dt = tools.BaseData() dt.name = it.name dt.gender = getId('gender', it.gender) dt.identityCard = it.identityCard dt.birthDay = it.birthDay.strftime('%Y%m%d') if it.birthDay else None dt.nationality = getId('nationality', it.nationality) dt.education = getId('education', it.education) dt.politics = getId('politics', it.politics) dt.marriageStatus = getId('marriageStatus', it.marriageStatus) dt.identityType = getId('identityType', it.identityType) dt.locate_community = it.locate_community.ora_name if it.locate_community else None dt.locate_street = it.locate_street.ora_name if it.locate_street else None dt.locate_county = it.locate_county.ora_name if it.locate_county else None dt.address = it.address dt.postcode = it.postcode dt.censusRegister = it.censusRegister dt.registerNature = getId('registerNature', it.registerNature) dt.emergencyPeople = it.emergencyPeople dt.emergencyPhone = it.emergencyPhone dt.pensions_bjtCard = it.pensions.bjtCard dt.pensions_bankCard = it.pensions.bankCard dt.pensions_insuranceType = getId('insuranceType', it.pensions.insuranceType) dt.pensions_medicalInsuranceType = getId( 'medicalInsuranceType', it.pensions.medicalInsuranceType) dt.pensions_insured = getId('insured', it.pensions.insured) dt.pensions_mininumLivingLevel = getId('mininumLivingLevel', it.pensions.mininumLivingLevel) dt.pensions_laborCapacity = getId('laborCapacity', it.pensions.laborCapacity) dt.pensions_employmentStatus = getId('employmentStatus', it.pensions.employmentStatus) dt.pensions_vocation = getId('vocation', it.pensions.vocation) dt.pensions_healthStatus = getId('healthStatus', it.pensions.healthStatus) dt.pensions_bodyStatus = getId('bodyStatus', it.pensions.bodyStatus) dt.pensions_residenceStatus = getId('residenceStatus', it.pensions.residenceStatus) dt.pensions_livingDegree = getId('livingDegree', it.pensions.livingDegree) dt.pensions_careType = getId('careType', it.pensions.careType) dt.pensions_economicSource = getId('economicSource', it.pensions.economicSource) dt.pensions_incomingLevel = getId('incomingLevel', it.pensions.incomingLevel) dt.flag_isObjectTraditional = getId('isObjectTraditional', it.flag.isObjectTraditional) dt.flag_isObjectServiced = getId('isObjectServiced', it.flag.isObjectServiced) dt.flag_isSpecialSalvation = getId('isSpecialSalvation', it.flag.isSpecialSalvation) dt.flag_isLonely = getId('isLonely', it.flag.isLonely) dt.flag_isDisabled = getId('isDisabled', it.flag.isDisabled) dt.flag_isNZJ = getId('isNZJ', it.flag.isNZJ) dt.flag_isReleased = getId('isReleased', it.flag.isReleased) dt.flag_isExservicee = getId('isExservicee', it.flag.isExservicee) dt.flag_isReservoirImmigrant = getId('isReservoirImmigrant', it.flag.isReservoirImmigrant) dt.flag_isAbroadRelative = getId('isAbroadRelative', it.flag.isAbroadRelative) dt.flag_isDeath = getId('isDeath', it.flag.isDeath) return tools.genErrorStatusResponse(error.status_200, **dt.toJson) return tools.genErrorStatusResponse(error.status_notFound)
def delete(self, request, *args, **kwargs): if self.action == 'accessories': return common.pollicyAccessoriesDelete(request) elif self.action == 'article': return common.policyArtDelete(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if self.action == 'conditions': return common.olderHealthArchive_conditions(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def post(self, request, *args, **kwargs): if self.action == 'article': return common.policyArticleUpdateOrCreate(request, created=True) elif self.action == 'accessories': return common.policyArticleUpload(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def put(self, request, *args, **kwargs): if self.action == 'article': return common.policyArticleUpdateOrCreate(request, created=False) return tools.genErrorStatusResponse(error.status_notAllowed)
def post(self, request, *args, **kwargs): if self.action == 'institution': return common.institutionUpdateOrCreate(request, created=True) elif self.action == 'exportTask': return common.exportInstitutionData(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def post(self, request, *args, **kwargs): if self.action == 'financial': return common.financialUpdateOrCreate(request, created=True) return tools.genErrorStatusResponse(error.status_notAllowed)
def delete(self, request, *args, **kwargs): if self.action == 'financial': return common.financialDeleteItem(request) return tools.genErrorStatusResponse(error.status_notAllowed)
def put(self, request, *args, **kwargs): if self.action == 'institution': return common.institutionUpdateOrCreate(request, created=False) return tools.genErrorStatusResponse(error.status_notAllowed)
def get(self, request, *args, **kwargs): if self.action == 'conditions': return common.careCenterCondition(request) elif self.action == "institutionList": return common.careCenterList(request, self.institutionType) return tools.genErrorStatusResponse(error.status_notAllowed)