Skip to content

Commit

Permalink
Login now full supported
Browse files Browse the repository at this point in the history
  • Loading branch information
siemanko committed Jan 25, 2013
1 parent 0530c77 commit 6aaeae8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 17 deletions.
12 changes: 11 additions & 1 deletion CodeStreak/contests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ def pula(request):
else:
raise Http404

def connectrequired(request):
return _contest_list(request, True)

def contest_list(request):
return _contest_list(request, False)

def _contest_list(request, alert_login):
limit = request.GET.get('limit')
offset = request.GET.get('offset')
contests = Contest.get_all_contests(offset, limit)
Expand All @@ -68,6 +73,12 @@ def contest_list(request):
<cs:page request={request} title={title}>
<cs:header-home />
<cs:content>
{ <div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">x</button>
<h4>Error!</h4>
You need to connect with Facebook to proceed.
</div>
if alert_login else <x:frag /> }
<h2>Contest List</h2>
<cs:contest-list contests={contests} />
</cs:content>
Expand All @@ -76,7 +87,6 @@ def contest_list(request):

return HttpResponse(str(page))


@login_required
def contest_home(request, contest_id):
try:
Expand Down
19 changes: 10 additions & 9 deletions CodeStreak/static/base/css/cs-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ body {
padding: 10px 10px;
}

.navbar-text img {
max-height:30px;
.navbar-img {
max-height:18px;
width:auto;
vertical-align:middle;
border: 1px solid black;
border-radius: 4px;
-moz-border-radius: 4px;
-khtml-border-radius: 4px;
-webkit-border-radius: 4px;
margin-left:5px;
margin-right:5px;
border-radius: 3px;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
margin-left:4px;
margin-right:4px;
margin-top:0px;
margin-bottom:0px;
}
1 change: 1 addition & 0 deletions CodeStreak/static/base/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $(document).ready(function(){
$(this).button('loading');
});
});
$(".alert").alert()

facebookAppId = '377224379022058';
facebookDefaultScope = ["email", "user_about_me", "user_birthday", "user_website"];
Expand Down
2 changes: 2 additions & 0 deletions CodeStreak/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@
}),

url(r'^pula', 'CodeStreak.contests.views.pula'),

url(r'^login_required', 'CodeStreak.contests.views.connectrequired'),
)
24 changes: 17 additions & 7 deletions CodeStreak/xhpy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,30 @@ def render(self):
{self.prepended_children}
{self.getChildren()}
</ul>
{ <div class="navbar-text pull-right">
{user_displayname}
{<img src={fb_image} />
if fb_image else <x:frag />}
</div>
<ul class="nav pull-right">
{ <li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
{user_displayname}
{<img class="navbar-img" src={fb_image} />
if fb_image else <x:frag />}
</a>
<ul class="dropdown-menu" role="menu">
<li><a tabindex="-1" href="#">View Profile (coming
soon)</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="http://manticore.chu.cam.ac.uk/accounts/logout/">Log out</a></li>
</ul>
</li>
if user.is_authenticated() else
<form action="/facebook/connect/?facebook_login=1" method="post">
<li><form action="/facebook/connect/?facebook_login=1" method="post">
<input type="hidden" value="" name="next" />
<button id="facebook-button" type="button" class="btn \
btn-primary pull-right" data-loading-text="Loading..." \
onclick="F.connect(this.parentNode); return false;">
Connect with Facebook
</button>
</form>}
</form></li>}
</ul>
{<div class="navbar-text pull-right">Time left:{' '}
<span id="timeLeft" class={end_timestamp}>
00:00:00
Expand Down
6 changes: 6 additions & 0 deletions templates/registration/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head>
<meta http-equiv="REFRESH" content="0;url=/login_required">
</head>
</html>

5 changes: 5 additions & 0 deletions templates/registration/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<head>
<meta http-equiv="REFRESH" content="0;url=/">
</head>
</html>

0 comments on commit 6aaeae8

Please sign in to comment.