-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from sparcs-kaist/feat/board-group
Add Board Group Model
- Loading branch information
Showing
13 changed files
with
198 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/core/migrations/0053_remove_board_banner_url_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 4.2.3 on 2023-07-21 12:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0052_alter_board_slug"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="board", | ||
name="banner_url", | ||
), | ||
migrations.AlterField( | ||
model_name="board", | ||
name="en_banner_description", | ||
field=models.TextField( | ||
blank=True, default="", verbose_name="게시판 배너에 삽입되는 영문 소개" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="board", | ||
name="ko_banner_description", | ||
field=models.TextField( | ||
blank=True, default="", verbose_name="게시판 배너에 삽입되는 국문 소개" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 4.2.3 on 2023-07-21 12:40 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0053_remove_board_banner_url_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="BoardGroup", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"ko_name", | ||
models.CharField(max_length=64, verbose_name="게시판 그룹 국문 이름"), | ||
), | ||
( | ||
"en_name", | ||
models.CharField(max_length=64, verbose_name="게시판 그룹 영문 이름"), | ||
), | ||
( | ||
"slug", | ||
models.SlugField(max_length=32, unique=True, verbose_name="슬러그"), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "게시판 그룹", | ||
"verbose_name_plural": "게시판 그룹 목록", | ||
}, | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
apps/core/migrations/0055_remove_board_group_id_board_group.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 4.2.3 on 2023-07-22 14:30 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0054_boardgroup"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="board", | ||
name="group_id", | ||
), | ||
migrations.AddField( | ||
model_name="board", | ||
name="group", | ||
field=models.ForeignKey( | ||
default=None, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="boards", | ||
to="core.boardgroup", | ||
verbose_name="게시판 그룹", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.db import models | ||
|
||
|
||
class BoardGroup(models.Model): | ||
ko_name = models.CharField( | ||
verbose_name="게시판 그룹 국문 이름", | ||
max_length=64, | ||
) | ||
en_name = models.CharField( | ||
verbose_name="게시판 그룹 영문 이름", | ||
max_length=64, | ||
) | ||
slug = models.SlugField( | ||
verbose_name="슬러그", | ||
max_length=32, | ||
unique=True, | ||
) | ||
|
||
class Meta: | ||
verbose_name = "게시판 그룹" | ||
verbose_name_plural = "게시판 그룹 목록" | ||
|
||
def __str__(self) -> str: | ||
return self.ko_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from rest_framework import serializers | ||
|
||
from apps.core.models.board_group import BoardGroup | ||
from apps.core.serializers.board import SimpleBoardSerializer | ||
|
||
|
||
class BoardGroupSerializer(serializers.ModelSerializer): | ||
boards = SimpleBoardSerializer(many=True, read_only=True) | ||
|
||
class Meta: | ||
model = BoardGroup | ||
fields = ["id", "slug", "ko_name", "en_name", "boards"] | ||
depth = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from rest_framework import permissions, viewsets | ||
|
||
from apps.core.models import BoardGroup | ||
from apps.core.serializers.board_group import BoardGroupSerializer | ||
|
||
|
||
class BoardGroupViewSet(viewsets.ReadOnlyModelViewSet): | ||
queryset = BoardGroup.objects.all() | ||
serializer_class = BoardGroupSerializer | ||
permission_classes = [permissions.IsAuthenticated] | ||
lookup_field = "slug" | ||
pagination_class = None |