Skip to content

Commit

Permalink
Merge pull request #3 from Mng-dev-ai/update-folder-structure
Browse files Browse the repository at this point in the history
chore(structure): Update folder structure
  • Loading branch information
Mng-dev-ai authored Sep 8, 2024
2 parents 9271a8e + 90effbf commit b21c545
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 3 deletions.
6 changes: 3 additions & 3 deletions django_modal_actions/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
class ModalActionMixin:
modal_actions: List[str] = []
list_modal_actions: List[str] = []
change_form_template: str = "django_modal_actions/change_form.html"
change_list_template: str = "django_modal_actions/change_list.html"
change_form_template: str = "admin/django_modal_actions/change_form.html"
change_list_template: str = "admin/django_modal_actions/change_list.html"

def get_urls(self) -> List[path]:
urls: List[path] = super().get_urls()
Expand Down Expand Up @@ -73,7 +73,7 @@ def get_modal_content(
"selected_ids": json.dumps(selected_ids) if obj is None else None,
}
content = render_to_string(
"django_modal_actions/modal_actions.html", context, request
"admin/django_modal_actions/modal_actions.html", context, request
)
return JsonResponse({"content": content})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "admin/change_form.html" %}

{% block object-tools %}
<ul class="object-tools">
{% block object-tools-items %}
{{ block.super }}
{% if modal_action_buttons %}
<li>{{ modal_action_buttons }}</li>
{% endif %}
{% endblock %}
</ul>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "admin/change_list.html" %}

{% block object-tools %}
<ul class="object-tools">
{% block object-tools-items %}
{{ block.super }}
{% if list_modal_action_buttons %}
<li>{{ list_modal_action_buttons }}</li>
{% endif %}
{% endblock %}
</ul>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="dma-modal-header">
<h2>{{ action_name }}</h2>
<button class="dma-modal-close">&times;</button>
</div>
<div class="dma-modal-body">
<p>{{ description }}</p>
{% if form %}
<form
id="dma-modal-form"
method="post"
action="{% if object %}{% url 'admin:'|add:opts.app_label|add:'_'|add:opts.model_name|add:'_execute_action' object.pk action %}{% else %}{% url 'admin:'|add:opts.app_label|add:'_'|add:opts.model_name|add:'_execute_list_action' action %}{% endif %}"
>
{% csrf_token %} {{ form.as_p }} {% if selected_ids %}
<input type="hidden" name="selected_ids" value="{{ selected_ids }}" />
{% endif %}
</form>
{% endif %}
</div>
<div class="dma-modal-footer">
{% if form %}
<button type="submit" form="dma-modal-form" class="dma-button default">
Confirm
</button>
<button class="dma-button cancel">Cancel</button>
{% else %}
<form
method="post"
action="{% if object %}{% url 'admin:'|add:opts.app_label|add:'_'|add:opts.model_name|add:'_execute_action' object.pk action %}{% else %}{% url 'admin:'|add:opts.app_label|add:'_'|add:opts.model_name|add:'_execute_list_action' action %}{% endif %}"
>
{% csrf_token %} {% if selected_ids %}
<input type="hidden" name="selected_ids" value="{{ selected_ids }}" />
{% endif %}
<button type="submit" class="dma-button default">Confirm</button>
<button class="dma-button cancel">Cancel</button>
</form>
{% endif %}
</div>

0 comments on commit b21c545

Please sign in to comment.