Revision 6abd262c

b/snf-astakos-app/astakos/im/forms.py
566 566
            k = k.partition('_proxy')[0]
567 567
            self.fields[k] = forms.IntegerField(
568 568
                required=False,
569
                widget=forms.HiddenInput(),
569
                #widget=forms.HiddenInput(),
570 570
                min_value=1
571 571
            )
572 572
        map(add_fields,
573
            ((k, v) for k,v in qd.iteritems() if k.endswith('_uplimit_proxy'))
573
            ((k, v) for k,v in qd.iteritems() if k.endswith('_uplimit'))
574 574
        )
575 575
        
576 576
        def add_fields((k, v)):
577 577
            self.fields[k] = forms.BooleanField(
578 578
                required=False,
579
                widget=forms.HiddenInput()
579
                #widget=forms.HiddenInput()
580 580
            )
581 581
        map(add_fields,
582 582
            ((k, v) for k,v in qd.iteritems() if k.startswith('is_selected_'))
b/snf-astakos-app/astakos/im/static/im/css/modules.css
418 418
.quotas-form .with-info .double-checks span.info { left:262px; }
419 419
.quotas-form .with-info .with-checkbox			{ margin-bottom:12px; }	 
420 420
.quotas-form .quota input[type="text"]			{ width:150px;}
421

  
422
	 
421
.quotas-form .quota .error-msg 					{ display:none; color:red; font-size:0.8em; margin:0; margin-left:224px; margin-bottom:5px; padding:5px; }
422
.quotas-form .quota .with-errors .error-msg		{ display:block;}	 
423 423
/* stats */
424 424
.stats ul										{ margin:0; padding:0; list-style:none outside none; }
425 425
.stats ul li 									{ margin:0 0 1em 0; padding:0 0 1em 0; list-style:none outside none; background:url(../images/stats-line.jpg) repeat-x left bottom}
b/snf-astakos-app/astakos/im/static/im/js/quotas.js
68 68
		
69 69
	});
70 70

  
71
 
71
    
72
	
73
	 
72 74
	 
73 75
	$('.quotas-form .quota input[type="text"]').change(function () {
74 76
	 	
77
	 	
78
	 	 
75 79
	 	// get value from input
76 80
	 	var value = $(this).val();
77 81
	 	
78
	 	// replace , with .  and get number 
79
	 	value = value.replace(",",".");
80
	 	var num = parseFloat(value);
81
	 	var bytes = num;
82
	 	//get input name without _proxy
83
	 	hidden_name = $(this).attr('name').replace("_proxy","");
84
	 	var hidden_input = $("input[name='"+hidden_name+"']");
85
	 	
82 86
	 	
83 87
	 	if ($(this).hasClass('dehumanize')){
88
	 		
89
	 		var flag = 0;
90
	 		
91
	 		// replace , with .  and get number 
92
		 	value = value.replace(",",".");
93
		 	var num = parseFloat(value);
94
		 	
95
		 	if ( !num ) { flag = 1}
96
		 	
97
		 	var bytes = num;
98
	 		
84 99
	 		 // get suffix. 'i' renders it case insensitive
85 100
		 	var suf = value.match( new RegExp('GB|KB|MB|TB|bytes', 'i'));
86 101
		 	if (suf){
......
111 126
			 		  bytes = num; 
112 127
		 		}
113 128
		 	} else {
114
		 		 bytes = num; 
129
		 		 flag = 1;
130
		 	}
131
		 	
132
		 	if ( flag == '1' ){ 
133
		 		$(this).parents('.form-row').addClass('with-errors');
134
		 		return;
135
		 		 
136
		 	} else {
137
		 		$(this).parents('.form-row').removeClass('with-errors');
115 138
		 	}
139
		 	
140
		 	machine_value = bytes;
141
		 	hidden_input.val(bytes);
142
		 	
143
	 	} else {
144

  
145
	 		var is_int = value.match (new RegExp('^[0-9]*$'));
146
	 		if ( !is_int ){ 
147
	 			$(this).parents('.form-row').find('.error-msg').html('Enter a whole number');
148
		 		$(this).parents('.form-row').addClass('with-errors');
149
		 		 
150
		 	} else {
151
		 		$(this).parents('.form-row').removeClass('with-errors');
152
		 		hidden_input.val(value);
153
		 	}
154

  
116 155
	 	}
117 156
	 	
118 157
	 	
119
	 	var human_value = value;
120
	 	var machine_value = bytes;
121
	 	
122
	 	//get input name without _proxy
123
	 	hidden_name = $(this).attr('name').replace("_proxy","");
124
	 	var hidden_input = $("input[name='"+hidden_name+"']");
125
	 	
126
	 	hidden_input.val(bytes);
127 158
	 	
128
	 	$(this).parents('.form-row').find('.msg').html( human_value+ machine_value  ); 
129 159
	 });
130 160
	
131 161
});
b/snf-astakos-app/astakos/im/templates/im/astakosgroup_form.html
20 20
    	</legend>
21 21
        
22 22
        {% include "im/form_render.html" %}
23
		
24
<!-- 
25
		<div class="double-checks">
26
    		<label>Max users per group</label>
27
    		<div class="form-row">
28
    			<p class="clearfix">
29
    				<label for="members_unlimited">Unlimited</label>
30
    				<input type="checkbox" id="members_unlimited" name="members_unlimited" class="unlimited" checked="checked">
31
    				<span class="info"> 
32
				    	<em>more info</em>
33
				    	<span>Help Text Help Text Help Text Text Help Text Help Text</span>
34
			    	</span>  
35
    			</p>
36
    		</div>
37
    		<div class="form-row">
38
    			<p class="clearfix">
39
    				<label for="members_limited">Limited</label>
40
    				<input type="checkbox" id="members_limited" name="members_limited" class="limited">
41
       				<input type="text" id="members_uplimit" name="members_uplimit" />
42
	       			  		 
43
    			</p>
44
    			
45
    		</div>
46
    		
47
    	</div> 
48
 -->
23

  
49 24
    </fieldset>     
50 25
    
51 26
    <fieldset id="icons">
......
104 79
		         		<span class="info"><em>more info</em><span>Help Text</span></span>
105 80
		    		</p>
106 81
		    	</div>-->
107
 				<!--
108
 				<div class="double-checks">
109
		    		<label>
110
		    			Max {% if resource_info.is_abbreviation %}{{ r|get_value_after_dot|upper }}{% else %}{{ r|get_value_after_dot }}{% endif %}{% if not resource.unit %}s {% endif  %} per user
111
						{% if resource.unit %} 
112
						 	({{ resource.unit }})
113
						{% endif  %}
114
					</label>
115
		    		<div class="form-row">
116
		    			<p class="clearfix">
117
		    				<label for="{{r|add:'_unlimited'}}">Unlimited</label>
118
		    				<input type="checkbox" id="{{'id_'|add:r|add:'_unlimited'}}" name="{{r|add:'_unlimited'}}_proxy" class="unlimited radio" checked="checked">
119
		    			</p>
120
		    		</div>
121
		    		<div class="form-row">
122
		    			<p class="clearfix">
123
		    				<label for="{{r|add:'_limited'}}">Limited</label>
124
		    				<input type="checkbox" id="id_storage_per_user_limited" name="{{r|add:'_limited'}}_proxy" class="radio limited">
125
		       				<input 	type="text" 
126
		       						id="{{'id_'|add:r|add:'_uplimit'}}" 
127
		       						name="{{r|add:'_uplimit'}}_proxy" 
128
		       						placeholder="{{ resource_info.placeholder}} " 
129
		       						{% if resource.unit == 'bytes' %} 
130
									 	class="dehumanize"
131
									{% endif  %}
132
		       						/> 
133
		    			</p>
134
		    			<p class="msg"></p>
135
		    		</div>
136
		    		
137
		    	</div>
138
		    	-->
82
 				 
83
		    	
139 84
		    	<div class="form-row">
140 85
		    		<p class="clearfix">
141 86
		    			<label for="num_storage">
......
150 95
									{% endif  %}
151 96
		       						/> 
152 97
		    			<span class="extra-img">&nbsp;</span>
153
		         		<span class="info"><em>more info</em><span>Help Text</span></span>
98
		         		<span class="info"><em>more info</em><span>Leave this field blank if you don't want to specify this resource</span></span>
99
		         		<p class="error-msg">Invalid format</p>
154 100
		    		</p>
155 101
		    		<p class="msg"></p>
156 102
		    	</div>
b/snf-astakos-app/astakos/im/views.py
777 777
    else:
778 778
        now = datetime.now()
779 779
        data = {
780
            'kind': kind
780
            'kind': kind,
781 781
        }
782
        for group, resources in resource_catalog['groups'].iteritems():
783
            data['is_selected_%s' % group] = False
784
            for resource in resources:
785
                data['%s_uplimit' % resource] = ''
786
        
782 787
        form = form_class(data)
783 788

  
784 789
    # Create the template, context, response

Also available in: Unified diff