Beispiel #1
0
def set_location(request):
    try:
        place_slug = request.GET.get('location', 'all')        
        tracker.add_event('set-location', {'location': place_slug})
        result = geocode(place_slug)
        if result: 
            try:
                user_point = Point(*result[1])
                pilot_city = City.objects.get(slug="fbn-pilot")
                request.session['fbn_pilot'] = user_point.within(pilot_city.enclosing_geometry)
            except:
                pass
            if request.city and not Point(*result[1]).within(request.city.enclosing_geometry):
                return HttpResponse(json.dumps({"status": False, 'reason': "NoCity"}), mimetype="application/json")  #redirect if place not within city limits
            request.session['bingeo'] = result[1]
            display_place_slug = place_slug.split(",")[0]
            request.session["place_slug"], request.session["display_place_slug"], request.session["delivery"], request.session["pick_up"] = place_slug, display_place_slug , True , False
        else:
            return HttpResponse(json.dumps({'reason': "NoPlace"}), mimetype="application/json")
        if "/no-such-place/" in request.referer:
            return HttpResponse(json.dumps({'reason': "NoPlace"}), mimetype="application/json")
        if "/not-in-city/" in request.referer:
            return HttpResponse(json.dumps({'reason': "NoCity"}), mimetype="application/json")
    except IndexError:
        raise 'hody'
        return HttpResponse(json.dumps({'reason': "NoPlace"}), mimetype="application/json")
    return HttpResponse(json.dumps({'display_name': request.session['place_slug']}), mimetype="application/json")
Beispiel #2
0
 def form_valid(self, form):
     form.instance.owner = self.request.user
     context = self.get_context_data()
     delivery_location_form = context['delivery_location_form']
     store = form.save()
     delivery_location_form.instance = store
     if delivery_location_form.is_valid():
         delivery_location_form.save()
         tracker.add_event('store-create', {'store': store.slug})
         return HttpResponseRedirect(self.success_url)
     else:
         return self.form_invalid(form)
     return super(StoreCreate, self).form_valid(form)
Beispiel #3
0
def set_city(request, slug):
    try:
        city = City.objects.get(slug=slug)
        tracker.add_event('set-city', {'city': slug})
        if city.slug != request.city and request.session.get('place_slug'):
            request.session.pop("place_slug")
            request.session.pop("display_place_slug")
            request.session.pop("bingeo")
        if 'specials' in request.referer and Special.objects.current():
            return redirect('http://'+city.slug + '.imly.in' + reverse('imly_specials', kwargs={'slug': Special.objects.current().slug}))
        return redirect('http://' + city.slug + '.imly.in/food/')
    except City.DoesNotExist:
        return redirect('http://imly.in/food/')
    except: 
        pass
    if "/will-be-there-soon/" in request.referer:
        return redirect("/food/")
    return redirect(request.GET.get("next", request.referer))
Beispiel #4
0
 def get_success_url(self):
     reviewed_item = self.object
     tracker.add_event('review-created', {'product': self.object.content_object.slug, 'store': self.object.content_object.store.slug})
     return reverse("imly_product_detail", args = (reviewed_item.content_object.store.slug,reviewed_item.content_object.slug,))