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 37 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 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
e3f9c67
#43 pipライブラリのアップデート.
yoneyan Jan 5, 2025
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
Prev Previous commit
Next Next commit
#43 django-simple-historyを使った履歴を記録する仕組みを導入.
yoneyan committed Sep 14, 2024
commit 8f7986ec013532f28bfb8e6d355cafaa300084f7
5 changes: 3 additions & 2 deletions custom_auth/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
from simple_history.admin import SimpleHistoryAdmin

from custom_auth.models import Group, TOTPDevice, User, UserActivateToken
from ip.models import JPNICUser
@@ -46,7 +47,7 @@ def id_link(self, obj):


@admin.register(User)
class User(admin.ModelAdmin):
class User(SimpleHistoryAdmin):
fieldsets = (
(None, {"fields": ("username", "username_jp", "password")}),
("Personal info", {"fields": ("email",)}),
@@ -77,7 +78,7 @@ def get_groups(self, obj):


@admin.register(Group)
class Group(admin.ModelAdmin):
class Group(SimpleHistoryAdmin):
fieldsets = (
(None, {"fields": ("name", "name_jp", "allow_service_add", "allow_jpnic_add", "is_pass", "comment")}),
("Membership", {"fields": ("membership_type", "membership_expired_at")}),
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Generated by Django 5.1.1 on 2024-09-14 20:33

import django.contrib.auth.validators
import django.db.models.deletion
import django.utils.timezone
import dsbd.models
import simple_history.models
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('custom_auth', '0006_group_allow_jpnic_add'),
]

operations = [
migrations.CreateModel(
name='HistoricalGroup',
fields=[
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('created_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='作成日')),
('updated_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='更新日')),
('name', models.CharField(db_index=True, max_length=150, verbose_name='name')),
('name_jp', models.CharField(db_index=True, max_length=150, verbose_name='name(japanese)')),
('comment', models.CharField(blank=True, default='', max_length=250, verbose_name='comment')),
('status', models.IntegerField(choices=[(1, '有効'), (10, 'ユーザより廃止'), (11, '運営委員より廃止'), (12, '審査落ち')], default=1, verbose_name='ステータス')),
('allow_service_add', models.BooleanField(default=False, verbose_name='サービス追加許可')),
('allow_jpnic_add', models.BooleanField(default=False, verbose_name='JPNIC情報追加許可')),
('membership_type', models.IntegerField(choices=[(1, '一般会員'), (40, '運営委員(優勝)'), (70, '学生委員'), (90, '運営委員(無償)'), (99, 'その他')], default=1, verbose_name='会員種別')),
('membership_expired_at', models.DateTimeField(blank=True, null=True, verbose_name='有効期限')),
('agree', models.BooleanField(default=False, verbose_name='規約確認済み')),
('question', dsbd.models.MediumTextField(default='', verbose_name='質問内容')),
('is_pass', models.BooleanField(default=False, verbose_name='審査OK')),
('stripe_customer_id', models.CharField(blank=True, max_length=200, null=True, verbose_name='Stripe(CusID)')),
('stripe_subscription_id', models.CharField(blank=True, max_length=200, null=True, verbose_name='Stripe(SubID)')),
('postcode', models.CharField(default='', max_length=20, verbose_name='郵便番号')),
('address', models.CharField(default='', max_length=250, verbose_name='住所')),
('address_jp', models.CharField(default='', max_length=250, verbose_name='住所(Japanese)')),
('phone', models.CharField(default='', max_length=30, verbose_name='phone')),
('country', models.CharField(default='Japan', max_length=100, verbose_name='居住国')),
('contract_type', models.CharField(choices=[('E-Mail', 'E-Mail'), ('AirMail', 'AirMail)')], default='E-Mail', max_length=100, verbose_name='契約種別')),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField(db_index=True)),
('history_change_reason', models.CharField(max_length=100, null=True)),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'historical グループ',
'verbose_name_plural': 'historical グループ',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': ('history_date', 'history_id'),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name='HistoricalUser',
fields=[
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('created_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='作成日')),
('updated_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='更新日')),
('display_name', models.CharField(blank=True, default='', max_length=150, verbose_name='display_name')),
('username', models.CharField(db_index=True, max_length=150, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('username_jp', models.CharField(db_index=True, max_length=150, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username(japanese)')),
('email', models.EmailField(db_index=True, max_length=254, verbose_name='email')),
('is_staff', models.BooleanField(default=False, verbose_name='管理者ステータス')),
('is_active', models.BooleanField(default=False, verbose_name='有効')),
('allow_group_add', models.BooleanField(default=True, verbose_name='グループ追加許可')),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField(db_index=True)),
('history_change_reason', models.CharField(max_length=100, null=True)),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'historical ユーザ',
'verbose_name_plural': 'historical ユーザ',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': ('history_date', 'history_id'),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
migrations.CreateModel(
name='HistoricalUserGroup',
fields=[
('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('created_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='作成日')),
('updated_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='更新日')),
('is_admin', models.BooleanField(default=False, verbose_name='管理者')),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField(db_index=True)),
('history_change_reason', models.CharField(max_length=100, null=True)),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('group', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='custom_auth.group')),
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'historical ユーザ・グループ',
'verbose_name_plural': 'historical ユーザ・グループ',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': ('history_date', 'history_id'),
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
]
4 changes: 4 additions & 0 deletions custom_auth/models.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
from django.db import models
from django.template.loader import render_to_string
from django.utils import timezone
from simple_history.models import HistoricalRecords

from custom_auth.tool import random_string
from dsbd.models import MediumTextField
@@ -109,6 +110,7 @@ class Group(models.Model): # noqa: F811
through_fields=("group", "user"),
related_name="group_users_set",
)
history = HistoricalRecords()

objects = GroupManager()

@@ -215,6 +217,7 @@ class User(AbstractBaseUser):
through_fields=("user", "group"),
related_name="user_set",
)
history = HistoricalRecords()

objects = UserManager()

@@ -313,6 +316,7 @@ class UserGroup(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
group = models.ForeignKey(Group, on_delete=models.CASCADE)
is_admin = models.BooleanField("管理者", default=False)
history = HistoricalRecords()

class Meta:
verbose_name = "ユーザ・グループ"
2 changes: 2 additions & 0 deletions dsbd/settings.py
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ def _import_ldap_group_type(group_type_name):
"router",
"ip",
"service",
"simple_history",
]

MIDDLEWARE = [
@@ -79,6 +80,7 @@ def _import_ldap_group_type(group_type_name):
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"simple_history.middleware.HistoryRequestMiddleware",
]

AUTHENTICATION_BACKENDS = [
5 changes: 3 additions & 2 deletions ip/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin

from .models import IP, JPNICUser

@@ -15,7 +16,7 @@ class TermInlineJPNICUserAdmin(admin.TabularInline):


@admin.register(IP)
class IP(admin.ModelAdmin):
class IP(SimpleHistoryAdmin):
fieldsets = (
(
None,
@@ -49,7 +50,7 @@ class IP(admin.ModelAdmin):


@admin.register(JPNICUser)
class JPNICUser(admin.ModelAdmin):
class JPNICUser(SimpleHistoryAdmin):
fieldsets = (
(
None,
Loading