Statistics
| Branch: | Tag: | Revision:

root / djnro / templates / edumanage / realms.html @ 4772922a

History | View | Annotate | Download (4.8 kB)

1
{% extends "edumanage/welcome.html"%}
2
{% load staticfiles %}
3
{% load i18n %}
4

    
5
{% block homeactive %}{% endblock %}
6
{% block realmsactive %}class="active"{% endblock %}
7

    
8
{% block management_content %}
9
<h4>{% trans "Realms" %}</h4>
10
<hr>
11
{% if messages %}
12
<table class="table table-condensed">
13

    
14
    {% for message in messages %}
15
    <tr {% if  %} class="{{ message.tags }}"{% endif %}><td>{{ message }}<td></tr>
16
    {% endfor %}
17
</table>
18
{% endif %}
19
{% if institution.ertype == 1 or institution.ertype == 3 %}
20
  {% if realms %}
21
  <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
22
        <thead>
23
        <tr>
24
                <th>{% trans "Realm" %}</th>
25
                <th>{% trans "Server(s)" %}</th>
26
                <th style="text-align: center;">{% trans "Action" %}</th>
27
        </tr>
28
        </thead>
29
        <tbody>
30
    {% for realm in realms %}
31
          <tr class="GradeC">
32
            <td>{{realm.realm}}</td>
33
            <td>{{realm.get_servers}}</td>
34
            <td style="text-align: center;"><a href="{% url edit-realms realm.pk %}" class="btn btn-small">{% trans "edit" %}</a> <a href="#" id="del_realm_{{realm.pk}}" data-realmname="{{realm.realm}}" class="btn btn-small btn-warning">{% trans "delete" %}</a></td>
35
    </tr>
36
          {% endfor %}
37
          </tbody>
38
  </table>
39

    
40
{% endif %}
41
<div>{% if institution.ertype == 1 or institution.ertype == 3 %}<a href="{% url edit-realms %}" class="btn btn-primary">{% trans "Add new realm" %}</a>{% endif %}</div>
42
{% endif %}
43
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
44
        <div class="modal-dialog">
45
            <div class="modal-content">
46
                        <div class="modal-header">
47
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
48
                                <h3 id="myModalLabel">{% trans "Delete Realm" %}</h3>
49
                        </div>
50
                        <div class="modal-body" id="mymodalbody">
51
                        </div>
52
                        <div class="modal-footer">
53
                                <button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button>
54
                                <a class="btn btn-warning" id="delrealmSubmit" href="#">{% trans "Delete" %}</a>
55
                        </div>
56
                </div>
57
        </div>
58
</div>
59
{% endblock %}
60

    
61

    
62

    
63
{% block extrajs %}
64
<script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
65
<script type="text/javascript" src="//cdn.datatables.net/plug-ins/505bef35b56/integration/bootstrap/1/dataTables.bootstrap.js"></script>
66
<script type="text/javascript">
67
$(document).ready(function(){
68
         {% if realms %}
69
var oTable = $('#table')
70
        .on( 'init.dt', function () {
71
               $('.pagination ul').addClass('pagination');
72
    })
73
    .dataTable({
74
                "sPaginationType": "bootstrap",
75
                "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
76
                "aoColumns": [{
77
                "bSearchable": true,
78
                "bSortable": true
79
            }, {
80
                "bSearchable": true,
81
                "bSortable": true
82
            }, {
83
                "bVisible": true,
84
                "bSearchable": false,
85
                "bSortable": false
86
            }],
87
            "aaSorting": [[0, 'desc']],
88
            "iDisplayLength": 25,
89
            "oSearch": {"bSmart": false, "bRegex":true},
90
            "oLanguage": {
91
                    "sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "realms" %}',
92
                "sProcessing":   "Processing...",
93
                "sZeroRecords": '{% trans "No records to display" %}',
94
                "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
95
                "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
96
                "sInfoFiltered": "(filtered from _MAX_ total entries)",
97
                "sInfoPostFix":  "",
98
                "sSearch":       '{% trans "Search:" %}',
99
                "sUrl":          "",
100
                "oPaginate": {
101
                    "sFirst":    '{% trans "First" %}',
102
                    "sPrevious": '{% trans "Previous" %}',
103
                    "sNext":     '{% trans "Next" %}',
104
                    "sLast":     '{% trans "Last" %}'
105
                }
106
            }
107
        });
108

109
oTable.fnDraw();
110

111
$('[id^=del_realm_]').click(function(){
112
        realm_id = (this.id).replace("del_realm_", '');
113
        name = this.getAttribute("data-realmname");
114
        $("#mymodalbody").html("You are about to delete realm: <b>"+name+"</b><br>Press Delete to proceed or Cancel to cancel deletion");
115
        $("#myModalLabel").html("Delete Realm "+name);
116
        $('#myModal').modal('show');
117
        $(".modal-footer").show();
118
        $("#realm_name_del").html(name)
119
        return false;
120
});
121

122
$("#delrealmSubmit").click(function(){
123
        $.ajax({
124
                url:"{% url del-realm %}/?realm_pk="+realm_id,
125
                type: "GET",
126
                success: function(data){
127
                        if (data.error){
128
                                $(".modal-footer").hide();
129
                                $("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
130
                        }
131
                        if (data.success){
132
                                $(".modal-footer").hide();
133
                                $("#mymodalbody").html("Realm "+name+" successfully deleted");
134
                                window.setTimeout('location.reload()', 1000);
135

136
                        }
137
                        }
138
                });
139
});
140

141
{% endif %}
142
});
143
</script>
144
{% endblock %}