Commit e67b3e6e authored by Olga Brani's avatar Olga Brani
Browse files

Group create form bug fixes ( preliminary effors )

parent b8a6aad3
......@@ -566,17 +566,17 @@ class AstakosGroupCreationForm(forms.ModelForm):
k = k.partition('_proxy')[0]
self.fields[k] = forms.IntegerField(
required=False,
widget=forms.HiddenInput(),
#widget=forms.HiddenInput(),
min_value=1
)
map(add_fields,
((k, v) for k,v in qd.iteritems() if k.endswith('_uplimit_proxy'))
((k, v) for k,v in qd.iteritems() if k.endswith('_uplimit'))
)
def add_fields((k, v)):
self.fields[k] = forms.BooleanField(
required=False,
widget=forms.HiddenInput()
#widget=forms.HiddenInput()
)
map(add_fields,
((k, v) for k,v in qd.iteritems() if k.startswith('is_selected_'))
......
......@@ -418,8 +418,8 @@ form.quotas-form legend span.info span { width:395px; }
.quotas-form .with-info .double-checks span.info { left:262px; }
.quotas-form .with-info .with-checkbox { margin-bottom:12px; }
.quotas-form .quota input[type="text"] { width:150px;}
.quotas-form .quota .error-msg { display:none; color:red; font-size:0.8em; margin:0; margin-left:224px; margin-bottom:5px; padding:5px; }
.quotas-form .quota .with-errors .error-msg { display:block;}
/* stats */
.stats ul { margin:0; padding:0; list-style:none outside none; }
.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}
......
......@@ -68,19 +68,34 @@ $(document).ready(function() {
});
$('.quotas-form .quota input[type="text"]').change(function () {
// get value from input
var value = $(this).val();
// replace , with . and get number
value = value.replace(",",".");
var num = parseFloat(value);
var bytes = num;
//get input name without _proxy
hidden_name = $(this).attr('name').replace("_proxy","");
var hidden_input = $("input[name='"+hidden_name+"']");
if ($(this).hasClass('dehumanize')){
var flag = 0;
// replace , with . and get number
value = value.replace(",",".");
var num = parseFloat(value);
if ( !num ) { flag = 1}
var bytes = num;
// get suffix. 'i' renders it case insensitive
var suf = value.match( new RegExp('GB|KB|MB|TB|bytes', 'i'));
if (suf){
......@@ -111,21 +126,36 @@ $(document).ready(function() {
bytes = num;
}
} else {
bytes = num;
flag = 1;
}
if ( flag == '1' ){
$(this).parents('.form-row').addClass('with-errors');
return;
} else {
$(this).parents('.form-row').removeClass('with-errors');
}
machine_value = bytes;
hidden_input.val(bytes);
} else {
var is_int = value.match (new RegExp('^[0-9]*$'));
if ( !is_int ){
$(this).parents('.form-row').find('.error-msg').html('Enter a whole number');
$(this).parents('.form-row').addClass('with-errors');
} else {
$(this).parents('.form-row').removeClass('with-errors');
hidden_input.val(value);
}
}
var human_value = value;
var machine_value = bytes;
//get input name without _proxy
hidden_name = $(this).attr('name').replace("_proxy","");
var hidden_input = $("input[name='"+hidden_name+"']");
hidden_input.val(bytes);
$(this).parents('.form-row').find('.msg').html( human_value+ machine_value );
});
});
\ No newline at end of file
......@@ -20,32 +20,7 @@
</legend>
{% include "im/form_render.html" %}
<!--
<div class="double-checks">
<label>Max users per group</label>
<div class="form-row">
<p class="clearfix">
<label for="members_unlimited">Unlimited</label>
<input type="checkbox" id="members_unlimited" name="members_unlimited" class="unlimited" checked="checked">
<span class="info">
<em>more info</em>
<span>Help Text Help Text Help Text Text Help Text Help Text</span>
</span>
</p>
</div>
<div class="form-row">
<p class="clearfix">
<label for="members_limited">Limited</label>
<input type="checkbox" id="members_limited" name="members_limited" class="limited">
<input type="text" id="members_uplimit" name="members_uplimit" />
</p>
</div>
</div>
-->
</fieldset>
<fieldset id="icons">
......@@ -104,38 +79,8 @@
<span class="info"><em>more info</em><span>Help Text</span></span>
</p>
</div>-->
<!--
<div class="double-checks">
<label>
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
{% if resource.unit %}
({{ resource.unit }})
{% endif %}
</label>
<div class="form-row">
<p class="clearfix">
<label for="{{r|add:'_unlimited'}}">Unlimited</label>
<input type="checkbox" id="{{'id_'|add:r|add:'_unlimited'}}" name="{{r|add:'_unlimited'}}_proxy" class="unlimited radio" checked="checked">
</p>
</div>
<div class="form-row">
<p class="clearfix">
<label for="{{r|add:'_limited'}}">Limited</label>
<input type="checkbox" id="id_storage_per_user_limited" name="{{r|add:'_limited'}}_proxy" class="radio limited">
<input type="text"
id="{{'id_'|add:r|add:'_uplimit'}}"
name="{{r|add:'_uplimit'}}_proxy"
placeholder="{{ resource_info.placeholder}} "
{% if resource.unit == 'bytes' %}
class="dehumanize"
{% endif %}
/>
</p>
<p class="msg"></p>
</div>
</div>
-->
<div class="form-row">
<p class="clearfix">
<label for="num_storage">
......@@ -150,7 +95,8 @@
{% endif %}
/>
<span class="extra-img">&nbsp;</span>
<span class="info"><em>more info</em><span>Help Text</span></span>
<span class="info"><em>more info</em><span>Leave this field blank if you don't want to specify this resource</span></span>
<p class="error-msg">Invalid format</p>
</p>
<p class="msg"></p>
</div>
......
......@@ -777,8 +777,13 @@ def group_add(request, kind_name='default'):
else:
now = datetime.now()
data = {
'kind': kind
'kind': kind,
}
for group, resources in resource_catalog['groups'].iteritems():
data['is_selected_%s' % group] = False
for resource in resources:
data['%s_uplimit' % resource] = ''
form = form_class(data)
# Create the template, context, response
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment