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

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

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

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