Permalink
Browse files

Fixed merge conflict

  • Loading branch information...
2 parents 8e835f1 + a27c6ee commit a93cfeedb46b6f94c71ae4eb9ee7d107989b3d24 @aduston aduston committed Oct 5, 2012
Showing with 50 additions and 36 deletions.
  1. +16 −17 main/templates/safari.html
  2. +1 −1 main/views.py
  3. +25 −12 middleware.py
  4. +8 −6 templates/base.html
@@ -3,25 +3,24 @@
{% load static %}
{% load url from future %}
+{% block nav %}{% endblock nav %}
+
{% block css %}
- <link rel="stylesheet" href="{% static 'css/safari.css' %}">
+<link rel="stylesheet" href="{% static 'css/safari.css' %}">
{% endblock %}
{% block content %}
- <div class="main-content cf">
- <div class="main-content-message">
- <h2>Hello, Safari user!</h2>
- </div>
- <div class="main-content-message">
- <p>One thing before we can get this Facebook app working for you&mdash;we need you to change your settings. Safari is blocking third-party cookies, including ones from Facebook applications.</p>
- <p>So, please turn on third-party cookies please. Go to Safari's preferences, then the Privacy tab and choose "Never". That's it!</p>
- <figure>
- <figcaption>
- <img src="{% static 'img/block.png' %}" alt="" />
- </figcaption>
- </figure>
- <p>We could do a workaround, but we don't want to compromise your security. But, we do want you to be able to register to vote, pledge, and see which of your friends are voting.</p>
- <p><a href="{% url 'main:register' %}" class="btn btn-large btn-green"><i class="icon-ok"></i> Use the app now!</a></p>
- </div>
- </div>
+<div class="main-content cf">
+ <div class="main-content-message">
+ <h2>Help us get more Americans to vote than ever before.</h2>
+ </div>
+ <div class="main-content-message">
+ <form action="{% url 'main:index' %}" method="post">
+ <input type="hidden" name="uid" value="{{ fb_uid }}" />
+ <input type="hidden" name="signed_request" value="{{ signed_request }}" />
+ <input type="hidden" name="access_token" value="{{ access_token }}" />
+ <input type="submit" name="safari" class="btn btn-large btn-green" value="Get started!" />
+ </form>
+ </div>
+</div>
{% endblock %}
View
@@ -31,7 +31,7 @@ def _post_index(request):
data = facebook.parse_signed_request(
signed_request,
settings.FACEBOOK_APP_SECRET)
- if not data.get("user_id") or not hasattr(request, 'facebook'):
+ if not data.get("user_id"):
scope = ["user_birthday", "user_location", "friends_birthday,"
"friends_hometown", "friends_location", "email"]
auth_url = facebook.auth_url(settings.FACEBOOK_APP_ID,
View
@@ -1,7 +1,7 @@
import facebook
from django.conf import settings
-from django.core.urlresolvers import resolve
-from django.shortcuts import redirect
+from django.shortcuts import render_to_response
+from django.template import RequestContext
from main.models import User
@@ -28,27 +28,40 @@ def _get_fb_user_canvas(self, request):
return fb_user
def _get_fb_user(self, request):
+ if request.POST.get("safari", False):
+ fb_user = { "method": "safari",
+ "uid": request.POST["uid"],
+ "access_token": request.POST["access_token"] }
+ return fb_user
fb_user = self._get_fb_user_cookie(request)
if fb_user:
return fb_user
return self._get_fb_user_canvas(request)
+ def _is_initial_safari_post(self, request):
+ if 'fb_user' not in request.session and \
+ 'safari' not in request.POST:
+ ua = request.META['HTTP_USER_AGENT']
+ if 'Safari' in ua and not 'Chrome' in ua:
+ return True
+ return False
+
def process_request(self, request):
fb_user = self._get_fb_user(request)
request.facebook = fb_user
if fb_user:
user, created = User.objects.get_or_create(fb_uid=fb_user["uid"])
+ # Safari blocks third-party cookies by default.
+ if self._is_initial_safari_post(request):
+ return render_to_response(
+ 'safari.html',
+ { 'fb_uid': fb_user['uid'],
+ 'signed_request': request.POST['signed_request'],
+ 'access_token': fb_user['access_token']},
+ RequestContext(request))
request.session["fb_user"] = fb_user
request.session.modified = True
- else:
- request.facebook = request.session.get("fb_user", None)
-
- # Safari blocks third-party cookies by default.
- ua = request.META['HTTP_USER_AGENT']
- missing_data = not request.facebook or 'uid' not in request.facebook
- is_safari = 'Safari' in ua and not 'Chrome' in ua
- is_safari_view = resolve(request.path)[0].func_name == 'SafariView'
- if missing_data and is_safari and not is_safari_view:
- return redirect("main:safari")
+
+ request.facebook = request.session.get("fb_user", None)
return None
View
@@ -48,12 +48,14 @@
Track who is registered, see who has voted early, and see who actually votes on election day.
</p>
</div>
- <ul>
- <li><a href="{% url 'main:invite_friends' %}" {% if page == "friends" %}class="selected"{% endif %}>MY FRIENDS</a></li>
- <li><a href="{% url 'main:pledge' %}" {% if page == "pledge" %}class="selected"{% endif %}>PLEDGE TO VOTE</a></li>
- <li><a href="{% url 'main:register_widget' %}" {% if page == "register" %}class="selected"{% endif %}>REGISTER</a></li>
- <li><a href="javascript:void(0);" class="invite">INVITE FRIENDS</a></li>
- </ul>
+ {% block nav %}
+ <ul>
+ <li><a href="{% url 'main:invite_friends' %}" {% if page == "friends" %}class="selected"{% endif %}>MY FRIENDS</a></li>
+ <li><a href="{% url 'main:pledge' %}" {% if page == "pledge" %}class="selected"{% endif %}>PLEDGE TO VOTE</a></li>
+ <li><a href="{% url 'main:register_widget' %}" {% if page == "register" %}class="selected"{% endif %}>REGISTER</a></li>
+ <li><a href="javascript:void(0);" class="invite">INVITE FRIENDS</a></li>
+ </ul>
+ {% endblock nav %}
</header>
{% if messages %}
<div class="notification">

0 comments on commit a93cfee

Please sign in to comment.