<%! from django.utils.translation import ugettext as _ %>

<%inherit file="main.html" />
<script>
function name_confirm(id) {
  $.post('/accept_name_change',{"id":id},
            function(data){
          if(data.success){
            $("#div"+id).html("${_('Accepted')}");
          } else {
            alert("${_('Error')}");
          }
     });
}

function name_deny(id) {
  $.post('/reject_name_change',{"id":id},
            function(data){
          if(data.success){
            $("#div"+id).html("${_('Rejected')}");
          } else {
            alert("${_('Error')}");
          }
     });
}
</script>

<section class="container">
<div class="gradebook-wrapper">
  <section class="gradebook-content">
  <h1>${_("Pending name changes")}</h1>
  <table>
  % for s in students:
  <tr>
    <td><a href="/profile/${s['uid']}"/>${s['old_name']}</td>
    <td>${s['new_name']|h}</td>
    <td>${s['email']|h}</td>
    <td>${s['rationale']|h}</td>
    <td><span id="div${s['cid']}"><span onclick="name_confirm(${s['cid']});">[${_("Confirm")}]</span>
    <span onclick="name_deny(${s['cid']});">[${_("Reject")}]</span></span></td></tr>
  % endfor
  </table>
  </section>
</div>
</section>
