当前位置: 首页>>代码示例>>Python>>正文


Python Stock.type方法代码示例

本文整理汇总了Python中models.Stock.type方法的典型用法代码示例。如果您正苦于以下问题:Python Stock.type方法的具体用法?Python Stock.type怎么用?Python Stock.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Stock的用法示例。


在下文中一共展示了Stock.type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stock_add

# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import type [as 别名]
def stock_add(request):
    from app.remote.stocks import StockHistoryClient
    from app.forms import StockWizardForm
    from app.models import Company, Stock

    if request.method == "POST":
        form = StockWizardForm(request.POST)
        pprint(form.is_valid())
        if form.is_valid():
            # save
            company = Company()
            company.name = form.cleaned_data['company_name']
            company.country = form.cleaned_data['company_country']
            company.save()

            stock = Stock()
            stock.company = company
            stock.name = form.cleaned_data['name']
            stock.wkn = form.cleaned_data['wkn']
            stock.isin = form.cleaned_data['isin']
            stock.symbol = form.cleaned_data['symbol']
            stock.type = form.cleaned_data['type']
            stock.default_stock_exchange = form.cleaned_data['default_stock_exchange']
            stock.save()

            return HttpResponseRedirect(reverse('stock', args=(stock.symbol,)))
        else:
            pprint(form.errors)
    else:
        data = None
        if 'wkn_or_isin' in request.GET:
            shc = StockHistoryClient()
            data = shc.get_basics_by_wkn_or_isin(wkn_or_isin=request.GET['wkn_or_isin'])

            data['company_country'] = data['country']
            data['company_name'] = data['name']

        form = StockWizardForm(initial=data)

    return render_to_response(
        'stock_wizard_add.html',
        {
            'form': form
        },
        context_instance=RequestContext(request)
    )
开发者ID:mrcrgl,项目名称:stockstore,代码行数:48,代码来源:views.py

示例2: stock

# 需要导入模块: from models import Stock [as 别名]
# 或者: from models.Stock import type [as 别名]
def stock(request):
    groups = request.user.groups.all()
    groupList=[]
    for obj in groups:
        groupList.append(obj.name)
    usr=request.user
    if usr.is_superuser or 'stock' in groupList:
        companyObj=Company.objects.all()
        commodityObj=Commodity.objects.all()
        context={}
        context['companyObj']=companyObj
        # context['companyObjList']=json.dumps(list(companyObj))
        context['commodityObj']=commodityObj

        if request.method == 'POST':
            tp= request.POST.get('type1', None)
            stockObj=Stock()
            stockObj.type=request.POST.get('type1',None)
            stockObj.company_id=str(request.POST.get('company_Name',None))
            print str(request.POST.get('cmpAddress',None))
            stockObj.address_id=str(request.POST.get('cmpAddress',None))
            stockObj.bill_No=request.POST.get('bill_No',None)
            bill_Date = request.POST.get('bill_Date', None)
            if len(bill_Date)>4:
                stockObj.bill_Date=bill_Date
            bill_Rec_Date = request.POST.get('bill_Rec_Date', None)
            if len(bill_Rec_Date) > 4:
                stockObj.bill_Rec_Date=bill_Rec_Date
            try:
                bill_Amount = float(str(request.POST.get('bill_Amount', '')))
                stockObj.bill_Amount=bill_Amount
            except:
                pass

            stockObj.lr_No=request.POST.get('lr_No',None)
            lr_Date = request.POST.get('lr_Date', None)
            if len(lr_Date) > 4:
                stockObj.lr_Date=lr_Date
            stockObj.cases=request.POST.get('cases',None)
            stockObj.carriers_Name=request.POST.get('carriers_Name',None)
            stockObj.permit_No=request.POST.get('permit_No',None)
            try:
                permit_Amt = float(str(request.POST.get('permit_Amt', '')))
                stockObj.permit_Amt = permit_Amt
            except:
                pass
            stockObj.doc_Month=request.POST.get('doc_Month',None)
            stockObj.F_C_O=request.POST.get('F_C_O',None)
            date = request.POST.get('date', None)
            if len(date) > 4:
                stockObj.date=date
            stockObj.qrt=request.POST.get('qrt',None)
            stockObj.remarks=request.POST.get('remarks',None)
            stockObj.commodity_id=str(request.POST.get('commodity',None))
            stockObj.year=request.POST.get('year',None)
            stockObj.save()
            context['message']="Stock Added Successfully. Note down Record Id-"+str(stockObj.id)
            return render(request, 'stock.html',context)
        return render(request, 'stock.html',context)
    else:
        context={'errorCode':404,'errorMsg':'You dont have this permissions'}
开发者ID:abhishekbkhemka,项目名称:kalapatru,代码行数:63,代码来源:views.py


注:本文中的models.Stock.type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。