Commit cddf8e08 authored by Mark Caglienzi's avatar Mark Caglienzi
Browse files

Merge branch 't14440'

parents a16639b9 24f98048
......@@ -7,9 +7,34 @@
<link rel="stylesheet" href="{% static 'select2-4.0.3/css/select2.min.css' %}"/>
<script src="{% static 'select2-4.0.3/js/select2.min.js' %}"></script>
<script type="text/javascript">
var name = "{{name}}";
var create_page = null;
var update_page = null;
if(name) {
create_page = false;
update_page = true;
}
else {
create_page = true;
update_page = false;
}
// refs #14440
function fill_path_field() {
$("#id_path").val("/home/SAMBA/" + $("#id_name").val());
}
$(document).ready(function() {
$("#id_writelist").select2();
$("#id_readlist").select2();
$("#id_writelist").select2();
$("#id_readlist").select2();
if(create_page) {
fill_path_field();
$("#id_name").on("input", function(ev) {
fill_path_field();
});
}
});
</script>
{% endblock %}
......
......@@ -29,6 +29,7 @@ class ShareListMixin:
)
return ctx
class List(OctonetMixin, ShareListMixin, TemplateView):
template_name = "samba/list.html"
......@@ -40,6 +41,13 @@ class EditForm(FormControlClassMixin, forms.Form):
readlist = forms.MultipleChoiceField(label=_("Read list"), required=False)
writelist = forms.MultipleChoiceField(label=_("Write list"), required=False)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['path'].widget = forms.TextInput(attrs={
'class': 'form-control',
'readonly': 'readonly',
})
class CreateForm(EditForm):
name = forms.CharField(label=_("Name"))
......@@ -57,6 +65,12 @@ class CreateForm(EditForm):
if '/' in name:
raise forms.ValidationError(_("A share name cannot contain a '/'"), code="no_slashes")
if '..' in name:
raise forms.ValidationError(_("A share name cannot contain '..'"), code="no_dot_dot")
if ' ' in name:
raise forms.ValidationError(_("A share name cannot contain spaces"), code="no_space")
# refs #13851
if name.lower() in [x.lower() for x in self.tree.llist(["samba"])]:
raise forms.ValidationError(_("A share with this name already exists"), code="duplicate")
......
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