Ejemplo n.º 1
0
def signup3(request):
    '''
    上传凭证后state处于等待审核
    '''
    if request.method == 'POST':
        upProxy = UpgradeProxy()
        upList = Upgrade.objects.filter(user_id=request.user.id,up_source=UPGRADE_SOURCE.APPLY)
        #pdb.set_trace()
        if len(upList) == 0:
            upgrade = Upgrade(user_id=request.user.id,
                          original_level = request.user.user_level,
                          up_source = UPGRADE_SOURCE.APPLY,
                          apply_level = request.user.user_level,
                          need_typist = 1,
                          input_state = 0,
                          state = UPGRADE_STATE.APPLY)
            
            if upProxy.create_up(upgrade):
                apl = Apply.objects.get(user=request.user.id)
                apl.state=ApplyState.WAIT_AUDIT
                apl.save()
                return HttpResponseRedirect(reverse('shenma_wait_audit'))
        else:
            return HttpResponseRedirect(reverse('shenme_wait_audit'))
    elif request.method == 'GET':
        if '_jump_upload' in request.GET.keys():
            apl = Apply.objects.get(user=request.user.id)
            apl.state=ApplyState.WAIT_AUDIT
            apl.uploadtime = datetime.datetime.now()
            apl.save()
            return HttpResponseRedirect(reverse('shenma_wait_audit'))

    return render_to_response('%s/signup3.html'%SIGNUP_TEMPLATE_PATH,{},context_instance=RequestContext(request))
Ejemplo n.º 2
0
def upgrade_save_image(request):
    """
    保存异步上传文件的action
    """
    if request.method == "POST":
        result, msg = False, u""
        try:
            for lc_name in request.FILES:
                lc_type = LICENSE_TYPE.IMAGE_TYPE.get(lc_name.lower(), None)
                if lc_type is None:
                    raise Exception(u"不支持的凭证类型!")
                file = request.FILES[lc_name]
                ext = os.path.splitext(file.name)[1].lower()

                if ext not in LICENSE_TYPE.SUPPORTED_IMAGE:
                    raise Exception(u"图片类型错误,支持的图片类型%s" % string.join(LICENSE_TYPE.SUPPORTED_IMAGE, sep="|"))

                imgName = save_image(int(request.user.id), lc_name, file)
                voucherProxy = UpgradeVoucherProxy()
                upgradeProxy = UpgradeProxy()
                voucher = UpgradeVoucher(
                    user_id=request.user.id,
                    cert_type=lc_type,
                    name=imgName,
                    apply_level=upgradeProxy.get_next_level(request.user),
                )

                if voucherProxy.save_voucher(voucher) < 1:
                    raise Exception(u"UpgradeVoucher save error!")
                else:
                    msg = imgName
                    result = True
        except Exception, e:
            _logerror.exception(e)
            msg = e.message

        return HttpResponse(json.dumps({"succeed": result, "msg": msg}))
Ejemplo n.º 3
0
def upgrade_upload(request):
    """
    上传凭证页面
    """
    if not user_can_upgrade(request.user):
        return HttpResponseRedirect("/upgrade")
    if request.method == "POST":
        upProxy = UpgradeProxy()
        upgrade = Upgrade(
            user_id=request.user.id,
            original_level=request.user.user_level,
            up_source=UPGRADE_SOURCE.WEB,
            apply_level=upProxy.get_next_level(request.user),
            need_typist=1,
            input_state=0,
        )

        if not upProxy.is_valid(request.user, upgrade):
            raise Exception(u"凭证信息上传不够完整,怎么POST过来的数据?!uid:%s" % request.user.id)

        if upProxy.create_up(upgrade):
            return HttpResponseRedirect("/upgrade/waitaudit/")

    return render_to_response("userportal/upgrade/upload.html", context_instance=RequestContext(request))
Ejemplo n.º 4
0
def user_can_upgrade(user):
    """
    是否可以发起升级请求
    """
    upproxy = UpgradeProxy()
    return user.user_level < 2 and upproxy.can_upgrade(user)