Statistics
| Branch: | Tag: | Revision:

root / djnro / templates / edumanage / institution_edit.html @ d3ea44a4

History | View | Annotate | Download (7.7 kB)

1
{% extends "edumanage/welcome.html"%}
2
{% load i18n %}
3
{% load tolocale %}
4
{% block crumbs %}
5
        <li><a href="{% url manage %}">{% trans "Home" %}</a><span class="divider">/</span></li>
6
        <li><a href="{% url institutions %}">{% trans "Institution" %}</a><span class="divider">/</span></li>
7
        <li class="active">{% tolocale institution LANGUAGE_CODE%} ({% trans "Edit" %})</li>
8
{% endblock %}
9
{% block extrahead %}
10
<script type="text/javascript" src="/static/js/jquery.formset.js"></script>
11
<script type="text/javascript">
12
$(document).ready(function() {
13
        $("#adduserSubmit").click(function(){
14
                $.ajax({
15
                        url:"{% url adduser %}", 
16
                        data:$("#add_user_form").serialize(),
17
                        type: "POST",
18
                        cache: false,
19
                        success:function(data){
20
                                        try {
21
                                                value = data.value;
22
                                                text = data.text;
23
                                                if (typeof value === 'undefined' && typeof text === 'undefined'){
24
                                                        $('#mymodalbody').html(data);        
25
                                                }
26
                                                else{
27
                                                        $('#id_contact').append($("<option></option>").attr("value",value).text(text));
28
                                                        $('#myModal').modal('hide')
29
                                                }
30
                                        }
31
                                        catch (exception) {
32
                                                $('#mymodalbody').html(data);
33
                                        }                                        
34
                                }
35
                                });
36
                return false;
37
        });
38
        
39
        $("#add_contact").click(function(){
40
         $('#myModal').modal('show')
41
         $.ajax({
42
                        url:"{% url adduser %}",
43
                        type: "GET",
44
                        success: function(data){
45
                                $('#mymodalbody').html(data);
46
                                }
47
                        });
48
        
49
         return false;
50
        });
51
        
52
        
53
         $('#urlsform tbody tr').formset({
54
        prefix: '{{urls_form.prefix}}',
55
        formCssClass: "dynamic-formset1",
56
        added: addButton,
57
    });
58

59
     $(".delete-row").prepend('<i class="icon-remove-sign icon-white"></i> ').addClass('btn btn-small btn-warning');
60
     $(".add-row").prepend('<i class="icon-plus-sign icon-white"></i> ').addClass('btn btn-small btn-info');
61
     
62
     
63
});
64
function addButton(row){
65
            $(row).find(".delete-row").prepend('<i class="icon-remove-sign icon-white"></i> ').addClass('btn btn-small btn-warning');
66
        }
67
        
68
</script>
69

    
70
{% endblock %}
71
{% block homeactive %}{% endblock %}
72
{% block instactive %}class="active"{% endblock %}
73
{% block subcontent %}
74
<h4>{% tolocale institution LANGUAGE_CODE%} {% trans "Edit" %}</h4>
75
<hr>
76
<form method="POST" class="form-horizontal">
77
        {% csrf_token %}
78
        {% if form.non_field_errors %}
79
        <p class="error">
80
                {{ form.non_field_errors}}
81
        </p>
82
        {% endif %}
83
        <div style="display: none">
84
                {{form.institution}}
85
        </div>
86
                <div class="control-group">
87
                <label class="control-label" for="id_name"><b>{% trans "Name" %}</b></label>
88
                <div class="controls">
89
                        <input class="input" id="disabledInput" type="text" placeholder="{% tolocale institution LANGUAGE_CODE %}" disabled
90
                </div
91
        </div
92
        <div ="control-group {% if  %} error {% endif %}">
93
                <label class="control-label" for="id_ertype"><b>{% trans "Type" %}</b></label>
94
                <div class="controls">
95
                        <input class="input" id="disabledInput2" type="text" placeholder="{{institution.get_ertype_display}}" disabled
96
                </div
97
        </div
98
        <div ="control-group {% if  %} error {% endif %}">
99
                <label class="control-label" for="id_address_street"><b>{% trans "Address Street" %}</b></label>
100
                <div class="controls">
101
                        {{ form.address_street }}
102
                        {% if form.address_street.errors %} <span class="help-inline"> {{ form.address_street.errors|join:", " }} </span>
103
                        {% endif %} <span class="help-block"> {{ form.address_street.help_text }}</span>
104
                </div>
105
        </div>
106
        <div class="control-group {% if form.address_city.errors %} error {% endif %}">
107
                <label class="control-label" for="id_address_city"><b>{% trans "Address City" %}</b></label>
108
                <div class="controls">
109
                        {{ form.address_city }}
110
                        {% if form.address_city.errors %} <span class="help-inline"> {{ form.address_city.errors|join:", " }} </span>
111
                        {% endif %} <span class="help-block"> {{ form.address_city.help_text }}</span>
112
                </div>
113
        </div>
114
        <div class="control-group {% if form.contact.errors %} error {% endif %}">
115
                <label class="control-label" for="id_contact"><b>{% trans "Contacts" %}</b></label>
116
                <div class="controls">
117
                        {{ form.contact }} <button class="btn btn-small btn-info" id="add_contact"><i class="icon-plus-sign icon-white"></i>Add...</button>
118
                        {% if form.contact.errors %} <span class="help-inline"> {{ form.ertype.contact|join:", " }} </span>
119
                        {% endif %} <span class="help-block"> {{ form.contact.help_text }}</span>
120
                </div>
121
        </div>
122
    <div class="control-group {% for err in urls_form.errors %}{% if err|length > 0 %}error{% endif %}{% endfor %}{% if urls_form.non_form_errors %}error{% endif %}">
123
        <label class="control-label" for="id_urls"><b>{% trans "Urls" %}</b></label>
124
        {{urls_form.management_form}}
125
        <div class="controls">
126
        {% if urls_form.non_form_errors %} <span class="help-inline"> {{ urls_form.non_form_errors|join:", "}}</span>{% endif %}
127
            <table id="urlsform"><thead><tr><td>url</td><td>type</td><td>language</td></tr></thead><tbody>
128
        {% for formset in urls_form.forms %}
129
        {{ formset.id }}
130
        
131
        
132
            <tr id="{{ formset.prefix }}-row">
133
            <td> {% if formset.instance.pk %}{{ formset.DELETE }}{% endif %}{{ formset.url }}{% if formset.url.errors %}<br><div class="help-inline"> {{ formset.url.errors|join:", " }} </div>{% endif %}</td> 
134
             <td>{{formset.urltype}}{% if formset.urltype.errors %}<br><p class="help-inline"> {{ formset.urltype.errors|join:", " }} </p>{% endif %}</td>
135
             <td>{{formset.lang}}{% if formset.lang.errors %}<br><p class="help-inline"> {{ formset.lang.errors|join:", " }} </p>{% endif %}</td>
136
             
137
        </tr>
138
        {% endfor %}
139
        </tbody></table>
140
        </div>
141
    </div>
142
    {% if institution.ertype == 2 or institution.ertype == 3 %}
143
        <div class="control-group {% if form.oper_name.errors %} error {% endif %}">
144
                <label class="control-label" for="id_oper_name"><b>{% trans "Domain Name" %}</b></label>
145
                <div class="controls">
146
                        {{ form.oper_name }}
147
                        {% if form.oper_name.errors %} <span class="help-inline"> {{ form.oper_name.errors|join:", " }} </span>
148
                        {% endif %} <span class="help-block">{% autoescape off %}{{ form.oper_name.help_text }}{% endautoescape %}</span>
149
                </div>
150
        </div>
151
        {% endif %}
152
        {% if institution.ertype == 1 or institution.ertype == 3 %}
153
        <div class="control-group {% if form.number_user.errors %} error {% endif %}">
154
                <label class="control-label" for="id_number_user">{% trans "Number of Users" %}</label>
155
                <div class="controls">
156
                        {{ form.number_user }}
157
                        {% if form.number_user.errors %} <span class="help-inline"> {{ form.number_user.errors|join:", " }} </span>
158
                        {% endif %} <span class="help-block"> {{ form.number_user.help_text }}</span>
159
                </div>
160
        </div>
161
        {% endif %}
162
        <div class="control-group {% if form.number_id.errors %} error {% endif %}">
163
                <label class="control-label" for="id_number_id">{% trans "Number of IDs" %}</label>
164
                <div class="controls">
165
                        {{ form.number_id }}
166
                        {% if form.number_id.errors %} <span class="help-inline"> {{ form.number_id.errors|join:", " }} </span>
167
                        {% endif %} <span class="help-block"> {{ form.number_id.help_text }}</span>
168
                </div>
169
        </div>
170
        <div class="control-group">
171
                <div class="controls">
172
                        <button type="submit" id="applybutton" value="Apply" class="btn btn-primary"/>{% trans "Apply" %}</button>
173
                </div>
174
        </div>
175
</form>
176
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
177
<div class="modal-header">
178
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
179
<h3 id="myModalLabel">{% trans "Add User" %}</h3>
180
</div>
181
<div class="modal-body" id="mymodalbody">
182

    
183
</div>
184
<div class="modal-footer">
185
<button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Close" %}</button>
186
<a class="btn btn-primary" id="adduserSubmit" href="#">{% trans "Save changes" %}</a>
187
</div>
188
</div>
189
{% endblock %}
190