Skip to content

Commit

Permalink
Separated login.html and language_selection.html
Browse files Browse the repository at this point in the history
  • Loading branch information
ykdojo committed Dec 11, 2018
1 parent 1a9fdfa commit d3ac7dc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
33 changes: 33 additions & 0 deletions templates/language_selection.html
@@ -0,0 +1,33 @@
{% extends 'base.html' %}

{% load socialaccount %}

{% block content %}
<!-- The assumption of this page is that user is logged in already. -->
<div class="container">
<div class="card col-lg-6 col-md-6 ml-auto mr-auto">
<h3>Select your languages</h3>
<form>
<label for="learning">I'm learning...</label>
<div id="learning-select">
<select class="custom-select ed-select" id="learning1">
<option>Select Your Language</option>
<option>English</option>
<option>Japanese</option>
</select>
</div>
<label for="fluent">I'm fluent in...</label>
<div id="fluent-select">
<select class="custom-select ed-select" id="fluent1">
<option>Select Your Language</option>
<option>English</option>
<option>Japanese</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<p></p>
</div>
</div>
<script src="static/js/language_selection.js" type="text/javascript"></script>
{% endblock content %}
31 changes: 2 additions & 29 deletions templates/login.html
Expand Up @@ -3,34 +3,8 @@
{% load socialaccount %}

{% block content %}
{% if user.is_authenticated %}
<div class="container">
<div class="card col-lg-6 col-md-6 ml-auto mr-auto">
<h3>Select your languages</h3>
<form>
<label for="learning">I'm learning...</label>
<div id="learning-select">
<select class="custom-select ed-select" id="learning1">
<option>Select Your Language</option>
<option>English</option>
<option>Japanese</option>
</select>
</div>
<label for="fluent">I'm fluent in...</label>
<div id="fluent-select">
<select class="custom-select ed-select" id="fluent1">
<option>Select Your Language</option>
<option>English</option>
<option>Japanese</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<p></p>
</div>
</div>
<script src="static/js/language_selection.js" type="text/javascript"></script>
{% else %}
<!-- NOTE: the assumption of this template is that
the user is not logged in yet.-->
<nav
class="navbar navbar-transparent fixed-top navbar-expand-lg"
color-on-scroll="100"
Expand Down Expand Up @@ -143,5 +117,4 @@ <h3 class="title">How it works</h3>
});
});
</script>
{% endif %}
{% endblock content %}
8 changes: 6 additions & 2 deletions users/views.py
Expand Up @@ -10,10 +10,14 @@ def login(request):
if not current_user.is_authenticated:
return render(request, 'login.html')

# If the user is authenticated, first, follow them on Twitter.
# TODO: store some info about if we already follow them or not.
twitter_account = SocialAccount.objects.filter(user = current_user)[0]
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
api.create_friendship(twitter_account.uid)
# TODO: store some info about if we already follow them or not.
return render(request, 'login.html')

# Then, show them the language selection page
# TODO: Only show this if they haven't selected languages yet.
return render(request, 'language_selection.html')

0 comments on commit d3ac7dc

Please sign in to comment.