PageRenderTime 31ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/user/register.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 171 lines | 151 code | 18 blank | 2 comment | 4 complexity | b0af4b096aa2c0af96f4aff5e8cfbdb8 MD5 | raw file
  1. <%inherit file="/base.mako"/>
  2. <%namespace file="/message.mako" import="render_msg" />
  3. %if redirect_url:
  4. <script type="text/javascript">
  5. top.location.href = '${redirect_url | h}';
  6. </script>
  7. %endif
  8. <%def name="javascripts()">
  9. ${parent.javascripts()}
  10. </%def>
  11. %if not redirect_url and message:
  12. ${render_msg( message, status )}
  13. %endif
  14. ## An admin user may be creating a new user account, in which case we want to display the registration form.
  15. ## But if the current user is not an admin user, then don't display the registration form.
  16. %if trans.user_is_admin() or not trans.user:
  17. ${render_registration_form()}
  18. %if trans.app.config.get( 'terms_url', None ) is not None:
  19. <br/>
  20. <p>
  21. <a href="${trans.app.config.get('terms_url', None)}">Terms and Conditions for use of this service</a>
  22. </p>
  23. %endif
  24. %endif
  25. <%def name="render_registration_form( form_action=None )">
  26. <%
  27. if form_action is None:
  28. form_action = h.url_for( controller='user', action='create', cntrller=cntrller )
  29. from galaxy.web.form_builder import CheckboxField
  30. subscribe_check_box = CheckboxField( 'subscribe' )
  31. %>
  32. <script type="text/javascript">
  33. $(document).ready(function() {
  34. function validateString(test_string, type) {
  35. var mail_re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  36. //var mail_re_RFC822 = /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/;
  37. var username_re = /^[a-z0-9\-]{3,255}$/;
  38. if (type === 'email') {
  39. return mail_re.test(test_string);
  40. } else if (type === 'username'){
  41. return username_re.test(test_string);
  42. }
  43. }
  44. function renderError(message) {
  45. if ($(".errormessage").length === 1) {
  46. $(".errormessage").html(message)
  47. } else {
  48. var div = document.createElement("div");
  49. div.className = "errormessage";
  50. div.innerHTML = message;
  51. document.body.insertBefore(div, document.body.firstChild);
  52. }
  53. }
  54. $('#registration').bind('submit', function(e) {
  55. $('#send').attr('disabled', 'disabled');
  56. // we need this value to detect submitting at backend
  57. var hidden_input = '<input type="hidden" id="create_user_button" name="create_user_button" value="Submit"/>';
  58. $("#email_input").before(hidden_input);
  59. var error_text_email= 'Please enter your valid email address';
  60. var error_text_email_long= 'Email cannot be more than 255 characters in length';
  61. var error_text_username_characters = 'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 3.';
  62. var error_text_password_short = 'Please use a password of at least 6 characters';
  63. var error_text_password_match = "Passwords don't match";
  64. var validForm = true;
  65. var email = $('#email_input').val();
  66. var name = $('#name_input').val();
  67. if (email.length > 255){ renderError(error_text_email_long); validForm = false;}
  68. else if (!validateString(email,"email")){ renderError(error_text_email); validForm = false;}
  69. else if (!($('#password_input').val() === $('#password_check_input').val())){ renderError(error_text_password_match); validForm = false;}
  70. else if ($('#password_input').val().length < 6 ){ renderError(error_text_password_short); validForm = false;}
  71. else if (name && !(validateString(name,"username"))){ renderError(error_text_username_characters); validForm = false;}
  72. if (!validForm) {
  73. e.preventDefault();
  74. // reactivate the button if the form wasn't submitted
  75. $('#send').removeAttr('disabled');
  76. }
  77. });
  78. });
  79. </script>
  80. <div class="toolForm">
  81. <form name="registration" id="registration" action="${form_action}" method="post" >
  82. <div class="toolFormTitle">Create account</div>
  83. <div class="form-row">
  84. <label>Email address:</label>
  85. <input id="email_input" type="text" name="email" value="${email | h}" size="40"/>
  86. <input type="hidden" name="redirect" value="${redirect | h}" size="40"/>
  87. </div>
  88. <div class="form-row">
  89. <label>Password:</label>
  90. <input id="password_input" type="password" name="password" value="" size="40"/>
  91. </div>
  92. <div class="form-row">
  93. <label>Confirm password:</label>
  94. <input id="password_check_input" type="password" name="confirm" value="" size="40"/>
  95. </div>
  96. <div class="form-row">
  97. <label>Public name:</label>
  98. <input id="name_input" type="text" name="username" size="40" value="${username |h}"/>
  99. %if t.webapp.name == 'galaxy':
  100. <div class="toolParamHelp" style="clear: both;">
  101. Your public name is an identifier that will be used to generate addresses for information
  102. you share publicly. Public names must be at least four characters in length and contain only lower-case
  103. letters, numbers, and the '-' character.
  104. </div>
  105. %else:
  106. <div class="toolParamHelp" style="clear: both;">
  107. Your public name provides a means of identifying you publicly within this tool shed. Public
  108. names must be at least four characters in length and contain only lower-case letters, numbers,
  109. and the '-' character. You cannot change your public name after you have created a repository
  110. in this tool shed.
  111. </div>
  112. %endif
  113. </div>
  114. <div class="form-row">
  115. <label>Join Our Cistrome Google Group:</label>
  116. <a href="http://groups.google.com/group/cistrome">http://groups.google.com/group/cistrome</a>
  117. </div>
  118. %if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) > 1:
  119. <div class="form-row">
  120. <label>User type</label>
  121. ${user_type_fd_id_select_field.get_html()}
  122. </div>
  123. %endif
  124. %if user_type_form_definition:
  125. %for field in widgets:
  126. <div class="form-row">
  127. <label>${field['label']}</label>
  128. ${field['widget'].get_html()}
  129. <div class="toolParamHelp" style="clear: both;">
  130. ${field['helptext']}
  131. </div>
  132. <div style="clear: both"></div>
  133. </div>
  134. %endfor
  135. %if not user_type_fd_id_select_field:
  136. <input type="hidden" name="user_type_fd_id" value="${trans.security.encode_id( user_type_form_definition.id )}"/>
  137. %endif
  138. %endif
  139. <div id="for_bears">
  140. If you see this, please leave following field blank.
  141. <input type="text" name="bear_field" size="1" value=""/>
  142. </div>
  143. <div class="form-row">
  144. <input type="submit" id="send" name="create_user_button" value="Submit"/>
  145. </div>
  146. </form>
  147. %if registration_warning_message:
  148. <div class="alert alert-danger" style="margin: 30px 12px 12px 12px;">
  149. ${registration_warning_message}
  150. </div>
  151. %endif
  152. </div>
  153. </%def>