def services_cifs(request): try: cifs = models.CIFS.objects.all()[0] except Exception: cifs = models.CIFS() try: it = idmap_tdb.objects.get( idmap_ds_type=DS_TYPE_CIFS, idmap_ds_id=cifs.id ) except Exception: it = idmap_tdb() if request.method == "POST": form = CIFSForm(request.POST, instance=cifs) try: if form.is_valid(): form.save() else: return JsonResp(request, form=form) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form) except ServiceFailed as e: return JsonResp( request, form=form, error=True, message=e.value, events=["serviceFailed(\"%s\")" % e.service]) except MiddlewareError as e: return JsonResp( request, form=form, error=True, message=_("Error: %s") % str(e)) idmap_form = idmap_tdb_Form(request.POST, instance=it) if idmap_form.is_valid(): idmap_form.save() return JsonResp( request, message=_("SMB successfully updated.") ) else: return JsonResp(request, form=idmap_form) else: form = CIFSForm(instance=cifs) idmap_form = idmap_tdb_Form(instance=it) idmap_form.fields['idmap_tdb_range_low'].label = _("Idmap Range Low") idmap_form.fields['idmap_tdb_range_high'].label = _("Idmap Range High") return render(request, 'services/cifs.html', { 'form': form, 'idmap_form': idmap_form })
def services_cifs(request): try: cifs = models.CIFS.objects.all()[0] except: cifs = models.CIFS() try: it = idmap_tdb.objects.get(idmap_ds_type=DS_TYPE_CIFS, idmap_ds_id=cifs.id) except Exception: it = idmap_tdb() if request.method == "POST": form = CIFSForm(request.POST, instance=cifs) if form.is_valid(): form.save() else: return JsonResp(request, form=form) idmap_form = idmap_tdb_Form(request.POST, instance=it) if idmap_form.is_valid(): idmap_form.save() return JsonResp(request, message=_("CIFS successfully updated.")) else: return JsonResp(request, form=idmap_form) else: form = CIFSForm(instance=cifs) idmap_form = idmap_tdb_Form(instance=it) idmap_form.fields["idmap_tdb_range_low"].label = _("Idmap Range Low") idmap_form.fields["idmap_tdb_range_high"].label = _("Idmap Range High") return render(request, "services/cifs.html", {"form": form, "idmap_form": idmap_form})
def services_cifs(request): try: cifs = models.CIFS.objects.all()[0] except Exception: cifs = models.CIFS() try: it = idmap_tdb.objects.get( idmap_tdb_domain='DS_TYPE_DEFAULT_DOMAIN' ) except Exception: it = idmap_tdb() if request.method == "POST": form = CIFSForm(request.POST, instance=cifs) try: if form.is_valid(): form.save() else: return JsonResp(request, form=form) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form) except ServiceFailed as e: return JsonResp( request, form=form, error=True, message=e.value, events=["serviceFailed(\"%s\")" % e.service]) except MiddlewareError as e: return JsonResp( request, form=form, error=True, message=_("Error: %s") % str(e)) idmap_form = idmap_tdb_Form(request.POST, instance=it) if idmap_form.is_valid(): idmap_form.save() return JsonResp( request, message=_("SMB successfully updated.") ) else: return JsonResp(request, form=idmap_form) else: form = CIFSForm(instance=cifs) idmap_form = idmap_tdb_Form(instance=it) idmap_form.fields['idmap_tdb_range_low'].label = _("Idmap Range Low") idmap_form.fields['idmap_tdb_range_high'].label = _("Idmap Range High") return render(request, 'services/cifs.html', { 'form': form, 'idmap_form': idmap_form })
def services_cifs(request): try: cifs = models.CIFS.objects.all()[0] except Exception: cifs = models.CIFS() try: it = idmap_tdb.objects.get( idmap_ds_type=DS_TYPE_CIFS, idmap_ds_id=cifs.id ) except Exception: it = idmap_tdb() if request.method == "POST": try: form = CIFSForm(request.POST, instance=cifs) if form.is_valid(): form.save() else: return JsonResp(request, form=form) except ValidationErrors as e: handle_middleware_validation(form, e) return JsonResp(request, form=form) idmap_form = idmap_tdb_Form(request.POST, instance=it) if idmap_form.is_valid(): idmap_form.save() return JsonResp( request, message=_("SMB successfully updated.") ) else: return JsonResp(request, form=idmap_form) else: form = CIFSForm(instance=cifs) idmap_form = idmap_tdb_Form(instance=it) idmap_form.fields['idmap_tdb_range_low'].label = _("Idmap Range Low") idmap_form.fields['idmap_tdb_range_high'].label = _("Idmap Range High") return render(request, 'services/cifs.html', { 'form': form, 'idmap_form': idmap_form })
def services_cifs(request): try: cifs = models.CIFS.objects.all()[0] except: cifs = models.CIFS() try: it = idmap_tdb.objects.get( idmap_ds_type=DS_TYPE_CIFS, idmap_ds_id=cifs.id ) except Exception as e: it = idmap_tdb() if request.method == "POST": form = CIFSForm(request.POST, instance=cifs) if form.is_valid(): form.save() else: return JsonResp(request, form=form) idmap_form = idmap_tdb_Form(request.POST, instance=it) if idmap_form.is_valid(): idmap_form.save() return JsonResp( request, message=_("CIFS successfully updated.") ) else: return JsonResp(request, form=idmap_form) else: form = CIFSForm(instance=cifs) idmap_form = idmap_tdb_Form(instance=it) idmap_form.fields['idmap_tdb_range_low'].label = "Idmap Range Low" idmap_form.fields['idmap_tdb_range_high'].label = "Idmap Range High" return render(request, 'services/cifs.html', { 'form': form, 'idmap_form': idmap_form })