Esempio n. 1
0
def login(request):
    context = RequestContext(request)
    context_dict = {}
    if request.method == 'POST':
        if 'username' in request.POST:
            u_name = request.POST.get('username', '')
            if not u_name:
                context_dict['errors1'] = '请输入姓名'
            else:
                context_dict['username'] = u_name
        if 'password' in request.POST:
            u_pwd = request.POST.get('password', '')
            if not u_pwd:
                context_dict['errors2'] = '请输入密码'
            else:
                context_dict['password'] = u_pwd
        print u_name, u_pwd
        if T.CheckExist(USERS, {'u_name': u_name, 'u_pwd': u_pwd}):
            USERS_obj = USERS.objects.get(u_name=u_name, u_pwd=u_pwd)
            request.session['username'] = USERS_obj.u_name
            request.session['user_id'] = USERS_obj.id
            return HttpResponseRedirect('/c/account_list/')
        else:
            if u_name and u_pwd:
                context_dict['errors'] = '用户名与密码不匹配,请重新输入'
                return render_to_response('qdinvest/login.html', context_dict,
                                          context)
    return render_to_response('qdinvest/login.html', context_dict, context)
Esempio n. 2
0
def sdetail(request, s_id):
    context = RequestContext(request)
    context_dict = {}
    if T.CheckExist(STOCK, {'id': s_id}):
        STOCK_obj = STOCK.objects.get(id__exact=s_id)
        context_dict['stock'] = STOCK_obj
    STOCK_objs2 = INVEST_STOCK.objects.filter(is_stock__id__exact=s_id)
    context_dict['invest_stocks'] = STOCK_objs2
    return render_to_response('qdinvest/sdetail.html', context_dict, context)
Esempio n. 3
0
def bdetail(request, t_id):
    context = RequestContext(request)
    context_dict = {}
    if T.CheckExist(BOND, {'id': t_id}):
        BOND_obj = BOND.objects.get(id__exact=t_id)
        BOND_obj2 = INVEST_BOND.objects.filter(ib_bond__id__exact=t_id)
        context_dict['bond'] = BOND_obj
        context_dict['invest_bonds'] = BOND_obj2
    return render_to_response('qdinvest/bdetail.html', context_dict, context)
Esempio n. 4
0
def news(request):
    context = RequestContext(request)
    context_dict = {}
    if request.session.has_key('username'):
        u_name = request.session['username']
        USERS_objs = USERS.objects.filter(u_name__exact=u_name)
        if USERS_objs:
            notices = []
            notice_user = []
            NOTICE_objs = NOTICE.objects.filter(
                no_is_delete__exact=0).order_by('-no_time')
            if NOTICE_objs:
                for NOTICE_obj in NOTICE_objs:
                    notice_data = {}
                    notice_data['id'] = NOTICE_obj.id
                    notice_data['no_title'] = NOTICE_obj.no_title
                    notice_data['no_time'] = NOTICE_obj.no_time
                    notice_data['no_type'] = NOTICE_obj.no_type
                    notice_data['type'] = 'sys'
                    if T.CheckExist(NOTICE_READ, {
                            'nr_user': USERS_objs[0],
                            'nr_notice': NOTICE_obj
                    }):
                        notice_data['no_is_read'] = 1
                    else:
                        notice_data['no_is_read'] = 0
                    notices.append(notice_data)
                    context_dict['notices'] = notices
                    # print 		context_dict['notices'][0]
            NOTICE_USER_objs = NOTICE_USER.objects.filter(
                nu_is_delete__exact=0,
                nu_user__exact=USERS_objs[0]).order_by('-nu_time')
            if NOTICE_USER_objs:
                for NOTICE_USER_obj in NOTICE_USER_objs:
                    notice_data1 = {}
                    notice_data1['id'] = NOTICE_USER_obj.id
                    notice_data1['nu_title'] = NOTICE_USER_obj.nu_title
                    # print notice_data1['nu_title']
                    notice_data1['nu_time'] = NOTICE_USER_obj.nu_time
                    notice_data1['nu_type'] = NOTICE_USER_obj.nu_type
                    notice_data1['nu_is_read'] = NOTICE_USER_obj.nu_is_read
                    notice_data1['type'] = 'user'
                    notice_user.append(notice_data1)
                    #按照时间的倒序进行排列
                    context_dict['notice_users'] = notice_user
                    print context_dict['notice_users'][0]

            context_dict['status'] = 1

        else:
            context_dict['status'] = 0
        context_dict['news'] = 1
    return render_to_response('qdinvest/news.html', context_dict, context)
Esempio n. 5
0
def forget1(request):
    context = RequestContext(request)
    context_dict = {}
    if request.method == 'GET':
        username = request.GET.get('u_name', '')
        if T.CheckExist(USERS, {'u_name': username}):
            context_dict['msg'] = 'success'
            return HttpResponse(json.dumps(context_dict),
                                content_type="application/json")
        else:
            context_dict['msg'] = '此用户名未注册过,无法找回密码'
            return HttpResponse(json.dumps(context_dict),
                                content_type="application/json")
Esempio n. 6
0
def forget(request):
    context = RequestContext(request)
    context_dict = {}
    kwargs = {}
    if request.method == 'POST':
        test = request.POST.get('rc_code', '')
        telephone = request.POST.get('u_tel', '')
        password = request.POST.get('u_pwd', '')
        print test, telephone, password
        if T.CheckExist(RANDOMCODE, {'rc_tel': telephone, 'rc_code': test}):
            USERS.objects.filter(u_tel=telephone).update(u_pwd=password)
            return HttpResponseRedirect('/c/login/')
        else:
            context_dict['error'] = '手机号码与验证码不符'
    return render_to_response('qdinvest/forget.html', context_dict, context)
Esempio n. 7
0
def stock_list(request):
    context = RequestContext(request)
    context_dict = {}
    invest = []
    st_invest_price = 0
    if request.session.has_key('username'):
        u_name = request.session['username']
        USERS_obj = USERS.objects.get(u_name__exact=u_name)
        STOCK_objs1 = INVEST_STOCK.objects.filter(is_user__u_name=u_name)
        context_dict['invest_stocks'] = STOCK_objs1
        if STOCK_objs1:
            for STOCK_obj in STOCK_objs1:
                st_invest_price += STOCK_obj.is_amount
            STOCK_ids = INVEST_STOCK.objects.filter(
                is_user__u_name=u_name).values('is_stock').distinct()
            if STOCK_ids:
                for STOCK_id in STOCK_ids:
                    STOCK_obj = STOCK.objects.get(
                        id__exact=STOCK_id['is_stock'])
                    is_payment = 0
                    if T.CheckExist(
                            PAYMENT, {
                                'pa_user': USERS_obj,
                                'pa_stock': STOCK_obj,
                                'pa_status': 0
                            }):
                        is_payment = 1
                    invest.append({
                        'id': STOCK_obj.id,
                        'st_brief': STOCK_obj.st_brief,
                        'st_com_type': STOCK_obj.st_com_type,
                        'st_pro_type': STOCK_obj.st_pro_type,
                        'st_industry': STOCK_obj.st_industry,
                        'is_payment': is_payment
                    })
            context_dict['stocks'] = invest
        context_dict['invest_price'] = st_invest_price
        context_dict['stock_list'] = 1
    else:
        return HttpResponseRedirect('/c/login/')
    return render_to_response('qdinvest/stock_list.html', context_dict,
                              context)
Esempio n. 8
0
def news2(request):
    context = RequestContext(request)
    context_dict = {}
    if request.session.has_key('username'):
        u_name = request.session['username']
    if request.method == 'GET':
        n_type = request.GET.get('type', '')
        n_id = request.GET.get('id', '-1')
        context_dict['type'] = n_type
        USERS_objs = USERS.objects.filter(u_name__exact=u_name)
        if USERS_objs:
            if n_type == 'sys':
                NOTICE_objs = NOTICE.objects.filter(id__exact=n_id)
                context_dict['notices'] = NOTICE_objs[0]
                if NOTICE_objs:
                    if not T.CheckExist(NOTICE_READ, {
                            'nr_user': USERS_objs[0],
                            'nr_notice': NOTICE_objs[0]
                    }):
                        NOTICE_READ_new = NOTICE_READ(nr_user=USERS_objs[0],
                                                      nr_notice=NOTICE_objs[0])
                        NOTICE_READ_new.save()
                        ACCOUNT_obj = ACCOUNT.objects.get(
                            ac_user=USERS_objs[0])
                        ACCOUNT_obj.ac_infos -= 1
                        ACCOUNT_obj.save()
            elif n_type == 'user':
                NOTICE_USER_objs = NOTICE_USER.objects.filter(id__exact=n_id)
                context_dict['notice_users'] = NOTICE_USER_objs[0]
                if NOTICE_USER_objs:
                    if NOTICE_USER_objs[0].nu_is_read == 0:
                        ACCOUNT_obj = ACCOUNT.objects.get(
                            ac_user=USERS_objs[0])
                        ACCOUNT_obj.ac_infos -= 1
                        ACCOUNT_obj.save()
                    #标记为已经阅读
                    NOTICE_USER_objs[0].nu_is_read = 1
                    NOTICE_USER_objs[0].save()
        context_dict['news2'] = 1
    return render_to_response('qdinvest/news2.html', context_dict, context)
Esempio n. 9
0
def bond_list(request):
    context = RequestContext(request)
    context_dict = {}
    invest = []
    ib_invest_price = 0
    if request.session.has_key('username'):
        u_name = request.session['username']
        USERS_obj = USERS.objects.get(u_name__exact=u_name)
        BOND_objs1 = INVEST_BOND.objects.filter(ib_user__u_name=u_name)
        context_dict['invest_bonds'] = BOND_objs1
        if BOND_objs1:
            for BOND_obj in BOND_objs1:
                ib_invest_price += BOND_obj.ib_amount
            BOND_ids = INVEST_BOND.objects.filter(
                ib_user__u_name=u_name).values('ib_bond').distinct()
            if BOND_ids:
                for BOND_id in BOND_ids:
                    BOND_obj = BOND.objects.get(id__exact=BOND_id['ib_bond'])
                    is_payment = 0
                    if T.CheckExist(PAYMENT, {
                            'pa_user': USERS_obj,
                            'pa_bond': BOND_obj,
                            'pa_status': 0
                    }):
                        is_payment = 1
                    invest.append({
                        'id': BOND_obj.id,
                        'bo_title': BOND_obj.bo_title,
                        'bo_com_type': BOND_obj.bo_com_type,
                        'bo_pro_type': BOND_obj.bo_pro_type,
                        'bo_industry': BOND_obj.bo_industry,
                        'is_payment': is_payment
                    })
            context_dict['bonds'] = invest
        context_dict['invest_price'] = ib_invest_price
        context_dict['bond_list'] = 1
    else:
        return HttpResponseRedirect('/c/login/')
    return render_to_response('qdinvest/bond_list.html', context_dict, context)
Esempio n. 10
0
def Invest(request):
    response_dict = {}

    if not request.session.has_key('username'):
        response_dict['status'] = -1
    elif request.method == 'POST':
        p_type = request.POST.get('type', '')
        p_id = request.POST.get('id', '-1')
        price = request.POST.get('price', '0')
        USERS_obj = USERS.objects.get(
            u_name__exact=request.session['username'])
        if float(price) > 0:
            if p_type == 'stock':
                STOCK_objs = STOCK.objects.filter(id__exact=p_id)
                if STOCK_objs:
                    if not T.CheckExist(INVEST_STOCK, {
                            'is_user': USERS_obj,
                            'is_stock': STOCK_objs[0]
                    }):
                        ACCOUNT_obj = ACCOUNT.objects.get(ac_user=USERS_obj)
                        ACCOUNT_obj.ac_support += 1
                        ACCOUNT_obj.save()
                    response_dict['status'] = 1
                    INVEST_STATUS_obj = INVEST_STATUS.objects.get(id__exact=1)
                    print '1'
                    INVEST_STOCK_new = INVEST_STOCK(
                        is_user=USERS_obj,
                        is_stock=STOCK_objs[0],
                        is_amount=str(price),
                        is_date=datetime.now(),
                        is_status=INVEST_STATUS_obj)
                    INVEST_STOCK_new.save()
                    print '2'

                    STOCK_objs[0].st_invest_count += 1
                    STOCK_objs[0].save()

                else:
                    response_dict['status'] = 0
            elif p_type == 'bond':
                BOND_objs = BOND.objects.filter(id__exact=p_id)
                if BOND_objs:
                    if not T.CheckExist(INVEST_BOND, {
                            'ib_user': USERS_obj,
                            'ib_bond': BOND_objs[0]
                    }):
                        ACCOUNT_obj = ACCOUNT.objects.get(ac_user=USERS_obj)
                        ACCOUNT_obj.ac_support += 1
                        ACCOUNT_obj.save()
                    response_dict['status'] = 1
                    INVEST_STATUS_obj = INVEST_STATUS.objects.get(id__exact=1)
                    INVEST_BOND_new = INVEST_BOND(ib_user=USERS_obj,
                                                  ib_bond=BOND_objs[0],
                                                  ib_amount=str(price),
                                                  ib_date=datetime.now(),
                                                  ib_status=INVEST_STATUS_obj)
                    INVEST_BOND_new.save()

                    BOND_objs[0].bo_invest_count += 1
                    BOND_objs[0].save()

                else:
                    response_dict['status'] = 0
            else:
                response_dict['status'] = 0
        else:
            response_dict['status'] = 2

    if settings.DEBUG:
        print response_dict
    return HttpResponse(json.dumps(response_dict),
                        content_type="application/json")