def bus_details(request, bus_id): b = get_object_or_404(Business, pk=bus_id) try: print('get URL!\n') b.photourl = get_photo_web_url(b) except: b.photourl= "" #NONE print('url is ' + str(b.photourl)) context = get_default_bus_context(b, request.user) return render_to_response('ratings/busdetail.html', context_instance=RequestContext(request,context))
def ans_business_questions(request,bus_id): if not request.user.is_authenticated(): return HttpResponseRedirect('/accounts/login/?next=%s'%request.path) if request.method != 'POST': b = get_object_or_404(Business, pk=bus_id) try: b.photourl = get_photo_web_url(b) except: b.photourl= "" #NONE questions = get_questions(b,request.user) b = get_single_bus_data(b,request.user) context = get_default_bus_context(b, request.user) context['questions'] = questions context['value_questions'] = getValueTagsWithOptions() print(context['value_questions'][0].options) return render_to_response('ratings/contribute/ans_questions.html', context_instance=RequestContext(request,context)) else: bid = request.POST['bid'] values = [] booleans = [] #get the list of anwers for key in request.POST: if key.find('answer') > -1: booleans.append(request.POST[key]) for key in request.POST: if key.find('values') > -1: values.append(request.POST[key]) b = Business.objects.get(id=bid) for v in booleans: ans = v.split('_')[1] qid = v.split('_')[0] hardtag = HardTag.objects.get(id=qid) if ans == 'y': BooleanQuestion.objects.create(hardtag=hardtag,business = b,user=request.user,agree=True) else: BooleanQuestion.objects.create(hardtag=hardtag,business = b,user=request.user,agree=False) for v in values: ans = v.split('_')[1] vid = v.split('_')[0] valuetag = ValueTag.objects.get(id=vid) IntegerQuestion.objects.create(valuetag=valuetag,business = b,user=request.user,value=ans) return redirect('/ratings/'+str(bus_id)+'/')
def edit_master_tag_discussion(request,bus_id,page_id): if not request.user.is_authenticated(): return HttpResponseRedirect('/accounts/login/?next=%s'%request.path) b = get_object_or_404(Business, pk=bus_id) page = get_object_or_404(Page, pk=page_id) try: b.photourl = get_photo_web_url(b) except: b.photourl= "" #NONE if request.method == 'POST': form = PageForm(request.POST) if form.is_valid(): if not page: page = Page() page.content = form.cleaned_data['content'] page.save() return redirect(bus_details, bus_id=bus_id) else: if page: wiki_edit_form = PageForm(initial=page.__dict__) else: wiki_edit_form = PageForm(initial={'name': page.name}) try: pgr = PageRelationship.objects.get(page=page) except: pgr = PageRelationship.objects.filter(page=page)[0] t = pgr.businesstag context = get_default_bus_context(b, request.user) context['form']=wiki_edit_form context['page']=page context['tag'] =t return render_to_response('ratings/busdetail.html', context_instance=RequestContext(request,context))
def get_url_view(o): return get_photo_web_url(o)