Permalink
Browse files

Correct a bunch of silly mistakes

  • Loading branch information...
paltman committed Oct 10, 2011
1 parent 287b7da commit c95b717ba8a573d0cdbf9249607a304fb1ae421a
Showing with 10 additions and 9 deletions.
  1. +2 −1 anafero/middleware.py
  2. +4 −4 anafero/models.py
  3. +1 −1 anafero/templates/anafero/_create_referral_form.html
  4. +1 −1 anafero/urls.py
  5. +2 −2 anafero/views.py
View
@@ -24,4 +24,5 @@ def process_request(self, request):
def process_response(self, request, response):
if getattr(request.user, "_can_delete_anafero_cookie", False):
- request.delete_cookie("anafero-referral")
+ response.delete_cookie("anafero-referral")
+ return response
View
@@ -40,15 +40,15 @@ def create(cls, user, redirect_to, target=None):
code = sha_constructor("".join(bits)).hexdigest()
if target:
- obj = cls.objects.create(
+ obj, _ = cls.objects.get_or_create(
user=user,
code=code,
redirect_to=redirect_to,
target_content_type=ContentType.objects.get_for_model(target),
target_object_id=target.pk
)
else:
- obj = cls.objects.create(
+ obj, _ = cls.objects.get_or_create(
user=user,
code=code,
redirect_to=redirect_to,
@@ -58,14 +58,14 @@ def create(cls, user, redirect_to, target=None):
@classmethod
def record_response(cls, request, action_string):
- if request.is_authenticated():
+ if request.user.is_authenticated():
qs = ReferralResponse.objects.filter(user=request.user)
else:
qs = ReferralResponse.objects.filter(session_key=request.session.session_key)
try:
response = qs.order_by("-created_at")[0]
- return response.referral(request, action_string)
+ return response.referral.respond(request, action_string)
except IndexError:
pass
@@ -1,5 +1,5 @@
<form class="referral" action="{% url anafero_create_referral %}" method="post">
- {% crsf_token %}
+ {% csrf_token %}
<input type="hidden" name="redirect_to" id="redirect_to" value="{{ url }}" />
<input type="hidden" name="obj_ct_pk" id="obj_ct_pk" value="{{ obj_ct.pk }}" />
<input type="hidden" name="obj_pk" id="obj_pk" value="{{ obj.pk }}" />
View
@@ -5,5 +5,5 @@
urlpatterns = patterns("",
url(r"^$", create_referral, name="anafero_create_referral"),
- url(r"^(?P<code>\w+)/$)", process_referral, name="anafero_process_referral")
+ url(r"^(?P<code>\w+)/$", process_referral, name="anafero_process_referral")
)
View
@@ -19,7 +19,7 @@ def create_referral(request):
redirect_to=request.POST.get("redirect_to"),
target=target
)
- path = reverse("anafero_process_referral", code=referral.code)
+ path = reverse("anafero_process_referral", kwargs={"code": referral.code})
domain = Site.objects.get_current().domain
url = "http://%s%s" % (domain, path)
return HttpResponse(json.dumps({"status": "OK", "url": url}))
@@ -30,7 +30,7 @@ def process_referral(request, code):
referral.respond(request, "RESPONDED")
response = redirect(referral.redirect_to)
- if request.is_anonymous():
+ if request.user.is_anonymous():
response.set_cookie(
"anafero-referral",
"%s:%s" % (code, request.session.session_key)

0 comments on commit c95b717

Please sign in to comment.