hydra/src/root/user.tt

172 lines
5.1 KiB
Plaintext
Raw Normal View History

2013-11-05 13:02:04 +00:00
[% WRAPPER layout.tt title=(create ? "Add new user" : "Editing user $user.username") %]
2010-12-03 09:40:25 +00:00
[% PROCESS common.tt %]
[% BLOCK roleoption %]
2013-02-27 17:33:47 +00:00
<option value="[% role %]"
[% checked = false %]
[% FOREACH r IN user.userroles %]
[% checked = r.role == role %]
[% BREAK IF checked %]
[% END %]
[% IF checked %]
selected="selected"
2013-02-27 17:33:47 +00:00
[% END %]
>[% role %]</option>
2010-12-03 09:40:25 +00:00
[% END %]
2013-11-05 13:02:04 +00:00
<form class="form-horizontal">
2013-02-27 17:33:47 +00:00
<fieldset>
2013-01-22 13:41:02 +00:00
2013-02-27 17:33:47 +00:00
[% IF create %]
<div class="control-group">
<label class="control-label">User name</label>
<div class="controls">
<input type="text" class="span3" name="username" [% HTML.attributes(value => username) %]/>
2013-02-27 17:33:47 +00:00
</div>
</div>
2013-02-27 17:33:47 +00:00
[% END %]
<div class="control-group">
<label class="control-label">Full name</label>
<div class="controls">
2013-11-05 13:02:04 +00:00
<input type="text" class="span3" name="fullname" [% HTML.attributes(value => create ? '' : user.fullname) %]/>
2013-02-27 17:33:47 +00:00
</div>
</div>
2013-02-27 17:33:47 +00:00
[% IF create || user.type == 'hydra' %]
2013-02-27 17:33:47 +00:00
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<input type="password" class="span3" name="password" value=""/>
2013-02-27 17:33:47 +00:00
</div>
</div>
2013-02-27 17:33:47 +00:00
<div class="control-group">
<label class="control-label">Confirm password</label>
<div class="controls">
<input type="password" class="span3" name="password2" value=""/>
2013-02-27 17:33:47 +00:00
</div>
</div>
[% END %]
2010-12-03 09:40:25 +00:00
2013-02-27 17:33:47 +00:00
<div class="control-group">
<label class="control-label">Email</label>
<div class="controls">
<input type="text" class="span3" name="emailaddress" [% IF !create && user.username.search('@') %]disabled="disabled"[% END %] [%+ HTML.attributes(value => user.emailaddress) %]/>
2013-02-27 17:33:47 +00:00
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
2013-11-05 13:02:04 +00:00
<input type="checkbox" name="emailonerror" [% IF !create && user.emailonerror; 'checked="checked"'; END %]/>Receive evaluation error notifications
</label>
2013-02-27 17:33:47 +00:00
</div>
</div>
2013-02-27 17:33:47 +00:00
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="publicdashboard" [% IF !create && user.publicdashboard; 'checked="checked"'; END %]/>Public dashboard
</label>
</div>
</div>
[% IF !create || c.check_user_roles('admin') %]
2013-02-27 17:33:47 +00:00
<div class="control-group">
<label class="control-label">Roles</label>
<div class="controls">
<select multiple="multiple" name="roles" class="span3" [% IF !c.check_user_roles('admin') %]disabled="disabled"[% END %]>
2013-02-27 17:33:47 +00:00
[% INCLUDE roleoption role="admin" %]
[% INCLUDE roleoption role="create-projects" %]
[% INCLUDE roleoption role="restart-jobs" %]
2013-02-27 17:33:47 +00:00
</select>
</div>
</div>
[% END %]
2013-02-27 17:33:47 +00:00
[% IF create && !c.check_user_roles('admin') %]
2013-02-27 17:33:47 +00:00
<div class="control-group">
<div class="controls">
<img src="[% c.uri_for('/captcha') %]" alt="CAPTCHA"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Type the digits shown in the image above</label>
<div class="controls">
<input type="text" class="span3" name="captcha" value=""/>
2013-02-27 17:33:47 +00:00
</div>
</div>
[% END %]
<div class="form-actions">
2013-11-05 13:02:04 +00:00
<button id="submit-user" class="btn btn-primary">
2013-02-27 17:33:47 +00:00
<i class="icon-ok icon-white"></i>
[%IF create %]Create[% ELSE %]Apply changes[% END %]
</button>
[% IF !create && c.check_user_roles('admin') && user.type == 'hydra' %]
2013-11-05 13:02:04 +00:00
<button id="reset-password" class="btn btn-warning">
<i class="icon-trash icon-white"></i>
Reset password
</button>
[% END %]
2013-02-27 17:33:47 +00:00
[% IF !create %]
2013-11-05 13:02:04 +00:00
<button id="delete-user" class="btn btn-danger">
2013-02-27 17:33:47 +00:00
<i class="icon-trash icon-white"></i>
Delete this user
</button>
[% END %]
</div>
</fieldset>
2010-12-03 09:40:25 +00:00
</form>
2013-11-05 13:02:04 +00:00
<script>
$("#submit-user").click(function() {
requestJSON({
[% IF create %]
url: "[% c.uri_for(c.controller('User').action_for('register')) %]",
[% ELSE %]
url: "[% c.uri_for(c.controller('User').action_for('edit'), c.req.captures) %]",
[% END %]
data: $(this).parents("form").serialize(),
type: 'PUT',
success: backToReferrer
});
return false;
});
$("#reset-password").click(function() {
bootbox.confirm(
'Are you sure you want to reset the password for this user?',
function(c) {
if (!c) return;
requestJSON({
url: "[% c.uri_for(c.controller('User').action_for('reset_password'), [user.username]) %]",
type: 'POST',
success: backToReferrer
});
});
return false;
});
$("#delete-user").click(function() {
bootbox.confirm(
'Are you sure you want to delete this user?',
function(c) {
if (!c) return;
requestJSON({
url: "[% c.uri_for(c.controller('User').action_for('edit'), c.req.captures) %]",
type: 'DELETE',
success: backToReferrer
});
});
return false;
});
</script>
2010-12-03 09:40:25 +00:00
[% END %]