Ejemplo n.º 1
0
    def save_models(self):
        #获取保持对象
        obj = self.new_obj
        obj.save()
        if obj is not None:
            real_auth = obj
            real_auth.auditor = self.user.username
            real_auth.audiTime = timezone.now()

            user_profile = UserProfile.objects.filter(
                username=real_auth.applier).first()
            #审核成功给用户添加审核成功状态位
            if real_auth.state == BitStatesUtils.STATE_AUDIT():
                # user_profile = UserProfile.objects.filter(username=real_auth.applier).first()
                user_profile.real_auth_id = real_auth.id
                # 添加审核通过状态位
                user_profile.bitState = BitStatesUtils.addState(
                    user_profile.bitState, BitStatesUtils.GET_OP_REAL_AUTH())
                user_profile.save()

            else:
                # user_profile = UserProfile.objects.filter(username=real_auth.applier).first()
                #用户的实名认证取消
                user_profile.real_auth_id = None
                #状态位更改
                if BitStatesUtils.hasState(user_profile.bitState,
                                           BitStatesUtils.GET_OP_REAL_AUTH()):
                    user_profile.bitState = BitStatesUtils.removeState(
                        user_profile.bitState,
                        BitStatesUtils.GET_OP_REAL_AUTH())

                user_profile.save()

            # real_auth.course_nums = Course.objects.filter(course_org=course_org).count()
            real_auth.save()
Ejemplo n.º 2
0
 def removeState(self, value):
     self.bitState = BitStatesUtils.removeState(self.bitState, value)