-
-
-
+
+
+
+
+
+
+ {% endif %}
+
+
+
+
-
-{% endblock %}
+
+ // Event listener to open the edit modal
+ editButton.addEventListener('click', function () {
+ const recordId = editButton.dataset.recordId;
+ if (recordId) {
+ const modal = new bootstrap.Modal(document.getElementById(`editDataModal-${recordId}`));
+ modal.show();
+ }
+ });
+ });
+
+{% endblock %}
\ No newline at end of file
diff --git a/butler/views.py b/butler/views.py
index 71af147..704de53 100644
--- a/butler/views.py
+++ b/butler/views.py
@@ -3,6 +3,7 @@ from pathlib import Path
import markdown
import os
from .models import NoticeBoard, IPManagementRecord
+from django.db.models import Q
def hello_view(request):
@@ -28,16 +29,40 @@ def notice_detail_view(request, pk):
# --- ip management ---
+# def ip_mgmt_view(request):
+# # records = IPManagementRecord.objects.all()
+# if request.user.is_authenticated:
+# # records = IPManagementRecord.objects.filter(author=request.user).order_by(
+# records = IPManagementRecord.objects.order_by(
+# "ip_addrs"
+# )
+# else:
+# # records = IPManagementRecord.objects.none()
+# records = IPManagementRecord.objects.all().order_by("ip_addrs")
+# return render(request, "butler/ip_mgmt.html", {"records": records})
+
+
def ip_mgmt_view(request):
- # records = IPManagementRecord.objects.all()
- if request.user.is_authenticated:
- records = IPManagementRecord.objects.filter(author=request.user).order_by(
- "ip_addrs"
+ query = request.GET.get("var_search", "").strip()
+
+ records = IPManagementRecord.objects.order_by(
+ "ip_addrs"
+ )
+
+ if query:
+ records = records.filter(
+ # Q(author__username__icontains=query) | Q(author__email__icontains=query)
+ Q(author__username__icontains=query) | Q(network_nm__icontains=query)
)
- else:
- # records = IPManagementRecord.objects.none()
- records = IPManagementRecord.objects.all().order_by("ip_addrs")
- return render(request, "butler/ip_mgmt.html", {"records": records})
+ """
+ SELECT * FROM ip_management_record AS ip JOIN auth_user AS au
+ ON ip.author_id = au.id
+ WHERE au.username LIKE CONCAT('%', 조회할 값, '%')
+ OR au.email LIKE CONCAT('%', 조회할 값, '%')
+ ORDER BY ip.ip_addrs;
+ """
+ records = records.order_by("ip_addrs")
+ return render(request, "butler/ip_mgmt.html", {"records": records, "var_search": query})
def add_ip_record(request):
@@ -93,9 +118,9 @@ def privacy_view(request):
with open(file_path, "r", encoding="utf-8") as file:
text = file.read()
- file_path = Path('docs/docs_md_files/privacy.md')
+ file_path = Path("docs/docs_md_files/privacy.md")
- with file_path.open('r', encoding='utf-8') as file:
+ with file_path.open("r", encoding="utf-8") as file:
text = file.read()
# Markdown을 HTML로 변환
# html_content = markdown.markdown(text)
diff --git a/version b/version
index c43ed23..a6a1681 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-dev_0.0.19r1
\ No newline at end of file
+dev_0.0.20
\ No newline at end of file