manage_users.html 3.79 KB
Newer Older
1
<%inherit file="base.html" />
2
<%block name="title">Course Team Settings</%block>
3
<%block name="bodyclass">is-signedin course users settings team</%block>
4

5 6

<%block name="content">
7
<div class="wrapper-mast wrapper">
8
  <header class="mast has-actions has-subtitle">
9
    <div class="title">
10 11
      <span class="title-sub">Course Settings</span>
      <h1 class="title-1">Course Team</h1>
12 13 14 15 16 17 18
    </div>

    <nav class="nav-actions">
      <h3 class="sr">Page Actions</h3>
      <ul>
        %if allow_actions:
        <li class="nav-item">
19
          <a href="#" class="button new-button new-user-button"><i class="ss-icon ss-symbolicons-standard icon icon-create">&#x002B;</i> New User</a>
20 21 22 23 24 25 26
        </li>
        %endif
      </ul>
    </nav>
  </header>
</div>

27 28
<div class="main-wrapper">
  <div class="inner-wrapper">
29

30 31 32 33 34
    <div class="details">
      <p>The following list of users have been designated as course staff. This means that these users will have permissions to modify course content. You may add additional course staff below, if you are the course instructor. Please note that they must have already registered and verified their account.</p>
    </div>

    <article class="user-overview">           
35 36
      %if allow_actions:
      <form class="new-user-form">
37 38 39
        <div id="result"></div>
        <div class="form-elements">
          <label>email: </label><input type="text" id="email" class="email-input" autocomplete="off" placeholder="email@example.com">
40 41
          <input type="submit" value="Add User" id="add_user" class="add-button" />
          <input type="button" value="Cancel" class="cancel-button" />
42
        </div>
43
      </form>
44
      %endif
45 46 47 48 49 50
      <div>
        <ol class="user-list">
          % for user in staff:
          <li>
            <span class="user-name">${user.username}</span>
            <span class="user-email">${user.email}</span>
51
            %if allow_actions :
52
            <div class="item-actions">
53 54 55
              %if request_user_id != user.id:
              <a href="#" class="delete-button remove-user" data-id="${user.email}"><span class="delete-icon"></span></a>
              %endif
56
            </div>
57
            %endif
58 59 60 61 62
          </li>
          % endfor
        </ol>
      </div>
    </article>
63
  </div>
64
</div>
65
</%block>
66 67 68

<%block name="jsextra">
<script type="text/javascript">
69 70 71 72 73
  var $newUserForm;

  function showNewUserForm(e) {
    e.preventDefault();
    $newUserForm.slideDown(150);
74
    $newUserForm.find('.email-input').focus();
75 76 77 78 79
  }

  function hideNewUserForm(e) {
    e.preventDefault();
    $newUserForm.slideUp(150);
80 81
    $('#result').hide();
    $('#email').val('');
82 83
  }

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  function checkForCancel(e) {
    if(e.which == 27) {
      e.data.$cancelButton.click();
    }
  }

  function addUser(e) {
    e.preventDefault();

    $.ajax({
      url: '${add_user_postback_url}',
      type: 'POST',
      dataType: 'json',
      contentType: 'application/json',
      data:JSON.stringify({ 'email': $('#email').val()}),
    }).done(function(data) {
      if (data.ErrMsg != undefined)
        $('#result').show().empty().append(data.ErrMsg);
      else
        location.reload();
    });
  }

107
  $(document).ready(function() {
108
    $newUserForm = $('.new-user-form');
109 110 111
    var $cancelButton = $newUserForm.find('.cancel-button');    
    $newUserForm.bind('submit', addUser);
    $cancelButton.bind('click', hideNewUserForm);
112 113

    $('.new-user-button').bind('click', showNewUserForm);
Don Mitchell committed
114
    $('body').bind('keyup', { $cancelButton: $cancelButton }, checkForCancel);
115

116 117 118 119 120 121 122 123 124 125 126
    $('.remove-user').click(function() {
      $.ajax({
        url: '${remove_user_postback_url}',
        type: 'POST',
        dataType: 'json',
        contentType: 'application/json',
        data:JSON.stringify({ 'email': $(this).data('id')}),          
        }).done(function() {
          location.reload();
        })
    });
127 128
  });
</script>
Lyla Fischer committed
129
</%block>