|
1 | 1 | {% extends "account/base.html" %} |
2 | | - |
| 2 | +{% load static %} |
3 | 3 | {% load i18n %} |
4 | 4 | {% load account socialaccount %} |
5 | | - |
6 | 5 | {% block head_title %}{% trans "Sign In" %}{% endblock %} |
7 | | - |
8 | 6 | {% block content %} |
9 | 7 | <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">×</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> |
27 | 71 | </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> |
45 | 72 | </section> |
46 | 73 | {% 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