303 lines
10 KiB
HTML
303 lines
10 KiB
HTML
<%! from django.utils.translation import ugettext as _ %>
|
|
<%! from django.core.urlresolvers import reverse %>
|
|
<%! from auth.authz import is_user_in_course_group_role %>
|
|
<%inherit file="base.html" />
|
|
<%block name="title">${_("Course Team Settings")}</%block>
|
|
<%block name="bodyclass">is-signedin course users team</%block>
|
|
|
|
|
|
<%block name="content">
|
|
<div class="wrapper-mast wrapper">
|
|
<header class="mast has-actions has-subtitle">
|
|
<h1 class="page-header">
|
|
<small class="subtitle">${_("Course Settings")}</small>
|
|
<span class="sr">> </span>${_("Course Team")}
|
|
</h1>
|
|
|
|
<nav class="nav-actions">
|
|
<h3 class="sr">${_("Page Actions")}</h3>
|
|
<ul>
|
|
%if allow_actions:
|
|
<li class="nav-item">
|
|
<a href="#" class="button new-button create-user-button"><i class="icon-plus"></i> ${_("New User")}</a>
|
|
</li>
|
|
%endif
|
|
</ul>
|
|
</nav>
|
|
</header>
|
|
</div>
|
|
|
|
<div class="wrapper-content wrapper">
|
|
<section class="content">
|
|
<div class="introduction">
|
|
<h2 class="title sr">Managing Your Course Team</h2>
|
|
<div class="copy">
|
|
<p>${_("[Introduction Message - Mark to Provide Copy.] Maecenas faucibus mollis interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit libero, a pharetra augue.")}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<article class="content-primary" role="main">
|
|
%if allow_actions:
|
|
<div class="wrapper-create-element animate wrapper-create-user">
|
|
<form class="create-user" id="create-user-form" name="create-user-form">
|
|
<div class="wrapper-form">
|
|
<h3 class="title">${_("Add a User to Your Course's Team")}</h3>
|
|
|
|
<fieldset class="form-fields">
|
|
<legend class="sr">${_("Textbook information")}</legend>
|
|
<ol class="list-input">
|
|
<li class="field text required create-user-email">
|
|
<label for="user-email-input">${_("User's Email Address")}</label>
|
|
<input id="user-email-input" name="user-email" type="text" placeholder="${_('e.g. jane.doe@gmail.com')}" value="">
|
|
<span class="tip tip-stacked">${_("Please provide the email address of the course staff member you'd like to add")}</span>
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
</div>
|
|
<div class="actions">
|
|
<button class="action action-primary" type="submit">${_("Add User")}</button>
|
|
<button class="action action-secondary action-cancel">${_("Cancel")}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
%endif
|
|
|
|
<ol class="user-list">
|
|
% for user in staff:
|
|
<li class="user-item" data-url="${reverse('course_team_user', kwargs=dict(
|
|
org=context_course.location.org,
|
|
course=context_course.location.course,
|
|
name=context_course.location.name,
|
|
email=user.email,
|
|
))}">
|
|
|
|
<% is_instuctor = is_user_in_course_group_role(user, context_course.location, 'instructor', check_staff=False) %>
|
|
% if is_instuctor:
|
|
<span class="wrapper-ui-badge">
|
|
<span class="flag flag-role flag-role-admin is-hanging">
|
|
<span class="label sr">${_("Current Role:")}</span>
|
|
<span class="value">
|
|
${_("Admin")}
|
|
% if request.user.id == user.id:
|
|
<span class="msg-you">${_("You!")}</span>
|
|
% endif
|
|
</span>
|
|
</span>
|
|
</span>
|
|
% else:
|
|
<span class="wrapper-ui-badge">
|
|
<span class="flag flag-role flag-role-staff is-hanging">
|
|
<span class="label sr">${_("Current Role:")}</span>
|
|
<span class="value">
|
|
${_("Staff")}
|
|
% if request.user.id == user.id:
|
|
<span class="msg-you">${_("You!")}</span>
|
|
% endif
|
|
</span>
|
|
</span>
|
|
</span>
|
|
% endif
|
|
|
|
<div class="item-metadata">
|
|
<h3 class="user-name">
|
|
<span class="user-username">${user.username}</span>
|
|
<span class="user-email">
|
|
<a class="action action-email" href="mailto:${user.email}" title="${_("send an email message to {email}").format(email=user.email)}">${user.email}</a>
|
|
</span>
|
|
</h3>
|
|
</div>
|
|
|
|
% if allow_actions:
|
|
<ul class="item-actions user-actions">
|
|
<li class="action action-role">
|
|
% if is_instuctor and len(instructors) == 1:
|
|
<span class="admin-role notoggleforyou">${_("Promote another member to remove admin access")}</span>
|
|
% else:
|
|
<a href="#" class="admin-role toggle-admin-role ${'remove' if is_instuctor else 'add'}-admin-role">${_("Remove Admin Access") if is_instuctor else _("Add Admin Access")}</a>
|
|
% endif
|
|
</li>
|
|
<li class="action action-delete ${"is-disabled" if request.user.id == user.id else ""}">
|
|
<a href="#" class="delete remove-user action-icon" data-id="${user.email}"><i class="icon-trash"></i><span class="sr">${_("Delete the user, {username}").format(username=user.username)}</span></a>
|
|
</li>
|
|
</ul>
|
|
% endif
|
|
|
|
</li>
|
|
% endfor
|
|
</ol>
|
|
</article>
|
|
|
|
<aside class="content-supplementary" role="complimentary">
|
|
<div class="bit">
|
|
<h3 class="title-3">${_("About Roles within Your Course Team")}</h3>
|
|
<p>${_("[Mark to provide copy] Maecenas faucibus mollis interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit libero, a pharetra augue.")}</p>
|
|
</div>
|
|
|
|
% if is_instuctor and len(instructors) == 1:
|
|
<div class="bit">
|
|
<h3 class="title-3">${_("Tranferring Ownership")}</h3>
|
|
<p>${_("[Mark to provide copy] Maecenas faucibus mollis interdum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.")}</p>
|
|
</div>
|
|
% endif
|
|
</aside>
|
|
</section>
|
|
</div>
|
|
</%block>
|
|
|
|
<%block name="jsextra">
|
|
<script type="text/javascript">
|
|
var tplUserURL = "${reverse('course_team_user', kwargs=dict(
|
|
org=context_course.location.org,
|
|
course=context_course.location.course,
|
|
name=context_course.location.name,
|
|
email="@@EMAIL@@",
|
|
))}"
|
|
|
|
$(document).ready(function() {
|
|
var $createUserForm = $('#create-user-form');
|
|
var $createUserFormWrapper = $createUserForm.closest('.wrapper-create-user');
|
|
$createUserForm.bind('submit', function(e) {
|
|
e.preventDefault();
|
|
var url = tplUserURL.replace("@@EMAIL@@", $('#user-email-input').val().trim())
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({
|
|
role: 'staff',
|
|
}),
|
|
success: function(data) {
|
|
location.reload();
|
|
},
|
|
notifyOnError: false,
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
var message;
|
|
try {
|
|
message = JSON.parse(jqXHR.responseText).error || "Unknown";
|
|
} catch (e) {
|
|
message = "Unknown";
|
|
}
|
|
var prompt = new CMS.Views.Prompt.Error({
|
|
title: gettext("Error adding user"),
|
|
message: message,
|
|
actions: {
|
|
primary: {
|
|
text: gettext("OK"),
|
|
click: function(view) {
|
|
view.hide();
|
|
$("#user-email-input").focus()
|
|
}
|
|
}
|
|
}
|
|
})
|
|
prompt.show();
|
|
}
|
|
});
|
|
});
|
|
|
|
var $cancelButton = $createUserForm.find('.action-cancel');
|
|
$cancelButton.bind('click', function(e) {
|
|
e.preventDefault();
|
|
$('.create-user-button').removeClass('is-disabled');
|
|
$createUserFormWrapper.toggleClass('is-shown');
|
|
$('#user-email-input').val('');
|
|
});
|
|
|
|
$('.create-user-button').bind('click', function(e) {
|
|
e.preventDefault();
|
|
$(this).addClass('is-disabled');
|
|
$createUserFormWrapper.toggleClass('is-shown');
|
|
$createUserForm.find('#user-email-input').focus();
|
|
});
|
|
|
|
$('body').bind('keyup', function(e) {
|
|
if(e.which == 27) {
|
|
$cancelButton.click();
|
|
}
|
|
});
|
|
|
|
$('.remove-user').click(function() {
|
|
var url = tplUserURL.replace("@@EMAIL@@", $(this).data('id'))
|
|
$.ajax({
|
|
url: url,
|
|
type: 'DELETE',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
success: function(data) {
|
|
location.reload();
|
|
},
|
|
notifyOnError: false,
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
var message;
|
|
try {
|
|
message = JSON.parse(jqXHR.responseText).error || "Unknown";
|
|
} catch (e) {
|
|
message = "Unknown";
|
|
}
|
|
var prompt = new CMS.Views.Prompt.Error({
|
|
title: gettext("Error removing user"),
|
|
message: message,
|
|
actions: {
|
|
primary: {
|
|
text: gettext("OK"),
|
|
click: function(view) {
|
|
view.hide();
|
|
}
|
|
}
|
|
}
|
|
})
|
|
prompt.show();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".toggle-admin-role").click(function(e) {
|
|
e.preventDefault()
|
|
var type;
|
|
if($(this).hasClass("add-admin-role")) {
|
|
role = 'instructor';
|
|
} else {
|
|
role = 'staff';
|
|
}
|
|
var url = $(this).closest("li[data-url]").data("url");
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({
|
|
role: role
|
|
}),
|
|
success: function(data) {
|
|
location.reload();
|
|
},
|
|
notifyOnError: false,
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
var message;
|
|
try {
|
|
message = JSON.parse(jqXHR.responseText).error || "Unknown";
|
|
} catch (e) {
|
|
message = "Unknown";
|
|
}
|
|
var prompt = new CMS.Views.Prompt.Error({
|
|
title: gettext("Error changing user"),
|
|
message: message,
|
|
actions: {
|
|
primary: {
|
|
text: gettext("OK"),
|
|
click: function(view) {
|
|
view.hide();
|
|
}
|
|
}
|
|
}
|
|
})
|
|
prompt.show();
|
|
}
|
|
})
|
|
})
|
|
|
|
});
|
|
</script>
|
|
</%block>
|