ip관리대장 검색기능 추가
All checks were successful
Build And Test / build-and-push (push) Successful in 4m20s
All checks were successful
Build And Test / build-and-push (push) Successful in 4m20s
This commit is contained in:
parent
c3f86c0902
commit
222c90b5d9
@ -6,8 +6,25 @@
|
|||||||
<h2 class="fw-bold pt-3 pb-2">IP 관리 대장</h2>
|
<h2 class="fw-bold pt-3 pb-2">IP 관리 대장</h2>
|
||||||
{% if not request.user.is_authenticated %}
|
{% if not request.user.is_authenticated %}
|
||||||
<p class="text-danger">비로그인 익명사용자로 접근 중입니다.
|
<p class="text-danger">비로그인 익명사용자로 접근 중입니다.
|
||||||
<br>로그인시 로그인 사용자가 등록한 데이터만 조회됩니다.</p>
|
<br>로그인시 로그인 사용자가 등록한 데이터만 조회됩니다.
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<!-- 검색 폼 -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<form method="get" class="mb-3">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="var_search" class="form-control" placeholder="Search by Author or Network Name..."
|
||||||
|
value="{{ var_search }}">
|
||||||
|
<button type="submit" class="btn btn-outline-primary">Search</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- IP 레코드 목록 -->
|
<!-- IP 레코드 목록 -->
|
||||||
<form id="recordForm" method="post" action="">
|
<form id="recordForm" method="post" action="">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
@ -28,7 +45,8 @@
|
|||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<tr data-record-id="{{ record.id }}">
|
<tr data-record-id="{{ record.id }}">
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<input type="checkbox" name="selected_records" value="{{ record.id }}" class="form-check-input record-checkbox">
|
<input type="checkbox" name="selected_records" value="{{ record.id }}"
|
||||||
|
class="form-check-input record-checkbox">
|
||||||
</td>
|
</td>
|
||||||
<td>{{ record.network_nm }}</td>
|
<td>{{ record.network_nm }}</td>
|
||||||
<td>{{ record.ip_addrs }}</td>
|
<td>{{ record.ip_addrs }}</td>
|
||||||
@ -40,7 +58,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- 수정 모달 -->
|
<!-- 수정 모달 -->
|
||||||
<div class="modal fade" id="editDataModal-{{ record.id }}" tabindex="-1" aria-labelledby="editDataModalLabel-{{ record.id }}" aria-hidden="true">
|
<div class="modal fade" id="editDataModal-{{ record.id }}" tabindex="-1"
|
||||||
|
aria-labelledby="editDataModalLabel-{{ record.id }}" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-warning text-dark">
|
<div class="modal-header bg-warning text-dark">
|
||||||
@ -53,15 +72,18 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="networkNm-{{ record.id }}" class="form-label">Network Name</label>
|
<label for="networkNm-{{ record.id }}" class="form-label">Network Name</label>
|
||||||
<input type="text" class="form-control" id="networkNm-{{ record.id }}" name="network_nm" value="{{ record.network_nm }}" required="required">
|
<input type="text" class="form-control" id="networkNm-{{ record.id }}" name="network_nm"
|
||||||
|
value="{{ record.network_nm }}" required="required">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="ipAddrs-{{ record.id }}" class="form-label">IP Address</label>
|
<label for="ipAddrs-{{ record.id }}" class="form-label">IP Address</label>
|
||||||
<input type="text" class="form-control" id="ipAddrs-{{ record.id }}" name="ip_addrs" value="{{ record.ip_addrs }}" required="required">
|
<input type="text" class="form-control" id="ipAddrs-{{ record.id }}" name="ip_addrs"
|
||||||
|
value="{{ record.ip_addrs }}" required="required">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="svrNm-{{ record.id }}" class="form-label">Server Name</label>
|
<label for="svrNm-{{ record.id }}" class="form-label">Server Name</label>
|
||||||
<input type="text" class="form-control" id="svrNm-{{ record.id }}" name="svr_nm" value="{{ record.svr_nm }}" required="required">
|
<input type="text" class="form-control" id="svrNm-{{ record.id }}" name="svr_nm"
|
||||||
|
value="{{ record.svr_nm }}" required="required">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="desc-{{ record.id }}" class="form-label">Description</label>
|
<label for="desc-{{ record.id }}" class="form-label">Description</label>
|
||||||
@ -69,7 +91,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="remark-{{ record.id }}" class="form-label">Remark</label>
|
<label for="remark-{{ record.id }}" class="form-label">Remark</label>
|
||||||
<textarea class="form-control" id="remark-{{ record.id }}" name="remark">{{ record.remark }}</textarea>
|
<textarea class="form-control" id="remark-{{ record.id }}"
|
||||||
|
name="remark">{{ record.remark }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -3,6 +3,7 @@ from pathlib import Path
|
|||||||
import markdown
|
import markdown
|
||||||
import os
|
import os
|
||||||
from .models import NoticeBoard, IPManagementRecord
|
from .models import NoticeBoard, IPManagementRecord
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
def hello_view(request):
|
def hello_view(request):
|
||||||
@ -28,16 +29,40 @@ def notice_detail_view(request, pk):
|
|||||||
|
|
||||||
|
|
||||||
# --- ip management ---
|
# --- 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):
|
def ip_mgmt_view(request):
|
||||||
# records = IPManagementRecord.objects.all()
|
query = request.GET.get("var_search", "").strip()
|
||||||
if request.user.is_authenticated:
|
|
||||||
records = IPManagementRecord.objects.filter(author=request.user).order_by(
|
records = IPManagementRecord.objects.order_by(
|
||||||
"ip_addrs"
|
"ip_addrs"
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
# records = IPManagementRecord.objects.none()
|
if query:
|
||||||
records = IPManagementRecord.objects.all().order_by("ip_addrs")
|
records = records.filter(
|
||||||
return render(request, "butler/ip_mgmt.html", {"records": records})
|
# Q(author__username__icontains=query) | Q(author__email__icontains=query)
|
||||||
|
Q(author__username__icontains=query) | Q(network_nm__icontains=query)
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
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):
|
def add_ip_record(request):
|
||||||
@ -93,9 +118,9 @@ def privacy_view(request):
|
|||||||
with open(file_path, "r", encoding="utf-8") as file:
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
text = file.read()
|
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()
|
text = file.read()
|
||||||
# Markdown을 HTML로 변환
|
# Markdown을 HTML로 변환
|
||||||
# html_content = markdown.markdown(text)
|
# html_content = markdown.markdown(text)
|
||||||
|
Loading…
Reference in New Issue
Block a user