Skip to content

Commit

Permalink
well well well, things start woking out
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Dec 12, 2023
1 parent f9fbecc commit f9eaed7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<div id="div_{{type1}}{{InstanceID}}">
<form action="/apis/relations/ajax/save/{{ entity_type }}/{{ form_name }}/{{ SiteID }}/" enctype="multipart/form-data" method="post" id="form_{{type1}}" class="form ajax_form {{url2}}" data-replace="#message-form">
<form hx-post="/apis/relations/ajax/save/{{ entity_type }}/{{ form_name }}/{{ SiteID }}/" hx-target="#tab_{{ relation_name }}"">
{% load crispy_forms_tags %}
{% crispy form form.helper %}
<div class="form-actions">
Expand Down
24 changes: 5 additions & 19 deletions apis_core/apis_relations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def get_form_ajax(request):
print(f"entity_type_str: {entity_type_str}")
print("###########################")
print("###########################")
relation_name = FormName.replace("Form", "")
form_match = re.match(r"([A-Z][a-z]+)([A-Z][a-z]+)(Highlighter)?Form", FormName)
form_match2 = re.match(r"([A-Z][a-z]+)(Highlighter)?Form", FormName)
if FormName and form_match:
Expand Down Expand Up @@ -180,6 +181,7 @@ def get_form_ajax(request):
"entity_type": entity_type_str,
"form": form,
"form_name": FormName,
"relation_name": relation_name,
"url2": "save_ajax_" + FormName,
"button_text": ButtonText,
"ObjectID": ObjectID,
Expand Down Expand Up @@ -268,23 +270,7 @@ def save_ajax_form(request, entity_type, kind_form, SiteID, ObjectID=False):
"text": hl_text,
"right_card": right_card,
}
return HttpResponse(table_html2)
else:
data = {
"test": False,
"call_function": call_function,
"DivID": f"div_{kind_form}{instance_id}",
"form": render_to_string(
"apis_relations/_ajax_form.html",
context={
"entity_type": entity_type_str,
"form": form,
"type1": kind_form,
"url2": "save_ajax_" + kind_form,
"button_text": button_text,
"ObjectID": ObjectID,
"SiteID": SiteID,
},
request=request,
),
}
return HttpResponse(json.dumps(data), content_type="application/json")
template = loader.get_template("apis_relations/_ajax_form.html")
return HttpResponse(template.render({"form": form}, request))

0 comments on commit f9eaed7

Please sign in to comment.