Skip to content

Commit bf4d12e

Browse files
Addedrquired files
1 parent 8914a0a commit bf4d12e

23 files changed

Lines changed: 376 additions & 269 deletions

oshc/authentication/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
urlpatterns = [
55
url(r'^accounts/', include('allauth.urls')),
6-
url(r'^accounts/login/profile/', views.profile, name="profile")
6+
url(r'^accounts/login/profile/', views.profile, name="profile"),
7+
url(r'^ajax/validate_username/$', views.validate_username, name='validate_username'),
78
]

oshc/authentication/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
from django.shortcuts import render
2+
from django.contrib.auth.models import User
3+
from django.http import JsonResponse
24

35

46
def profile(request):
57
return render(request, "profile.html")
8+
9+
10+
def validate_username(request):
11+
username = request.GET.get('username', None)
12+
data = {
13+
'is_present': User.objects.filter(username__iexact=username).exists()
14+
}
15+
return JsonResponse(data)

oshc/main/static/main/css/app.css

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ footer .container {
354354
border-top-right-radius: 0;
355355
}
356356

357-
.forgot-password {
357+
.form-registration .forgot-password {
358358
margin-top: 10px;
359359
}
360360

361-
.new-account {
361+
.form-registration .new-account {
362362
display: block;
363363
margin-top: 10px;
364364
}
@@ -379,26 +379,3 @@ footer .container {
379379
.form-registration button:focus {
380380
background: #0275d8;
381381
}
382-
383-
/*css for strength meter*/
384-
385-
.strength-wrapper {
386-
margin-top: -33px;
387-
}
388-
389-
.strength-wrapper .strength {
390-
float:left;
391-
width:72px;
392-
height:3px;
393-
margin-right: 3px;
394-
}
395-
396-
#passwordStrengthString {
397-
font-size: 0.8em;
398-
margin-left: -299px;
399-
font-weight: bold;
400-
}
401-
402-
.zone {
403-
display:none;
404-
}
54 KB
Loading

oshc/main/static/main/js/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(document).ready(function() {
1010
"use strict";
1111
var options = {};
1212
options.ui = {
13-
container: "#signup_form",
13+
container: "#form",
1414
showVerdictsInsideProgressBar: true,
1515
viewports: {
1616
progress: ".pwstrength_viewport_progress",
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{% extends "account/base.html" %}
2-
32
{% load i18n %}
4-
53
{% block head_title %}{% trans "Account Inactive" %}{% endblock %}
6-
74
{% block content %}
8-
<h1>{% trans "Account Inactive" %}</h1>
9-
10-
<p>{% trans "This account is inactive." %}</p>
5+
<section class="main-section">
6+
<h1 class="text-center">{% trans "Account Inactive" %}</h1>
7+
<p class="text-center">{% trans "This account is inactive." %}</p>
8+
</section>
119
{% endblock %}

oshc/main/templates/account/email.html

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,75 @@
11
{% extends "account/base.html" %}
2-
32
{% load i18n %}
4-
53
{% block head_title %}{% trans "Account" %}{% endblock %}
6-
74
{% block content %}
8-
<h1>{% trans "E-mail Addresses" %}</h1>
9-
{% if user.emailaddress_set.all %}
10-
<p>{% trans 'The following e-mail addresses are associated with your account:' %}</p>
11-
12-
<form action="{% url 'account_email' %}" class="email_list" method="post">
13-
{% csrf_token %}
14-
<fieldset class="blockLabels">
15-
16-
{% for emailaddress in user.emailaddress_set.all %}
17-
<div class="ctrlHolder">
18-
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
19-
20-
<input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
21-
22-
{{ emailaddress.email }}
23-
{% if emailaddress.verified %}
24-
<span class="verified">{% trans "Verified" %}</span>
5+
<section class="main-section">
6+
<h1 class="form-title text-center">{% trans "E-mail Addresses" %}</h1>
7+
{% if user.emailaddress_set.all %}
8+
<p class="text-center">{% trans 'The following e-mail addresses are associated with your account:' %}</p>
9+
<div class="container">
10+
<div class="row">
11+
<div class="col-sm-6 col-md-4 col-md-offset-4">
12+
<div class="account-wall">
13+
<form action="{% url 'account_email' %}" class="email_list" method="post">
14+
{% csrf_token %}
15+
<div class="form-registration">
16+
<fieldset class="blockLabels">
17+
{% for emailaddress in user.emailaddress_set.all %}
18+
<div class="ctrlHolder radio">
19+
<label for="email_radio_{{forloop.counter}}" class="{% if emailaddress.primary %}primary_email{%endif%}">
20+
<input id="email_radio_{{forloop.counter}}" type="radio" name="email" {% if emailaddress.primary or user.emailaddress_set.count == 1 %}checked="checked"{%endif %} value="{{emailaddress.email}}"/>
21+
{{ emailaddress.email }}
22+
{% if emailaddress.verified %}
23+
<span class="label label-success verified">{% trans "Verified" %}</span>
24+
{% else %}
25+
<span class="label label-danger unverified">{% trans "Unverified" %}</span>
26+
{% endif %}
27+
{% if emailaddress.primary %}<span class="label label-primary primary">{% trans "Primary" %}</span>{% endif %}
28+
</label>
29+
</div>
30+
{% endfor %}
31+
<div class="buttonHolder">
32+
<button class="btn btn-primary btn-lg btn-block secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
33+
<button class="btn btn-primary btn-lg btn-block secondaryAction" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
34+
<button class="btn btn-primary btn-lg btn-block primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button>
35+
</div>
36+
</fieldset>
37+
</div>
38+
</form>
39+
</div>
40+
</div>
41+
</div>
42+
</div>
2543
{% else %}
26-
<span class="unverified">{% trans "Unverified" %}</span>
44+
<p class="text-center"><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p>
2745
{% endif %}
28-
{% if emailaddress.primary %}<span class="primary">{% trans "Primary" %}</span>{% endif %}
29-
</label>
30-
</div>
31-
{% endfor %}
32-
33-
<div class="buttonHolder">
34-
<button class="secondaryAction" type="submit" name="action_primary" >{% trans 'Make Primary' %}</button>
35-
<button class="secondaryAction" type="submit" name="action_send" >{% trans 'Re-send Verification' %}</button>
36-
<button class="primaryAction" type="submit" name="action_remove" >{% trans 'Remove' %}</button>
37-
</div>
38-
39-
</fieldset>
40-
</form>
41-
42-
{% else %}
43-
<p><strong>{% trans 'Warning:'%}</strong> {% trans "You currently do not have any e-mail address set up. You should really add an e-mail address so you can receive notifications, reset your password, etc." %}</p>
44-
45-
{% endif %}
46-
47-
48-
<h2>{% trans "Add E-mail Address" %}</h2>
49-
50-
<form method="post" action="{% url 'account_email' %}" class="add_email">
51-
{% csrf_token %}
52-
{{ form.as_p }}
53-
<button name="action_add" type="submit">{% trans "Add E-mail" %}</button>
54-
</form>
55-
46+
<div class="container">
47+
<div class="row">
48+
<div class="col-sm-6 col-md-4 col-md-offset-4">
49+
<h2>{% trans "Add E-mail Address" %}</h2>
50+
<div class="account-wall">
51+
<form method="post" action="{% url 'account_email' %}" class="add_email form-registration">
52+
{% csrf_token %}
53+
<p class="required field-title">
54+
{% if form.email.errors %}
55+
{% for error in form.email.errors %}
56+
<div style="font-size: 12px;" class="alert alert-danger alert-dismissible" role="alert">
57+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
58+
{{ error|escape }}</div>
59+
{% endfor %}
60+
{% endif %}
61+
<label class="required" for="id_email">{% trans 'E-mail:' %}</label>
62+
<input class="form-control" type="email" name="email" size="30" placeholder="E-mail address" required id="id_email" />
63+
</p>
64+
<button class="btn btn-lg btn-primary btn-block" name="action_add" type="submit">{% trans "Add E-mail" %}</button>
65+
</form>
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
</section>
5671
{% endblock %}
57-
58-
59-
{% block extra_body %}
72+
{% block javascript %}
6073
<script type="text/javascript">
6174
(function() {
6275
var message = "{% trans 'Do you really want to remove the selected e-mail address?' %}";
Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
{% extends "account/base.html" %}
2-
32
{% load i18n %}
43
{% load account %}
5-
64
{% block head_title %}{% trans "Confirm E-mail Address" %}{% endblock %}
7-
8-
95
{% block content %}
10-
<h1>{% trans "Confirm E-mail Address" %}</h1>
11-
12-
{% if confirmation %}
13-
14-
{% user_display confirmation.email_address.user as user_display %}
15-
16-
<p>{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>
17-
18-
<form method="post" action="{% url 'account_confirm_email' confirmation.key %}">
19-
{% csrf_token %}
20-
<button type="submit">{% trans 'Confirm' %}</button>
21-
</form>
22-
23-
{% else %}
24-
25-
{% url 'account_email' as email_url %}
26-
27-
<p>{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
28-
29-
{% endif %}
30-
6+
<section class="main-section">
7+
<h1 class="text-center">{% trans "Confirm E-mail Address" %}</h1>
8+
{% if confirmation %}
9+
{% user_display confirmation.email_address.user as user_display %}
10+
<p class="text-center">{% blocktrans with confirmation.email_address.email as email %}Please confirm that <a href="mailto:{{ email }}">{{ email }}</a> is an e-mail address for user {{ user_display }}.{% endblocktrans %}</p>
11+
<form class="form-registration" method="post" action="{% url 'account_confirm_email' confirmation.key %}">
12+
{% csrf_token %}
13+
<button type="submit" class="btn btn-lg btn-primary btn-block">{% trans 'Confirm' %}</button>
14+
</form>
15+
{% else %}
16+
{% url 'account_email' as email_url %}
17+
<p class="text-center">{% blocktrans %}This e-mail confirmation link expired or is invalid. Please <a href="{{ email_url }}">issue a new e-mail confirmation request</a>.{% endblocktrans %}</p>
18+
{% endif %}
19+
</section>
3120
{% endblock %}
Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,95 @@
11
{% extends "account/base.html" %}
2-
2+
{% load static %}
33
{% load i18n %}
44
{% load account socialaccount %}
5-
65
{% block head_title %}{% trans "Sign In" %}{% endblock %}
7-
86
{% block content %}
97
<section class="main-section">
10-
<h1>{% trans "Sign In" %}</h1>
11-
12-
{% get_providers as socialaccount_providers %}
13-
14-
{% if socialaccount_providers %}
15-
<p>{% blocktrans with site.name as site_name %}Please sign in with one
16-
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
17-
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
18-
19-
<div class="socialaccount_ballot">
20-
21-
<ul class="socialaccount_providers">
22-
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
23-
</ul>
24-
25-
<div class="login-or">{% trans 'or' %}</div>
26-
8+
<div class="container">
9+
<div class="row">
10+
<div class="col-sm-6 col-md-4 col-md-offset-4">
11+
<h1 class="form-title text-center">{% trans "Sign In" %}</h1>
12+
<div class="alert alert-danger hidden" role="alert">
13+
{% trans "A user with this username don't exists." %}
14+
</div>
15+
<div class="account-wall">
16+
<img class="profile-img" src="{% static 'main/images/user.png' %}"
17+
alt="">
18+
<form class="login" method="post" action="{% url 'account_login' %}">
19+
{% csrf_token %}
20+
<div class="form-registration">
21+
<p class="required field-title">
22+
{% if form.username.errors %}
23+
{% for error in form.username.errors %}
24+
<div style="font-size: 12px;" class="alert alert-danger alert-dismissible" role="alert">
25+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
26+
{{ error|escape }}</div>
27+
{% endfor %}
28+
{% endif %}
29+
<label class="required" for="id_login">{% trans 'Username:' %}</label>
30+
<input class="form-control" type="text" name="login" placeholder="Username" autofocus="autofocus" maxlength="150" required id="id_login" />
31+
</p>
32+
<p>
33+
{% if form.password.errors %}
34+
{% for error in form.password.errors %}
35+
<div class="alert alert-danger" role="alert">{{ error|escape }}</div>
36+
{% endfor %}
37+
{% endif %}
38+
<label class="required" for="id_password">{% trans 'Password:' %}</label>
39+
<input class="form-control" type="password" name="password" placeholder="Password" required id="id_password" />
40+
</p>
41+
<label class="checkbox pull-left">
42+
<input type="checkbox" name="remember" id="id_remember" value="remember-me" />
43+
<span class="clearfix"></span>
44+
Remember me
45+
</label>
46+
<a class="button secondaryAction pull-right forgot-password" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a><span class="clearfix"></span>
47+
<button class="btn btn-lg btn-primary btn-block" type="submit">{% trans 'Sign In' %}</button>
48+
</div>
49+
</form>
50+
</div>
51+
<br>
52+
{% get_providers as socialaccount_providers %}
53+
{% if socialaccount_providers %}
54+
<p>
55+
{% blocktrans with site.name as site_name %}
56+
Please sign in with one of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
57+
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
58+
<div class="socialaccount_ballot">
59+
<ul class="socialaccount_providers">
60+
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
61+
</ul>
62+
<div class="login-or">{% trans 'or' %}</div>
63+
</div>
64+
{% include "socialaccount/snippets/login_extra.html" %}
65+
{% else %}
66+
<p class="text-center">{% blocktrans %}If you have not created an account yet, then please
67+
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
68+
{% endif %}
69+
</div>
70+
</div>
2771
</div>
28-
29-
{% include "socialaccount/snippets/login_extra.html" %}
30-
31-
{% else %}
32-
<p>{% blocktrans %}If you have not created an account yet, then please
33-
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
34-
{% endif %}
35-
36-
<form class="login" method="POST" action="{% url 'account_login' %}">
37-
{% csrf_token %}
38-
{{ form.as_p }}
39-
{% if redirect_field_value %}
40-
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
41-
{% endif %}
42-
<a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
43-
<button class="primaryAction" type="submit">{% trans "Sign In" %}</button>
44-
</form>
4572
</section>
4673
{% endblock %}
74+
{% block javascript %}
75+
<script>
76+
$("#id_login").change(function() {
77+
var username = $(this).val();
78+
$.ajax({
79+
url: '/ajax/validate_username/',
80+
data: {
81+
'username': username
82+
},
83+
dataType: 'json',
84+
success: function(data) {
85+
if (data.is_present == false) {
86+
$(".alert").removeClass("hidden");
87+
setTimeout(function(){
88+
$(".alert").addClass("hidden");
89+
}, 5000);
90+
}
91+
}
92+
});
93+
});
94+
</script>
95+
{% endblock %}

0 commit comments

Comments
 (0)