From 9e23094460e43806d1ae2ef370e73c95ba917a24 Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Fri, 4 Mar 2011 23:59:48 +0100 Subject: adding users now has custom validation --- templates/apps/membership/edit.html | 26 +++++++++++++++++++++++++- templates/apps/name/name.html | 6 +++--- templates/base.html | 14 ++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/apps/membership/edit.html b/templates/apps/membership/edit.html index 8174aea..06d033b 100644 --- a/templates/apps/membership/edit.html +++ b/templates/apps/membership/edit.html @@ -3,6 +3,30 @@ $('#wizard').formwizard({ validationEnabled: true, focusFirstInput: true, - textSubmit: "Finish" + textSubmit: "Finish", + validationOptions: { + rules: { + username: 'validUser' + } + } + }); + $('#id_username').autocomplete({ + source: "/user/search.json", + focus: function(event, ui) { + $('#id_username').val(ui.item.label); + return false; + }, + select: function(event, ui) { + $('#id_username').val(ui.item.label); + $('#id_user').val(ui.item.value); + return false; + }, + minLength: 2, + open: function() { + $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); + }, + close: function() { + $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); + } }); {% endblock %} \ No newline at end of file diff --git a/templates/apps/name/name.html b/templates/apps/name/name.html index 01de064..f8d667a 100644 --- a/templates/apps/name/name.html +++ b/templates/apps/name/name.html @@ -60,13 +60,13 @@

{{m.user|lastidentifier}}

- {{m.user|userdisplay}} ({{m.user|lastidentifier}}) became a member of {{name.shortname}} {{m.timecreated|datehumanize}} - and has the following role{{m.tags|pluralize}}: + {{m.user|userdisplay}} ({{m.user|lastidentifier}}) became a member of {{name.shortname}} {{m.timecreated|datehumanize}} + {% if m.tags %}and has the following role{{m.tags|pluralize}}:
    {% for tag in m.tags %}
  • {{ tag|escape }}
  • {% endfor %} -
+ {%endif%}.
    diff --git a/templates/base.html b/templates/base.html index bb59dda..64024e4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -40,6 +40,20 @@ $(input).addClass("ui-state-default"); } }); + + function validUser(value,element) { + var valid = false; + $.ajax({ + url: "/user/info/"+value+".json", + async: false, + dataType: 'json', + success: function (json) { + valid = true; + } + }); + return valid; + } + $.validator.addMethod("validUser", validUser, "Please enter a valid user."); }); {% block js %}{% endblock %} -- cgit v1.1