Skip to content

Commit

Permalink
Merge pull request #51 from pythonkr/devdev
Browse files Browse the repository at this point in the history
운영 배포
  • Loading branch information
golony6449 authored Mar 5, 2023
2 parents 6613c38 + 9b65283 commit 7c347be
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pythonkr/PyConKR-2023
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### 목표
*

### 작업내용
### 작업 내용
*

### 유의사항
* 리뷰어는 `PyConKR-2023`지정 해 주세요.
### 유의 사항
* 리뷰어는 `PyConKR-2023`지정해주세요.
* 작업한 내용을 상세하게 작성해주세요.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_on_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: psf/black@stable
with:
options: "--check --verbose --exclude migrations"
options: "--check --verbose"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_on_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: psf/black@stable
with:
options: "--check --verbose --exclude migrations"
options: "--check --verbose"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-merge-precondition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

- uses: psf/black@stable
with:
options: "--check --verbose --exclude migrations"
options: "--check --verbose"

- uses: isort/isort-action@master
with:
configuration: "--check-only --diff --profile black"
configuration: "--check-only --diff"
requirementsFiles: "requirements.txt"

- name: install dependencies
Expand Down
Empty file added program/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions program/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions program/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ProgramConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "program"
Empty file added program/migrations/__init__.py
Empty file.
89 changes: 89 additions & 0 deletions program/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from django.contrib.auth import get_user_model
from django.db import models

User = get_user_model()


class ProposalCategory(models.Model):
name = models.CharField(max_length=100, db_index=True)
visible = models.BooleanField(default=True)

def __str__(self):
return self.name


class Proposal(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)

title = models.CharField(max_length=255)
brief = models.TextField(max_length=1000, help_text="리뷰용: 발표에 대한 간단한 설명.")
desc = models.TextField(max_length=4000, help_text="리뷰용: 발표에 대한 자세한 설명")
comment = models.TextField(
max_length=4000, null=True, blank=True, help_text="리뷰용: 파준위에게 전하고 싶은 말"
)

difficulty = models.CharField(
max_length=15,
choices=(
("BEGINNER", "Beginner"),
("INTERMEDIATE", "Intermediate"),
("EXPERIENCED", "Experienced"),
),
)

duration = models.CharField(
max_length=15,
choices=(
("SHORT", "25min"),
("LONG", "40min"),
),
)

language = models.CharField(
max_length=15,
choices=(
("", "---------"),
("KOREAN", "Korean"),
("ENGLISH", "English"),
),
default="",
)

category = models.ForeignKey(
ProposalCategory,
on_delete=models.SET_DEFAULT,
null=True,
blank=True,
default=14,
)
accepted = models.BooleanField(default=False)
introduction = models.TextField(
max_length=2000,
null=True,
blank=True,
help_text="발표 소개 페이지에 들어가는 내용입니다. 변경 사항은 최대 60분 이내에 적용됩니다.",
)
video_url = models.CharField(
max_length=255, null=True, blank=True, help_text="발표 영상 URL"
)
slide_url = models.CharField(
max_length=255, null=True, blank=True, help_text="발표 자료 URL"
)
room_num = models.CharField(
max_length=15,
null=True,
blank=True,
help_text="발표장소",
choices=(
("101", "101"),
("102", "102"),
("103", "103"),
("104", "104"),
("105", "105"),
),
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.title
45 changes: 45 additions & 0 deletions program/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from rest_framework.serializers import ModelSerializer

from program.models import Proposal, ProposalCategory


class ProposalSerializer(ModelSerializer):
class Meta:
model = Proposal
fields = [
"user",
"title",
"brief",
"desc",
"comment",
"difficulty",
"duration",
"language",
"category",
"accepted",
"introduction",
"video_url",
"slide_url",
"room_num",
]


class ProposalListSerializer(ModelSerializer):
class Meta:
model = Proposal
fields = [
"title",
"brief",
"difficulty",
"duration",
"language",
"category",
]


class ProposalCategorySerializer(ModelSerializer):
class Meta:
model = ProposalCategory
fields = [
"name",
]
3 changes: 3 additions & 0 deletions program/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions program/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
9 changes: 7 additions & 2 deletions pyconkr/settings-dev.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from pyconkr.settings import *
from pyconkr.storage import *

DEBUG = True

Expand All @@ -22,8 +23,12 @@

# django-storages: S3
del MEDIA_ROOT
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
# DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
# STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"

DEFAULT_FILE_STORAGE = "pyconkr.storage.MediaStorage"
STATICFILES_STORAGE = "pyconkr.storage.StaticStorage"

AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
AWS_DEFAULT_REGION = "ap-northeast-2"
Expand Down
6 changes: 6 additions & 0 deletions pyconkr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
APPEND_SLASH = False

ALLOWED_HOSTS = []

Expand All @@ -47,11 +48,14 @@
"status",
# swagger
"drf_spectacular",
# cors
"corsheaders",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
Expand Down Expand Up @@ -170,3 +174,5 @@
# available SwaggerUI versions: https://github.com/swagger-api/swagger-ui/releases
"SWAGGER_UI_DIST": "//unpkg.com/swagger-ui-dist@3.35.1",
}

CORS_ALLOW_ALL_ORIGINS = True
12 changes: 12 additions & 0 deletions pyconkr/storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.conf import settings
from storages.backends.s3boto3 import S3Boto3Storage, S3StaticStorage


class MediaStorage(S3Boto3Storage):
def _get_security_token(self):
return None


class StaticStorage(S3StaticStorage):
def _get_security_token(self):
return None
4 changes: 2 additions & 2 deletions pyconkr/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
path("api-auth/", include("rest_framework.urls")),
path("summernote/", include("django_summernote.urls")),
path("admin/", admin.site.urls),
path("sponsors/", include(sponsor.routers.get_router().urls)),
path("status/", include(status.urls)),
path("sponsors", include(sponsor.routers.get_router().urls)),
path("status", include(status.urls)),
]

if settings.DEBUG is True:
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tool.black]
line-length = 88
include = '\.pyi?$'
extend-exclude = '''
(
migrations
)
'''

[tool.isort]
extend_skip = ["migrations"]
profile = "black"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Pillow==9.4.0
django-constance==2.9.1
django-picklefield==3.1
drf-spectacular==0.25.1
django-cors-headers==3.14.0
14 changes: 7 additions & 7 deletions sponsor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SponsorLevel(models.Model):
)
visible = models.BooleanField(default=True)
price = models.IntegerField(default=0)
limit = models.IntegerField(default=0, help_text="후원사 등급 별 구좌수")
limit = models.IntegerField(default=0, help_text="후원사 등급별 구좌 수")
order = models.IntegerField(default=1)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Expand Down Expand Up @@ -64,8 +64,8 @@ class Meta:

creator = models.ForeignKey(
User,
null=True, # TODO: 추루 로그인 적용 후 입력
blank=True, # TODO: 추루 로그인 적용 후 입력
null=True, # TODO: 추후 로그인 적용 후 입력
blank=True, # TODO: 추후 로그인 적용 후 입력
on_delete=models.CASCADE,
help_text="후원사를 등록한 유저",
related_name="sponsor_creator",
Expand Down Expand Up @@ -110,7 +110,7 @@ class Meta:
max_length=100,
null=True,
blank=True,
help_text="후원사 사업자 등록번호입니다. 세금 계산서 발급에 사용됩니다.",
help_text="후원사 사업자 등록 번호입니다. 세금 계산서 발급에 사용됩니다.",
)
business_registration_file = models.FileField(
null=True,
Expand All @@ -123,13 +123,13 @@ class Meta:
null=True,
blank=True,
upload_to=bank_book_file_upload_to,
help_text="후원사 사업자 등록증 스캔본입니다. 세금 계산서 발급에 사용됩니다.",
help_text="후원사 통장 사본입니다.",
)
url = models.CharField(
max_length=255,
null=True,
blank=True,
help_text="파이콘 홈페이지에 공개되는 후원사 홈페이지 주소입니다.",
help_text="파이콘 한국 홈페이지에 공개되는 후원사 홈페이지 주소입니다.",
)
logo_image = SorlImageField(
upload_to=logo_image_upload_to,
Expand All @@ -150,5 +150,5 @@ class Meta:
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

def __str_(self):
def __str__(self):
return f"{self.name}/{self.level}"
4 changes: 2 additions & 2 deletions sponsor/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

def get_router():
router = DefaultRouter()
router.register("remaining", SponsorRemainingAccountViewSet, basename="remaining")
router.register("prospectus", SponsorLevelViewSet, basename="prospectus")
router.register("/remaining", SponsorRemainingAccountViewSet, basename="remaining")
router.register("/prospectus", SponsorLevelViewSet, basename="prospectus")
router.register("", SponsorViewSet, basename="sponsor")

return router
Loading

0 comments on commit 7c347be

Please sign in to comment.