Ejemplo n.º 1
0
Archivo: views.py Proyecto: vollov/sm
def create_store(request):
    logger.debug('calling store.views.create_store()')
    if request.method == 'POST':
        store_form = StoreForm(data=request.POST)
        if store_form.is_valid():
            store = store_form.save(commit=False)
            store.owner = request.user
            print 'user = {0}'.format(vars(request.user))
            store.save()
            return owner_profile(request)
        else:
            print store_form.errors
            return HttpResponse("Create store is failed.")
    else:
        # for visitor, generate empty menu
        
        menu = MenuService.new_user_menu(request.user)
        
        store_form = StoreForm()
        
    requestContext = RequestContext(request, {'menu':menu,
                                              'store_form': store_form, 
                                              'page_title': 'Create store'} )

    # Render the template depending on the context.
    return render_to_response('new.html', requestContext)
Ejemplo n.º 2
0
def store_apply(request):
    """
    店铺入驻
    :param request:
    :return:
    'name','seller','business','kinds','link','industry','character','phone','QQ',,'introduction,,
    'headpicture','companyname','connectioner','connection_number','company_adress','company_QQ','business_license'
    """
    user = request.user
    print user
    if request.method =='POST':
        form = StoreForm(request.POST or None, request.FILES or None)
        print "uiosdhfui"
        print form.errors
        if form.is_valid():
            name=form.cleaned_data['name']
            business=form.cleaned_data['business']
            kinds=form.cleaned_data['kinds']
            link=form.cleaned_data['link']
            industry=form.cleaned_data['industry']
            character=form.cleaned_data['character']
            phone=form.cleaned_data['phone']
            QQ=form.cleaned_data['QQ']
            introduction=form.cleaned_data['introduction']
            headpicture=form.cleaned_data['headpicture']
            companyname = form.cleaned_data['companyname']
            connectioner=form.cleaned_data['connectioner']
            connection_number=form.cleaned_data['connection_number']
            company_adress=form.cleaned_data['company_adress']
            company_QQ = form.cleaned_data['company_QQ']
            business_license = form.cleaned_data['business_license']
            company_introduce=form.cleaned_data['company_introduce']

            print headpicture
            print business_license
            print kinds
            # kind = big_goods_type.objects.get(id=kinds)
            # print kind
            # #头像保存
            path = default_storage.save(str(headpicture), ContentFile(headpicture.read()))
            tmp_file = os.path.join(settings.MEDIA_ROOT, path)
            headpicture = str(headpicture)
            #营业执照保存
            path = default_storage.save(str(business_license), ContentFile(business_license.read()))
            tmp_file = os.path.join(settings.MEDIA_ROOT, path)
            business_license = str(business_license)
            s=Store.objects.create(name=name, phone=phone, QQ=QQ,seller=user,
                                 business=business, industry=industry,kinds=kinds,
                                 character=character, introduction=introduction, headpicture=headpicture,
                                 companyname=companyname,link=link,
                                 connectioner=connectioner, connection_number=connection_number,
                                 company_adress=company_adress, company_QQ=company_QQ,
                                 business_license=business_license, company_introduce=company_introduce)
            return render(request,'person_rzcg.html')
        else:
            msg=u'参数填写错误'
            return render(request,'person_dpsq.html',{'msg':msg})
    else:
        return render(request, 'person_dpsq.html', {'forms': StoreForm(),'user':user})
Ejemplo n.º 3
0
def add_store(request,user_id=1):
    if request.POST:
        user = auth.get_user(request).id
        form = StoreForm(request.POST)
        if form.is_valid():
            Store = form.save(commit=False)
            Store.store_user_add_store = request.user
            form.save()
    return redirect('/')
Ejemplo n.º 4
0
def add_store(request, user_id=1):
    if request.POST:
        user = auth.get_user(request).id
        form = StoreForm(request.POST)
        if form.is_valid():
            Store = form.save(commit=False)
            Store.store_user_add_store = request.user
            form.save()
    return redirect('/')