return an error when trying to register a deleted user
[plstackapi.git] / planetstack / templates / admin / login.html
index ab066dc..29534db 100644 (file)
 {% endif %}
 
 {% if form.non_field_errors or form.this_is_the_login_form.errors %}
-{% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
+{% for error in form.non_field_errors %}
+<p class="errornote">
+    {{ error }}
+</p>
+{% endfor %}
+{% for error in form.this_is_the_login_form.errors %}
 <p class="errornote">
     {{ error }}
 </p>
                         <div class="request-form-row">
                                 <label for="request-site-name">Site</label><br>
                                <select id="request-site-name" name="request-site-name">
-                                        <option>---------</option>
-                                        <option>Stanford</option>
-                                        <option>Washington</option>
-                                        <option>Princeton</option>
-                                        <option>GeorgiaTech</option>
-                                        <option>MaxPlanck</option>
-                                        <option>I2 Atlanta</option>
-                                        <option>I2 Chicago</option>
-                                        <option>I2 Houston</option>
-                                        <option>I2 Kansas City</option>
-                                        <option>I2 Los Angeles</option>
-                                        <option>I2 New York</option>
-                                        <option>I2 Salt Lake City</option>
-                                        <option>I2 Seattle</option>
-                                        <option>I2 Washington DC</option>
-                                        <option>ON.Lab</option>
-                                        <option>I2 Singapore</option>
-                                        <option>Arizona</option>
+                                    <option>---------</option>
+                                    {% for site in sites %}
+                                        {% if site.allowNewUsers %}
+                                            <option>{{ site.name }}</option>
+                                        {% endif %}
+                                    {% endfor %}
                                </select>
                         </div>
                        <div class="submit-row">
@@ -138,9 +131,21 @@ $("#request-signup").unbind().click(function(){
                                                                },
                                                                async: false,
                                                                type: 'POST',
-                                                               success: function () {
-                                                                       $("#request-account-form").dialog("close");     
-                                                                       alert("Your request has been submitted");                                                       
+                                                               success: function (response) {
+                                                                    if (response && response.error) {
+                                                                        if (response.error == "already_approved") {
+                                                                            alert("Your request has already been proccessed and approved. We are sending you another email with a new temporary password");
+                                                                            return;
+                                                                        } else if (response.error == "already_pending") {
+                                                                            alert("Your request is already pending and awaiting approval");
+                                                                            return;
+                                                                        } else if (response.error == "is_deleted") {
+                                                                            alert("Your user record is in a deleted state. Please contact OpenCloud support");
+                                                                            return;
+                                                                        }
+                                                                    }
+                                                                   $("#request-account-form").dialog("close");
+                                                                   alert("Your request has been submitted");
                                                                },
                                                                error:function (xhr, textStatus, thrownError){
                                                                   alert("Error:", textStatus + " " + xhr.responseText);