Statistics
| Branch: | Tag: | Revision:

root / djnro / templates / edumanage / institution_edit.html @ 1d70dbce

History | View | Annotate | Download (7.8 kB)

1
{% extends "edumanage/welcome.html"%}
2
{% load staticfiles %}
3
{% load i18n %}
4
{% load tolocale %}
5
{% block homeactive %}{% endblock %}
6
{% block instactive %}class="active"{% endblock %}
7
{% block management_content %}
8

    
9
<h4>{% tolocale institution LANGUAGE_CODE%} {% trans "Edit" %}</h4>
10
<hr>
11

    
12
        <div class="col-md-12">
13
                <form method="POST">
14
                        {% csrf_token %}
15
                        {% if form.non_field_errors %}
16
                        <p class="error">
17
                                {{ form.non_field_errors}}
18
                        </p>
19
                        {% endif %}
20
                        <div style="display: none">
21
                                {{form.institution}}
22
                        </div>
23
                        <div class="form-group">
24
                                <label class="control-label" for="id_name"><b>{% trans "Name" %}</b></label>
25
                                <div class="controls">
26
                                        <input class="input" id="disabledInput" type="text" placeholder="{% tolocale institution LANGUAGE_CODE %}" disabled
27
                                </div
28
                        </div
29
                        <div ="form-group {% if  %} error {% endif %}">
30
                                <label class="control-label" for="id_ertype"><b>{% trans "Type" %}</b></label>
31
                                <div class="controls">
32
                                        <input class="input" id="disabledInput2" type="text" placeholder="{{institution.get_ertype_display}}" disabled
33
                                </div
34
                        </div
35
                        <div ="form-group {% if  %} error {% endif %}">
36
                                <label class="control-label" for="id_address_street"><b>{% trans "Address Street" %}</b></label>
37
                                <div class="controls">
38
                                        {{ form.address_street }}
39
                                        {% if form.address_street.errors %} <span class="help-inline"> {{ form.address_street.errors|join:", " }} </span>
40
                                        {% endif %} <span class="help-block"> {{ form.address_street.help_text }}</span>
41
                                </div>
42
                        </div>
43
                        <div class="form-group {% if form.address_city.errors %} error {% endif %}">
44
                                <label class="control-label" for="id_address_city"><b>{% trans "Address City" %}</b></label>
45
                                <div class="controls">
46
                                        {{ form.address_city }}
47
                                        {% if form.address_city.errors %} <span class="help-inline"> {{ form.address_city.errors|join:", " }} </span>
48
                                        {% endif %} <span class="help-block"> {{ form.address_city.help_text }}</span>
49
                                </div>
50
                        </div>
51
                        <div class="form-group {% if form.contact.errors %} error {% endif %}">
52
                                <label class="control-label" for="id_contact"><b>{% trans "Contacts" %}</b></label>
53
                                <div class="controls">
54
                                        <div class="">{{ form.contact }}</div>
55
                                        <button class="btn btn-small btn-info" id="add_contact"><i class="icon-plus-sign icon-white"></i>Add...</button>
56
                                        {% if form.contact.errors %} <span class="help-inline"> {{ form.ertype.contact|join:", " }} </span>
57
                                        {% endif %} <span class="help-block"> {{ form.contact.help_text }}</span>
58
                                </div>
59
                        </div>
60
                    <div class="form-group {% for err in urls_form.errors %}{% if err|length > 0 %}error{% endif %}{% endfor %}{% if urls_form.non_form_errors %}error{% endif %}">
61
                        <label class="control-label" for="id_urls"><b>{% trans "Urls" %}</b></label>
62
                        {{urls_form.management_form}}
63
                        <div class="controls">
64
                        {% if urls_form.non_form_errors %} <span class="help-inline"> {{ urls_form.non_form_errors|join:", "}}</span>{% endif %}
65
                            <table id="urlsform"><thead><tr><td>url</td><td>type</td><td>language</td></tr></thead><tbody>
66
                        {% for formset in urls_form.forms %}
67
                        {{ formset.id }}
68

    
69

    
70
                            <tr id="{{ formset.prefix }}-row">
71
                            <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>
72
                             <td>{{formset.urltype}}{% if formset.urltype.errors %}<br><p class="help-inline"> {{ formset.urltype.errors|join:", " }} </p>{% endif %}</td>
73
                             <td>{{formset.lang}}{% if formset.lang.errors %}<br><p class="help-inline"> {{ formset.lang.errors|join:", " }} </p>{% endif %}</td>
74

    
75
                        </tr>
76
                        {% endfor %}
77
                        </tbody></table>
78
                        </div>
79
                    </div>
80
                    {% if institution.ertype == 2 or institution.ertype == 3 %}
81
                        <div class="form-group {% if form.oper_name.errors %} error {% endif %}">
82
                                <label class="control-label" for="id_oper_name"><b>{% trans "Domain Name" %}</b></label>
83
                                <div class="controls">
84
                                        {{ form.oper_name }}
85
                                        {% if form.oper_name.errors %} <span class="help-inline"> {{ form.oper_name.errors|join:", " }} </span>
86
                                        {% endif %} <span class="help-block">{% autoescape off %}{{ form.oper_name.help_text }}{% endautoescape %}</span>
87
                                </div>
88
                        </div>
89
                        {% endif %}
90
                        {% if institution.ertype == 1 or institution.ertype == 3 %}
91
                        <div class="form-group {% if form.number_user.errors %} error {% endif %}">
92
                                <label class="control-label" for="id_number_user">{% trans "Number of Users" %}</label>
93
                                <div class="controls">
94
                                        {{ form.number_user }}
95
                                        {% if form.number_user.errors %} <span class="help-inline"> {{ form.number_user.errors|join:", " }} </span>
96
                                        {% endif %} <span class="help-block"> {{ form.number_user.help_text }}</span>
97
                                </div>
98
                        </div>
99
                        {% endif %}
100
                        <div class="form-group {% if form.number_id.errors %} error {% endif %}">
101
                                <label class="control-label" for="id_number_id">{% trans "Number of IDs" %}</label>
102
                                <div class="controls">
103
                                        {{ form.number_id }}
104
                                        {% if form.number_id.errors %} <span class="help-inline"> {{ form.number_id.errors|join:", " }} </span>
105
                                        {% endif %} <span class="help-block"> {{ form.number_id.help_text }}</span>
106
                                </div>
107
                        </div>
108
                        <div class="form-group">
109
                                <div class="controls">
110
                                        <button type="submit" id="applybutton" value="Apply" class="btn btn-primary"/>{% trans "Apply" %}</button>
111
                                </div>
112
                        </div>
113
                </form>
114
        </div>
115
</div>
116

    
117
<div class="modal fade" id="myModal">
118
  <div class="modal-dialog">
119
    <div class="modal-content">
120
      <div class="modal-header">
121
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
122
        <h4 class="modal-title" id="myModalLabel">{% trans "Add User" %}</h4>
123
      </div>
124
      <div class="modal-body" id="mymodalbody">
125
        <p>Loading...</p>
126
      </div>
127
      <div class="modal-footer">
128
        <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
129
        <button type="button" id="adduserSubmit" class="btn btn-primary">{% trans "Save changes" %}</button>
130
      </div>
131
    </div>
132
  </div>
133
</div>
134

    
135
{% endblock %}
136

    
137
{% block extrajs %}
138
<script type="text/javascript" src="{% static 'js/jquery.formset.js' %}"></script>
139
<script type="text/javascript">
140
$(document).ready(function() {
141
        $("#adduserSubmit").click(function(){
142
                $.ajax({
143
                        url:"{% url adduser %}",
144
                        data:$("#add_user_form").serialize(),
145
                        type: "POST",
146
                        cache: false,
147
                        success:function(data){
148
                                        try {
149
                                                value = data.value;
150
                                                text = data.text;
151
                                                if (typeof value === 'undefined' && typeof text === 'undefined'){
152
                                                        $('#mymodalbody').html(data);
153
                                                }
154
                                                else{
155
                                                        $('#id_contact').append($("<option></option>").attr("value",value).text(text));
156
                                                        $('#myModal').modal('hide')
157
                                                }
158
                                        }
159
                                        catch (exception) {
160
                                                $('#mymodalbody').html(data);
161
                                        }
162
                                }
163
                                });
164
                return false;
165
        });
166

167
        $("#add_contact").click(function(){
168
                $('#myModal').modal('show');
169
                $.ajax({
170
                                url:"{% url adduser %}",
171
                                type: "GET",
172
                                success: function(data){
173
                                        $('#mymodalbody').html(data);
174
                                }
175
                        });
176

177
         return false;
178
        });
179

180

181
         $('#urlsform tbody tr').formset({
182
        prefix: '{{urls_form.prefix}}',
183
        formCssClass: "dynamic-formset1",
184
        added: addButton,
185
    });
186

187
     $(".delete-row").prepend('<i class="icon-remove-sign icon-white"></i> ').addClass('btn btn-small btn-warning');
188
     $(".add-row").prepend('<i class="icon-plus-sign icon-white"></i> ').addClass('btn btn-small btn-info');
189

190

191
});
192
function addButton(row){
193
            $(row).find(".delete-row").prepend('<i class="icon-remove-sign icon-white"></i> ').addClass('btn btn-small btn-warning');
194
        }
195

    
196
</script>
197

    
198
{% endblock %}