forked from enviPath/enviPy
[Feature] Leftovers after Release (#303)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#303
This commit is contained in:
@ -1352,6 +1352,14 @@ def package_compound_structure(request, package_uuid, compound_uuid, structure_u
|
||||
)
|
||||
|
||||
if request.method == "GET":
|
||||
is_image_request = request.GET.get("image")
|
||||
|
||||
if is_image_request:
|
||||
if is_image_request == "svg":
|
||||
return HttpResponse(current_structure.as_svg, content_type="image/svg+xml")
|
||||
else:
|
||||
return HttpResponseBadRequest("Currently only SVG as image formate supported!")
|
||||
|
||||
context = get_base_context(request)
|
||||
context["title"] = (
|
||||
f"enviPath - {current_package.name} - {current_compound.name} - {current_structure.name}"
|
||||
@ -2569,6 +2577,28 @@ def package_scenario(request, package_uuid, scenario_uuid):
|
||||
return redirect(current_scenario.url)
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
new_scenario_name = request.POST.get("scenario-name")
|
||||
|
||||
if new_scenario_name is not None:
|
||||
new_scenario_name = nh3.clean(new_scenario_name, tags=s.ALLOWED_HTML_TAGS).strip()
|
||||
|
||||
if new_scenario_name:
|
||||
current_scenario.name = new_scenario_name
|
||||
|
||||
new_scenario_description = request.POST.get("scenario-description")
|
||||
|
||||
if new_scenario_description is not None:
|
||||
new_scenario_description = nh3.clean(
|
||||
new_scenario_description, tags=s.ALLOWED_HTML_TAGS
|
||||
).strip()
|
||||
|
||||
if new_scenario_description:
|
||||
current_scenario.description = new_scenario_description
|
||||
|
||||
if any([new_scenario_name, new_scenario_description]):
|
||||
current_scenario.save()
|
||||
return redirect(current_scenario.url)
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
else:
|
||||
@ -2784,10 +2814,17 @@ def settings(request):
|
||||
context["object_type"] = "setting"
|
||||
context["breadcrumbs"] = [
|
||||
{"Home": s.SERVER_URL},
|
||||
{"Group": s.SERVER_URL + "/setting"},
|
||||
{"Setting": s.SERVER_URL + "/setting"},
|
||||
]
|
||||
|
||||
context["objects"] = SettingManager.get_all_settings(current_user)
|
||||
# Context for paginated template
|
||||
context["entity_type"] = "setting"
|
||||
context["api_endpoint"] = "/api/v1/settings/"
|
||||
context["per_page"] = s.API_PAGINATION_DEFAULT_PAGE_SIZE
|
||||
context["list_title"] = "settings"
|
||||
context["list_mode"] = "combined"
|
||||
|
||||
return render(request, "collections/settings_paginated.html", context)
|
||||
|
||||
return render(request, "collections/objects_list.html", context)
|
||||
elif request.method == "POST":
|
||||
@ -2867,7 +2904,26 @@ def settings(request):
|
||||
|
||||
|
||||
def setting(request, setting_uuid):
|
||||
pass
|
||||
current_user = _anonymous_or_real(request)
|
||||
current_setting = SettingManager.get_setting_by_id(current_user, setting_uuid)
|
||||
|
||||
if request.method == "GET":
|
||||
context = get_base_context(request)
|
||||
context["title"] = f"enviPath - {current_setting.name}"
|
||||
|
||||
context["object_type"] = "setting"
|
||||
context["breadcrumbs"] = [
|
||||
{"Home": s.SERVER_URL},
|
||||
{"Setting": s.SERVER_URL + "/setting"},
|
||||
{f"{current_setting.name}": current_setting.url},
|
||||
]
|
||||
|
||||
context["setting"] = current_setting
|
||||
context["current_object"] = current_setting
|
||||
|
||||
return render(request, "objects/setting.html", context)
|
||||
else:
|
||||
return HttpResponseNotAllowed(["GET"])
|
||||
|
||||
|
||||
def jobs(request):
|
||||
|
||||
Reference in New Issue
Block a user