Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phase1の機能実装 [feat/#43] #45

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6edbbd0
#43 通知ページの修正.
yoneyan Sep 7, 2024
0975a7f
#43 コード整形.
yoneyan Sep 7, 2024
b7ac2b4
#43 サイドバーのボタン位置調整.
yoneyan Sep 7, 2024
c07319d
#43 掲載終了の通知情報を削除するスクリプト.
yoneyan Sep 8, 2024
18816f1
#43 django signalsが実行出来ない問題の修正.
yoneyan Sep 8, 2024
f8340bf
#43 READMEの更新.
yoneyan Sep 8, 2024
8e39145
#43 ideaファイルの更新.
yoneyan Sep 8, 2024
6534b17
#43 グループに関する情報をトップページに表示など.
yoneyan Sep 8, 2024
a9df51a
#43 pre-commit機能の追加.
yoneyan Sep 8, 2024
5c4a5f5
#43 リファクタリング
yoneyan Sep 8, 2024
5a3c913
#43 開発用の環境を整備 for web.
yoneyan Sep 8, 2024
66f50e7
#43 ライブラリのアップデート for web.
yoneyan Sep 8, 2024
832fbad
#43 サービス情報と接続情報の登録機能の実装.
yoneyan Sep 14, 2024
b1b5420
#43 Webフォルダの削除(不要のため).
yoneyan Sep 14, 2024
6e7c654
#43 routerやnoc modelの修正.
yoneyan Sep 14, 2024
c314df9
#43 ライブラリのアップデート.
yoneyan Sep 14, 2024
cee3ec8
#43 軽微な修正.
yoneyan Sep 14, 2024
1cce464
#43 チケットシステムの修正とメール送信機能の追加.
yoneyan Sep 14, 2024
8f7986e
#43 django-simple-historyを使った履歴を記録する仕組みを導入.
yoneyan Sep 14, 2024
a091b14
#43 DB情報更新時にSlack通知する機能の実装.
yoneyan Sep 15, 2024
d98bcad
#43 UserモードでSlack通知出来ない問題の修正.
yoneyan Sep 15, 2024
8f8ba91
#43 通知機能の改修(登録時の処理).
yoneyan Sep 15, 2024
fd4c913
#43 リファクタリング.
yoneyan Sep 15, 2024
69f9199
#43 リファクタリング.
yoneyan Sep 15, 2024
3ec7eec
#43 pipenv install忘れの修正.
yoneyan Sep 15, 2024
29a723a
#43 Dockerfileの更新&workflowsファイルの修正.
yoneyan Sep 15, 2024
3afd2dc
#43 管理者モード時にタグを表示機能の追加.
yoneyan Sep 15, 2024
d340ff2
#43 リファクタリング.
yoneyan Sep 15, 2024
812a1a4
#43 ライブラリのアップデート.
yoneyan Sep 16, 2024
0e280e9
#43 会費支払いシステムの実装.
yoneyan Sep 16, 2024
320f2f5
#43 文言の修正.
yoneyan Sep 16, 2024
f1982c3
#43 donationシステムの実装.
yoneyan Sep 16, 2024
2aed855
#43 文字サイズの変更.
yoneyan Sep 16, 2024
c3f1614
#43 ライブラリのアップデート.
yoneyan Sep 23, 2024
4c8d41f
#43 ライブラリのアップデート.
yoneyan Nov 23, 2024
de6f31a
#43 pipライブラリのアップデート.
yoneyan Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## 変更内容

- なにか

## 変更理由

- なにか

## 動作確認

1. hogehoge1
2. hogehoge2
3. hogehoge3
12 changes: 11 additions & 1 deletion .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ on:
paths:
- '.github/**'
- 'files/**'
- 'custom_admin/**'
- 'custom_auth/**'
- 'dsbd/**'
- 'ip/**'
- 'noc/**'
- 'notice/**'
- 'router/**'
- 'service/**'
- 'ticket/**'
- 'manage.py'
- 'Dockerfile'
- 'requirements.txt'
- 'Pipfile'
- 'Pipfile.lock'

jobs:
push_to_registry:
Expand Down
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.4 AS app
FROM python:3.12 AS app

RUN pip install --upgrade pip && pip install pipenv
RUN apt-get update && \
Expand All @@ -17,7 +17,7 @@ RUN pip install gunicorn daphne
ENV PYTHONPATH=/opt/app/
ADD Pipfile /opt/app/Pipfile
ADD Pipfile.lock /opt/app/Pipfile.lock
RUN pipenv install --system
RUN pipenv sync --system

ADD manage.py /opt/app/
ADD dsbd/ /opt/app/dsbd/
Expand Down
30 changes: 16 additions & 14 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,47 @@ autobahn = "==24.*"
automat = "==24.*"
certifi = "==2024.*"
cffi = "==1.*"
channels = "==4.1.0"
channels = "==4.*"
charset-normalizer = "==3.*"
constantly = "==23.10.4"
constantly = "==23.*"
cryptography = "==43.*"
daphne = "==4.1.2"
django = "==5.1.*"
django-auth-ldap = "==4.*"
daphne = "==4.*"
django = "==5.*"
django-auth-ldap = "==5.*"
django-countries = "==7.*"
django-debug-toolbar = "==4.*"
django-qrcode = "==0.3"
django-widget-tweaks = "==1.5.0"
hyperlink = "==21.0.0"
django-qrcode = "==0.*"
django-widget-tweaks = "==1.*"
hyperlink = "==21.*"
idna = "==3.*"
incremental = "==24.*"
markdown = "==3.*"
mysqlclient = "==2.*"
pyasn1 = "==0.6.0"
pyasn1-modules = "==0.4.0"
pycparser = "==2.22"
pyasn1 = "==0.6.*"
pyasn1-modules = "==0.4.*"
pycparser = "==2.*"
pyopenssl = "==24.*"
pyotp = "==2.9.0"
pypng = "==0.20220715.0"
python-ldap = "==3.*"
pytz = "==2024.*"
qrcode = "==7.*"
qrcode = "==8.*"
requests = "==2.*"
service-identity = "==24.*"
six = "==1.*"
slack-sdk = "==3.*"
sqlparse = "==0.*"
stripe = "==10.*"
stripe = "==11.*"
twisted = "==24.*"
txaio = "==23.*"
typing-extensions = "==4.*"
urllib3 = "==2.*"
"zope.interface" = "==7.*"
django-simple-history = "*"

[dev-packages]
black = "*"
ruff = "*"
ruff-lsp = "*"

[requires]
python_version = "3.12"
585 changes: 313 additions & 272 deletions Pipfile.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# dsbd
Home NOC Dashboard

HomeNOC Dashboard

[![Publish Docker image(dev)](https://github.com/homenoc/dsbd/actions/workflows/build-dev.yaml/badge.svg)](https://github.com/homenoc/dsbd/actions/workflows/build-dev.yaml)
[![Publish Docker image(prod)](https://github.com/homenoc/dsbd/actions/workflows/build-prod.yaml/badge.svg)](https://github.com/homenoc/dsbd/actions/workflows/build-prod.yaml)
### develop environment

### develop environment install

```
mkdir venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pre-commit install # pre-commitを入れる必要あり
pipenv install --dev
```

### run server

```
python3 manage.py runserver --settings=dsbd.settings
pipenv run python3 manage.py runserver --settings=dsbd.settings
```

## make migration
Expand Down
54 changes: 31 additions & 23 deletions custom_admin/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import json

from asgiref.sync import sync_to_async
from channels.generic.websocket import AsyncWebsocketConsumer
from django.conf import settings
from django.utils import timezone
from pytz import timezone

from ticket.consumers import ChatConsumer
from ticket.models import Ticket, Chat
from ticket.models import Chat, Ticket


@sync_to_async()
Expand Down Expand Up @@ -44,18 +42,24 @@ async def receive(self, text_data=None, bytes_data=None):
await self.add_chat(message)

time_format = "%Y/%m/%d %H:%M:%S"
time = datetime.datetime.now(tz=datetime.timezone.utc if settings.USE_TZ else None).astimezone(
timezone(settings.TIME_ZONE)).strftime(time_format)

await self.channel_layer.group_send(self.chat_group_name, {
"type": "broadcast_message",
"time": time,
"user_id": self.user.id,
"username": self.user.username,
"group": 0,
"message": message,
"is_admin": True
})
time = (
datetime.datetime.now(tz=datetime.timezone.utc if settings.USE_TZ else None)
.astimezone(timezone(settings.TIME_ZONE))
.strftime(time_format)
)

await self.channel_layer.group_send(
self.chat_group_name,
{
"type": "broadcast_message",
"time": time,
"user_id": self.user.id,
"username": self.user.username,
"group": 0,
"message": message,
"is_admin": True,
},
)

async def broadcast_message(self, event):
time = event["time"]
Expand All @@ -65,11 +69,15 @@ async def broadcast_message(self, event):
message = event["message"]
is_admin = event["is_admin"]

await self.send(text_data=json.dumps({
"time": time,
"user_id": user_id,
"username": username,
"group": group,
"message": message,
"is_admin": is_admin
}))
await self.send(
text_data=json.dumps(
{
"time": time,
"user_id": user_id,
"username": username,
"group": group,
"message": message,
"is_admin": is_admin,
}
)
)
3 changes: 2 additions & 1 deletion custom_admin/routing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.urls import path

from . import consumers

urlpatterns = [
path('ws/admin/custom/ticket/<int:ticket_id>/chat', consumers.AdminChatConsumer.as_asgi()),
path("ws/admin/custom/ticket/<int:ticket_id>/chat", consumers.AdminChatConsumer.as_asgi()),
]
2 changes: 1 addition & 1 deletion custom_admin/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import path, include
from django.urls import path

from . import views

Expand Down
18 changes: 7 additions & 11 deletions custom_admin/views.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
import json

from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from django.core.paginator import EmptyPage, InvalidPage, Paginator
from django.shortcuts import render, redirect
from django.shortcuts import redirect, render

from ticket.models import Ticket


@login_required
@staff_member_required
def index(request):
context = {
"tickets": Ticket.objects.all()
}
context = {"tickets": Ticket.objects.all()}
return render(request, "custom_admin/index.html", context)


@login_required
@staff_member_required
def ticket_list(request):
if request.method == 'POST':
id = request.POST.get('id', 0)
if request.method == "POST":
id = request.POST.get("id", 0)
ticket = Ticket.objects.get(id=int(id))
if "no_solved" in request.POST:
ticket.is_solved = False
ticket.save()
elif "solved" in request.POST:
ticket.is_solved = True
ticket.save()
return redirect('/admin/custom/ticket')
return redirect("/admin/custom/ticket")

is_solved = request.GET.get('is_solved', "false")
is_solved = request.GET.get("is_solved", "false")
ticket_objects = Ticket.objects.filter(is_solved=True if is_solved == "true" else False)

paginator = Paginator(ticket_objects, int(request.GET.get("per_page", "5")))
Expand All @@ -53,5 +49,5 @@ def chat(request, ticket_id):
ticket = Ticket.objects.get(id=ticket_id)
if not ticket:
return render(request, "ticket/chat_error.html", {})
context = {"ticket": ticket, "chats": ticket.chat_set.order_by('created_at').all()}
context = {"ticket": ticket, "chats": ticket.chat_set.order_by("created_at").all()}
return render(request, "custom_admin/ticket/chat.html", context)
Loading
Loading