Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 1 | {% extends "admin/base_site_login.html" %} |
| 2 | {% load i18n admin_static %} |
| 3 | |
| 4 | {% block extrastyle %}{{ block.super }} |
| 5 | <link rel="stylesheet" type="text/css" href="/static/suit/bootstrap/css/bootstrap.min.css" media="all"/> |
| 6 | <link rel="stylesheet" type="text/css" href="{% static "planetstack.css" %}" /> |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 7 | <script src="{% static 'suit/js/jquery-1.9.1.min.js' %}"></script> |
| 8 | <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script> |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 9 | {% endblock %} |
| 10 | |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 11 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 12 | {% block bodyclass %}login{% endblock %} |
| 13 | |
| 14 | {% block nav-global %}{% endblock %} |
| 15 | |
| 16 | {% block content_title %}{% endblock %} |
| 17 | |
| 18 | {% block breadcrumbs %}{% endblock %} |
| 19 | |
| 20 | {% block content %} |
| 21 | {% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %} |
| 22 | <p class="errornote"> |
| 23 | {% blocktrans count counter=form.errors.items|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} |
| 24 | </p> |
| 25 | {% endif %} |
| 26 | |
| 27 | {% if form.non_field_errors or form.this_is_the_login_form.errors %} |
Scott Baker | b418d19 | 2015-01-05 16:10:57 -0800 | [diff] [blame] | 28 | {% for error in form.non_field_errors %} |
| 29 | <p class="errornote"> |
| 30 | {{ error }} |
| 31 | </p> |
| 32 | {% endfor %} |
| 33 | {% for error in form.this_is_the_login_form.errors %} |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 34 | <p class="errornote"> |
| 35 | {{ error }} |
| 36 | </p> |
| 37 | {% endfor %} |
| 38 | {% endif %} |
| 39 | <div id="wrap"> |
| 40 | <div id="content-main"> |
| 41 | <h1><i class="icon-lock icon-white"></i> OpenCloud</h1> |
| 42 | <form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %} |
| 43 | <div class="form-row"> |
| 44 | {% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %} |
| 45 | {{ form.username }} |
| 46 | </div> |
| 47 | <div class="form-row"> |
| 48 | {% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %} |
| 49 | {{ form.password }} |
| 50 | <input type="hidden" name="this_is_the_login_form" value="1" /> |
| 51 | <input type="hidden" name="next" value="{{ next }}" /> |
| 52 | </div> |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 53 | <div class="submit-row"> |
| 54 | <input type="submit" class="btn btn-info" value="{% trans 'SIGN IN' %}" /> |
| 55 | </div> |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 56 | <div id="requestAccountLink">{% trans 'Request a new Account' %}</div> |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 57 | </form> |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 58 | |
| 59 | <div id="request-account-form" title="Request an Account" style="display: none;"> |
| 60 | <form> |
| 61 | <fieldset> |
| 62 | <div class="request-form-row"> |
| 63 | <label for="request-first-name">First Name</label> |
| 64 | <input type="text" name="request-first-name" id="request-first-name"> |
| 65 | </div> |
| 66 | <div class="request-form-row"> |
| 67 | <label for="request-last-name">Last Name</label> |
| 68 | <input type="text" name="request-last-name" id="request-last-name"> |
| 69 | </div> |
| 70 | <div class="request-form-row"> |
| 71 | <label for="request-email">Email</label> |
| 72 | <input type="text" name="request-email" id="request-email"> |
| 73 | </div> |
| 74 | <div class="request-form-row"> |
| 75 | <label for="request-site-name">Site</label><br> |
| 76 | <select id="request-site-name" name="request-site-name"> |
Scott Baker | 5face3a | 2014-08-05 10:15:26 -0700 | [diff] [blame] | 77 | <option>---------</option> |
| 78 | {% for site in sites %} |
| 79 | {% if site.allowNewUsers %} |
| 80 | <option>{{ site.name }}</option> |
| 81 | {% endif %} |
| 82 | {% endfor %} |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 83 | </select> |
| 84 | </div> |
| 85 | <div class="submit-row"> |
| 86 | <input id ="request-signup" class="btn btn-info" value="SIGN UP"> |
| 87 | </div> |
| 88 | </fieldset> |
| 89 | </form> |
| 90 | </div> |
| 91 | </div> |
| 92 | </div> |
| 93 | |
| 94 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 95 | <script type="text/javascript"> |
Scott Baker | 6985cd5 | 2014-08-05 09:51:40 -0700 | [diff] [blame] | 96 | $(function() { |
| 97 | initRequest(); |
| 98 | }); |
| 99 | function initRequest(){ |
| 100 | $.ajax({ |
| 101 | url: '/tenantview', |
| 102 | dataType: 'json', |
| 103 | success: function (data) { |
| 104 | var sites = data['sitesToBeRequested']; |
| 105 | console.log(sites); |
| 106 | for (site in sites){ |
| 107 | $("#request-site-name").append("<option>" + site + "</option>"); |
| 108 | } |
| 109 | } |
| 110 | }); |
| 111 | } |
| 112 | $("#requestAccountLink").unbind().click(function(){ |
| 113 | $("#request-account-form").dialog({ |
| 114 | autoOpen: false, |
| 115 | modal: true, |
| 116 | dialogClass: "requestDialog", |
| 117 | }); |
| 118 | $("#request-account-form").dialog("open"); |
| 119 | }) |
| 120 | $("#request-signup").unbind().click(function(){ |
| 121 | $.ajax({ |
| 122 | url: '/requestaccess/', |
| 123 | dataType: 'json', |
| 124 | data: { |
| 125 | email: $("#request-email").val(), |
| 126 | firstname: $("#request-first-name").val(), |
| 127 | lastname: $("#request-last-name").val(), |
| 128 | site: $("#request-site-name").val(), |
| 129 | csrfmiddlewaretoken: "{{ csrf_token }}", // < here |
| 130 | state: "inactive" |
| 131 | }, |
| 132 | async: false, |
| 133 | type: 'POST', |
| 134 | success: function () { |
| 135 | $("#request-account-form").dialog("close"); |
| 136 | alert("Your request has been submitted"); |
| 137 | }, |
| 138 | error:function (xhr, textStatus, thrownError){ |
| 139 | alert("Error:", textStatus + " " + xhr.responseText); |
| 140 | } |
| 141 | }); |
| 142 | }) |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 143 | document.getElementById('id_username').focus() |
| 144 | </script> |
| 145 | </div> |
| 146 | </div> |
| 147 | {% endblock %} |