コード例 #1
0
ファイル: views.py プロジェクト: zouf/as2
def get_edit_business(request,bid):
  b = get_object_or_404(InterestedBusiness,pk=int(bid))
  editing = True
  businessform = InterestedBusinessForm(instance=b)
  if request.method == 'POST':
    if request.user != b.owner:
      return HttpResponseRedirect('/invalid')
    bform = InterestedBusinessForm(request.POST, instance=b)
    if bform.is_valid():
      bform.save()
      return HttpResponseRedirect('/menu/'+str(b.id))

  return render_to_response('menu/menuelements/menu.html',{'business':b,'busform': businessform, 'editing':editing}, context_instance=RequestContext(request))    
コード例 #2
0
ファイル: views.py プロジェクト: zouf/as2
def bus_signup(request):
  if request.user.is_authenticated():
    u = request.user
    if InterestedBusiness.objects.filter(owner=u.pk).count() > 0:
      print u.pk
      b =InterestedBusiness.objects.filter(owner=u.pk)[0]
      return HttpResponseRedirect('/menu/'+str(b.id))
    
  form = InterestedBusinessForm(request.POST)
  if form.is_valid():  
    b = form.save()
    b.owner = u
    b.save()
    return HttpResponseRedirect('/menu/'+str(b.id))
  else:
    form = InterestedBusinessForm()
  return render_to_response('menu/merchant/signup.html',{'form':form}, context_instance=RequestContext(request))