diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1144112 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +SECRET_KEY='django-insecure-@z03)1f&@(m*+xbz#la#_#h&d1*83qhuk8%z%lr)qgwz3%1h@2' +DEBUG=True diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..c96b671 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,27 @@ +--- +name: Bug template +about: 버그 발생 시 사용하는 템플릿입니다 +title: "버그 리포트" +labels: "bug" +assignees: + +--- + +## 버그에 대한 설명 +버그가 무엇인지 명확하고 간결하게 설명합니다. + +## 재현 방법 +어떤 식으로 발생했는지 순서대로 작성해주세요: +1. 어디를 가서 '....' +2. 어떤 행동을 했더니 '...' +3. 에러가 나왔다 ' ... ' + +## 예상 동작 +발생할 것으로 예상한 사항에 대한 명확하고 간결한 설명. + +## 스크린샷 +해당하는 경우 스크린샷을 추가하여 문제를 설명. + + +## 추가 내용 +여기에 문제에 대한 다른 내용을 추가합니다. diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md new file mode 100644 index 0000000..f1a746d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -0,0 +1,28 @@ +--- +name: Issue template +about: 이슈 작성 시 사용하는 템플릿입니다 +title: "이슈 리포트" +labels: "" +assignees: + +--- + +## 이슈 내용 +> 이슈 내용 작성 + +
+ +## 작업 사항 +- [ ] 해당 이슈의 작업사항 + +
+ +## 관련 이슈 +- #이슈 번호 + +
+ +## 기타사항 + + +
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..96e4408 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,37 @@ +## PR 체크리스트 +아래 항목을 확인해 주세요: + +- [ ] 커밋 메시지가 우리의 가이드라인을 따르고 있는지 확인하세요 +- [ ] 변경 사항에 대한 테스트가 추가되었는지 확인하세요 (버그 수정 / 기능 추가) +- [ ] 문서가 추가되거나 업데이트되었는지 확인하세요 (버그 수정 / 기능 추가) + +## PR 유형 +이 PR은 어떤 종류의 변경을 가져오나요? + + + +- [ ] 버그 수정 +- [ ] 새로운 기능 추가 +- [ ] 코드 스타일 업데이트 (서식, 로컬 변수) +- [ ] 리팩터링 (기능 변경 없음, API 변경 없음) +- [ ] 빌드 관련 변경 +- [ ] CI 관련 변경 +- [ ] 문서 내용 변경 +- [ ] 애플리케이션 / 인프라 변경 +- [ ] 기타... 설명: + +## 현재 동작은 무엇인가요? + + +이슈 번호: N/A + +## 새로운 동작은 무엇인가요? + +## 이 PR은 호환성 변경을 도입하나요? + +- [ ] 예 +- [ ] 아니요 + + + +## 기타 정보 diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..5e0e2e0 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,29 @@ +name: CI + +on: + pull_request: + branches: [ "develop", "main" ] + +jobs: + django-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build docker + run: docker compose build + + - name: Migration test database + run: docker compose run django poetry run python src/manage.py migrate + + - name: Run isort + run: docker compose run django poetry run isort . --check + + - name: Run black + run: docker compose run django poetry run black . --check + + - name: Run flake8 + run: docker compose run django poetry run flake8 + + - name: Run Test + run: docker compose run django poetry run python3 src/manage.py test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ea4b8b --- /dev/null +++ b/.gitignore @@ -0,0 +1,344 @@ +# Created by https://www.toptal.com/developers/gitignore/api/django,macos,visualstudiocode,windows,python +# Edit at https://www.toptal.com/developers/gitignore?templates=django,macos,visualstudiocode,windows,python + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# Cython debug symbols + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/django,macos,visualstudiocode,windows,python diff --git a/.gitmessage.txt b/.gitmessage.txt new file mode 100644 index 0000000..ca15b3d --- /dev/null +++ b/.gitmessage.txt @@ -0,0 +1,29 @@ +################ +# <타입> : <제목> 의 형식으로 제목을 아래 공백줄에 작성 +# 제목은 50자 이내 / 변경사항이 "무엇"인지 명확히 작성 / 끝에 마침표 금지 +# 예) :sparkles:Feat : 로그인 기능 추가 # 이슈번호 + +# 바로 아래 공백은 지우지 마세요 (제목과 본문의 분리를 위함) + +################ +# 본문(구체적인 내용)을 아랫줄에 작성 +# 여러 줄의 메시지를 작성할 땐 "-"로 구분 (한 줄은 72자 이내) +# '왜'라는 것에 초점을 맞춰 작성 + +################ +# 꼬릿말(footer)을 아랫줄에 작성 (현재 커밋과 관련된 이슈 번호 추가 등) +# 해결 -> Closes(종료), Fixes(수정), Resolves(해결) +# 참고 -> Ref(참고), Related to(관련), See also(참고) +# 예) Close #7 + +################ +# :tada:Init: 프로젝트 개시 +# :sparkles:Feat : 새로운 기능 추가 +# :bug:Fix : 버그 수정 +# :fire:Remove : 코드 삭제 +# :memo:Docs : 문서 수정 +# :white_check_mark:Test : 테스트 코드, 리팩토링 테스트 코드 추가 +# :recycle:Refact : 코드 리팩토링 +# :rocket:Deploy : 배포 +# :hammer:Chore : 빌드 업무 수정, 패키지 매니저 수정 +################ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a7574aa --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/ambv/black + rev: 23.7.0 + hooks: + - id: black + args: ['-l', '140', '-t', 'py311'] + + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: + - --remove-all-unused-imports + - --remove-unused-variables + - --ignore-init-module-imports + - --in-place + - --recursive + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: ['--profile', 'black', '--filter-files', 'true'] + +default_language_version: + python: python3.11 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f5bd247 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM python:3.11-slim + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 +ENV POETRY_VERSION=1.6.1 +ENV POETRY_HOME=/opt/poetry +ENV POETRY_VENV=/opt/poetry-venv + +RUN python3 -m venv $POETRY_VENV \ + && $POETRY_VENV/bin/pip install -U pip setuptools \ + && $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION} + +ENV PATH="${PATH}:${POETRY_VENV}/bin" + +RUN mkdir /app/ +RUN mkdir /app/src/ +WORKDIR /app + +COPY pyproject.toml /app/ +COPY setup.cfg /app/ + +RUN poetry install diff --git a/README.md b/README.md index 3e6145c..ca3799c 100644 --- a/README.md +++ b/README.md @@ -1 +1,190 @@ -# repo_1 \ No newline at end of file +# 소셜미디어 통합 Feed 서비스 +
+ +## Table of Contents +- [개요](#개요) +- [기술스택](#기술스택) +- [설치](#설치) +- [테스트](#테스트) +- [APIs](#APIs) +- [팀원 및 회고](#팀원-및-회고) + +
+## 개요 +- 본 서비스는 복수의 SNS에 게시된 게시물을 하나의 서비스에서 확인할 수 있는 통합 Feed 어플리케이션입니다. +- `인스타그램`, `스레드`, `페이스북`, `트위터` 등 사용하고 있는 다양한 SNS에 게시된 게시물을 유저 계정 해시태그 (예, `#dami` ) 또는 특정 해시태그를 기반으로 확인할 수 있습니다. +- 본 서비스의 이용을 원하는 고객은 가입 진행 시 계정, 비밀번호, 이메일 정보를 제공해야 하며, 가입 승인을 위해 이메일로 발송된 코드를 입력하여 가입 승인을 받아야 서비스 이용이 가능합니다. +- 본 서비스의 메뉴는 통합 Feed 단일이며, 조회된 게시물의 제목 및 내용과 관련한 키워드를 검색 할 수 있고, 검색하여 나온 결과를 통해 원하는 게시물들을 조회할 수 있습니다. +- 본 서비스의 고객은 본인의 기호에 따라 게시물에 좋아요를 클릭하여 `view_count` 횟수를 증가 시킬 수 있으며, 해당 횟수는 제한이 없습니다. 또한 게시물 공유가 가능하며 공유 시 `share_count`가 증가하게 됩니다. +- 본 서비스의 고객은 해시태그를 기반으로 일자별, 시간별 게시물 개수 통계를 확인할 수 있습니다. 일자별 조회는 최대 한달(30일)이며, 시간별 조회는 최대 일주일(7일) 조회가 가능합니다. + +## 기술스택 +### Backend +
+
+ + + + + +
+ +
+Why? + +Django +``` +1. 간단한 설정 및 빠른 개발 +https://docs.djangoproject.com/ko/4.2/misc/design-philosophies/ +장고의 철학 중 하나인 신속한 개발이 포함. 해당 과제를 수행으로 +빠른 기능 구현을 위해 사용 +2. 강력한 ORM +길어질 수 있는 SQL쿼리를 직접 작성하지 않고 데이터베이스를 조작하기 위해 ORM +을 사용 가능하기에 사용 +3. 커뮤니티 활성화 +파이썬 프레임워크 커뮤니티 중 가장 거대하고 활성화가 되어있고 자료 검색 용이를 +위해 사용 +``` + +DRF(Django Rest Framework) +``` +1. RESTfrul API 지원 +DRF에서 RESTful API구축하는데 필요한 모든 도구와 기능을 제공 +(시리얼라이저, URL, 테스트 API 뷰 등등) +2. 직렬화 및 역질렬화 +데이터 모델을 JSON 또는 다른 형식의 데이터로 변환하고 그 역도 가능하도록 +도와주는 강력한 직렬화 및 역직렬화 기능을 제공 +3. 인증 및 권한 관리 +DRF는 사용자 인증 및 권한 관리를 위한 다양한 방법을 제공 +``` + +Docker & Docker-compose +``` +배포를 위해서가 아니라 github actions와 데이터베이스(Postgres)를 사용 +어느 동일한 개발 환경을 테스트를 위해 격리된 환경을 제공하고 환경 설정할 수 있기에 +사용 docker-compose의 경우 두개 이상의 컨테이너가 존재하기에 yaml파일을 정의해서 +간단하게 사용 가능하기에 사용 +``` +
+ +
+ +### DB + +
+Why? +데이터베이스 변경 이슈 + +해당 과제에 간단한 CRUD만 된다고 생각하여 기본으로 제공하는 SQLite를 사용하기로 했습니다. 하지만 아래의 문제점, 원인으로 인하여 PostgreSQL를 사용했습니다. +문제점: 통계 API 작성 중에서 날짜 집계 함수를 사용하려고 했습니다. TruncDay라는 함수가 있는데 django.db.utils.OperationalError: user- +defined function raised exception가 발생= +원인: SQLite에서 datetime을 지원하지 않아 함수 사용이 불가 + +Postgres +```json +1. Djang는 PostgreSQL에서만 작동하는 다양한 데이터 유형을 제공 +2. Django에는 PostgreSQL에서 데이터베이스 작업을 수행하기 위한 django.contrib.postgres가 있음 + +``` +- Django공식문서 Postgres + +[PostgreSQL 관련 집계 함수](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/aggregates/) + +[PostgreSQL 관련 데이터베이스 제약 조건](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/constraints/) + +[PostgreSQL 관련 양식 필드 및 위젯](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/forms/) + +[PostgreSQL 관련 데이터베이스 기능](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/functions/) + +[PostgreSQL 관련 모델 인덱스](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/indexes/) + +[PostgreSQL 관련 조회](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/lookups/) + +[데이터베이스 마이그레이션 작업](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/operations/) + +[전체 텍스트 검색](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/search/) + +[인덱스](https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/validators/) +
+
+ +### Managements +
+ + + +
+
+Why? +Git & Github + +```json +1. 버전관리 +소스 코드를 효과적으로 버전 관리할 수 있는 도구로, +개발자들은 변경 내용을 추적하고 이전 버전으로 되돌릴 수 있음 +이를 통해 협업 중 코드 충돌을 방지하고 안정적인 코드베이스를 유지 + +2. GitHub +Git 저장소를 호스팅하고 협업을 간편하게 할 수 있게 해주는 플랫폼 +여러 개발자가 동시에 작업하고 변경 사항을 추적하며 코드 검토 및 이슈 관리를 쉽게 할 수 있음 + +``` + +Github Actions + +```json +팀 내의 코드 컨벤션, 테스트 코드 작성, 이를 바탕으로 CI를 적용하기 위해서 +깃 허브에서 간단한 설정 및 연동이 가능한 github actions를 사용 +``` +
+ +
+ +## 설치 +docker-compose로 django(어플리케이션)과 postgre(데이터베이스)를 구성합니다. +- docker-compose로 django(어플리케이션)과 postgre(데이터베이스)를 구성하였습니다. + +```python +docker compose up # running server to http://127.0.0.1:8000 +``` + +
+ +## 테스트 +- django 컨테이너에서 poetry로 구성하면서 app과 app/src로 구성되며, src의 test를 진행합니다. + +```python +docker compose run django poetry run python3 src/manage.py test src/ +``` + +![test](test.png) + +
+ +## APIs +| 앱 | 기능 | URL | Method | Parameter | Return | +| --- | --- | --- | --- | --- | --- | +| users | 회원 가입 | /users/confirm/ | POST | {email, username, password} | {email, username, confirmcode} | +| | 가입 승인 | /users/login/ | POST | {username, password, code} | {username, isConfirmed} | +| | 로그인 | /users/signup/ | POST | {username, password} | {username, token{refresh, access}} | +| | token 재발급 | /users/token/refresh | POST | {refresh_token} | {access_token} | +| posts | 게시물 리스트 조회 | /posts/ | GET | {limit, offset, type, search, ordering, hastag} | PostList{contentId, postType, title, content, viewCount, likeCount, shareCount, createdAt, updatedAt, hashtag, user} | +| | 게시물 상세 조회 | /posts/{id} | GET | {content_id} | PostDetail{contentId, postType, title, content, viewCount, likeCount, shareCount, createdAt, updatedAt, hashtag, user} | +| | 통계 정보 조회 | /posts/statistics | GET | {type, start, end, hashtag, value} | {datetime, count} | +| | 최근 많이 사용된 해시태그 조회 | /posts/hashtag/recommend | GET | | {hashtag_id, hashtag_name} | +| likes | 게시물에 좋아요 | /likes/{id} | POST | {content_id} | | +| shares | 게시물 공유 | /shares/{id} | POST | {content_id} | | + +
+ +## 팀원 및 회고 +
+ +| name | title | profile link | email | review | +|------|-------|--------------|-------|--------| +| 윤성원 | 팀장 | [@lfoyh6591](https://github.com/lfoyh6591) | lfoyh6591@naver.com | https://determined-chamomile-42b.notion.site/835d8c6783a2477499438c07e1a7c125?pvs=4 +| 사재혁 | 팀원 | [@saJaeHyukc](https://github.com/saJaeHyukc) | wogur981208@gmail.com | https://determined-chamomile-42b.notion.site/f86b007c44954ab6947dbf2a445ee67f?pvs=4 +| 박대준 | 팀원 | [@Chestnut90](https://github.com/Chestnut90) | cowzon90@gmail.com | https://determined-chamomile-42b.notion.site/09b567f9f59747ee86d4074659211a3a?pvs=4 +| 이슬기 | 팀원 | [@simseulnyang](https://github.com/simseulnyang) | happysseul627@gmail.com | https://determined-chamomile-42b.notion.site/5491797e84834a26a32a0f8ce58e51d8?pvs=4 + +
diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8d895c0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.9' + +volumes: + postgres: {} + +services: + postgres: + container_name: postgres + image: postgres:16.0-alpine + volumes: + - postgres:/var/lib/postgresql/data/ + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=password + - POSTGRES_DB=repo_1 + - TZ=Asia/Seoul + restart: on-failure + + django: + container_name: django + build: + context: . + dockerfile: Dockerfile + command: > + bash -c "poetry run python src/manage.py makemigrations && + poetry run python src/manage.py migrate && + poetry run python src/manage.py runserver 0.0.0.0:8000" + volumes: + - ./src:/app/src/ + environment: + - POSTGRESQL_HOST=postgres + ports: + - "8000:8000" + depends_on: + - postgres + restart: on-failure diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..46f7b4b --- /dev/null +++ b/poetry.lock @@ -0,0 +1,832 @@ +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. + +[[package]] +name = "asgiref" +version = "3.7.2" +description = "ASGI specs, helper code, and adapters" +optional = false +python-versions = ">=3.7" +files = [ + {file = "asgiref-3.7.2-py3-none-any.whl", hash = "sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e"}, + {file = "asgiref-3.7.2.tar.gz", hash = "sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed"}, +] + +[package.extras] +tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] + +[[package]] +name = "black" +version = "23.10.1" +description = "The uncompromising code formatter." +optional = false +python-versions = ">=3.8" +files = [ + {file = "black-23.10.1-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:ec3f8e6234c4e46ff9e16d9ae96f4ef69fa328bb4ad08198c8cee45bb1f08c69"}, + {file = "black-23.10.1-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:1b917a2aa020ca600483a7b340c165970b26e9029067f019e3755b56e8dd5916"}, + {file = "black-23.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c74de4c77b849e6359c6f01987e94873c707098322b91490d24296f66d067dc"}, + {file = "black-23.10.1-cp310-cp310-win_amd64.whl", hash = "sha256:7b4d10b0f016616a0d93d24a448100adf1699712fb7a4efd0e2c32bbb219b173"}, + {file = "black-23.10.1-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:b15b75fc53a2fbcac8a87d3e20f69874d161beef13954747e053bca7a1ce53a0"}, + {file = "black-23.10.1-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:e293e4c2f4a992b980032bbd62df07c1bcff82d6964d6c9496f2cd726e246ace"}, + {file = "black-23.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d56124b7a61d092cb52cce34182a5280e160e6aff3137172a68c2c2c4b76bcb"}, + {file = "black-23.10.1-cp311-cp311-win_amd64.whl", hash = "sha256:3f157a8945a7b2d424da3335f7ace89c14a3b0625e6593d21139c2d8214d55ce"}, + {file = "black-23.10.1-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:cfcce6f0a384d0da692119f2d72d79ed07c7159879d0bb1bb32d2e443382bf3a"}, + {file = "black-23.10.1-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:33d40f5b06be80c1bbce17b173cda17994fbad096ce60eb22054da021bf933d1"}, + {file = "black-23.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:840015166dbdfbc47992871325799fd2dc0dcf9395e401ada6d88fe11498abad"}, + {file = "black-23.10.1-cp38-cp38-win_amd64.whl", hash = "sha256:037e9b4664cafda5f025a1728c50a9e9aedb99a759c89f760bd83730e76ba884"}, + {file = "black-23.10.1-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:7cb5936e686e782fddb1c73f8aa6f459e1ad38a6a7b0e54b403f1f05a1507ee9"}, + {file = "black-23.10.1-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:7670242e90dc129c539e9ca17665e39a146a761e681805c54fbd86015c7c84f7"}, + {file = "black-23.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ed45ac9a613fb52dad3b61c8dea2ec9510bf3108d4db88422bacc7d1ba1243d"}, + {file = "black-23.10.1-cp39-cp39-win_amd64.whl", hash = "sha256:6d23d7822140e3fef190734216cefb262521789367fbdc0b3f22af6744058982"}, + {file = "black-23.10.1-py3-none-any.whl", hash = "sha256:d431e6739f727bb2e0495df64a6c7a5310758e87505f5f8cde9ff6c0f2d7e4fe"}, + {file = "black-23.10.1.tar.gz", hash = "sha256:1f8ce316753428ff68749c65a5f7844631aa18c8679dfd3ca9dc1a289979c258"}, +] + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + +[[package]] +name = "cffi" +version = "1.16.0" +description = "Foreign Function Interface for Python calling C code." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cffi-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6b3d6606d369fc1da4fd8c357d026317fbb9c9b75d36dc16e90e84c26854b088"}, + {file = "cffi-1.16.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ac0f5edd2360eea2f1daa9e26a41db02dd4b0451b48f7c318e217ee092a213e9"}, + {file = "cffi-1.16.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7e61e3e4fa664a8588aa25c883eab612a188c725755afff6289454d6362b9673"}, + {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a72e8961a86d19bdb45851d8f1f08b041ea37d2bd8d4fd19903bc3083d80c896"}, + {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5b50bf3f55561dac5438f8e70bfcdfd74543fd60df5fa5f62d94e5867deca684"}, + {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7651c50c8c5ef7bdb41108b7b8c5a83013bfaa8a935590c5d74627c047a583c7"}, + {file = "cffi-1.16.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e4108df7fe9b707191e55f33efbcb2d81928e10cea45527879a4749cbe472614"}, + {file = "cffi-1.16.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:32c68ef735dbe5857c810328cb2481e24722a59a2003018885514d4c09af9743"}, + {file = "cffi-1.16.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:673739cb539f8cdaa07d92d02efa93c9ccf87e345b9a0b556e3ecc666718468d"}, + {file = "cffi-1.16.0-cp310-cp310-win32.whl", hash = "sha256:9f90389693731ff1f659e55c7d1640e2ec43ff725cc61b04b2f9c6d8d017df6a"}, + {file = "cffi-1.16.0-cp310-cp310-win_amd64.whl", hash = "sha256:e6024675e67af929088fda399b2094574609396b1decb609c55fa58b028a32a1"}, + {file = "cffi-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b84834d0cf97e7d27dd5b7f3aca7b6e9263c56308ab9dc8aae9784abb774d404"}, + {file = "cffi-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b8ebc27c014c59692bb2664c7d13ce7a6e9a629be20e54e7271fa696ff2b417"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ee07e47c12890ef248766a6e55bd38ebfb2bb8edd4142d56db91b21ea68b7627"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8a9d3ebe49f084ad71f9269834ceccbf398253c9fac910c4fd7053ff1386936"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e70f54f1796669ef691ca07d046cd81a29cb4deb1e5f942003f401c0c4a2695d"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5bf44d66cdf9e893637896c7faa22298baebcd18d1ddb6d2626a6e39793a1d56"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b78010e7b97fef4bee1e896df8a4bbb6712b7f05b7ef630f9d1da00f6444d2e"}, + {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c6a164aa47843fb1b01e941d385aab7215563bb8816d80ff3a363a9f8448a8dc"}, + {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e09f3ff613345df5e8c3667da1d918f9149bd623cd9070c983c013792a9a62eb"}, + {file = "cffi-1.16.0-cp311-cp311-win32.whl", hash = "sha256:2c56b361916f390cd758a57f2e16233eb4f64bcbeee88a4881ea90fca14dc6ab"}, + {file = "cffi-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:db8e577c19c0fda0beb7e0d4e09e0ba74b1e4c092e0e40bfa12fe05b6f6d75ba"}, + {file = "cffi-1.16.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:fa3a0128b152627161ce47201262d3140edb5a5c3da88d73a1b790a959126956"}, + {file = "cffi-1.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:68e7c44931cc171c54ccb702482e9fc723192e88d25a0e133edd7aff8fcd1f6e"}, + {file = "cffi-1.16.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:abd808f9c129ba2beda4cfc53bde801e5bcf9d6e0f22f095e45327c038bfe68e"}, + {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:88e2b3c14bdb32e440be531ade29d3c50a1a59cd4e51b1dd8b0865c54ea5d2e2"}, + {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fcc8eb6d5902bb1cf6dc4f187ee3ea80a1eba0a89aba40a5cb20a5087d961357"}, + {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b7be2d771cdba2942e13215c4e340bfd76398e9227ad10402a8767ab1865d2e6"}, + {file = "cffi-1.16.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e715596e683d2ce000574bae5d07bd522c781a822866c20495e52520564f0969"}, + {file = "cffi-1.16.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:2d92b25dbf6cae33f65005baf472d2c245c050b1ce709cc4588cdcdd5495b520"}, + {file = "cffi-1.16.0-cp312-cp312-win32.whl", hash = "sha256:b2ca4e77f9f47c55c194982e10f058db063937845bb2b7a86c84a6cfe0aefa8b"}, + {file = "cffi-1.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:68678abf380b42ce21a5f2abde8efee05c114c2fdb2e9eef2efdb0257fba1235"}, + {file = "cffi-1.16.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc"}, + {file = "cffi-1.16.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a09582f178759ee8128d9270cd1344154fd473bb77d94ce0aeb2a93ebf0feaf0"}, + {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e760191dd42581e023a68b758769e2da259b5d52e3103c6060ddc02c9edb8d7b"}, + {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:80876338e19c951fdfed6198e70bc88f1c9758b94578d5a7c4c91a87af3cf31c"}, + {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a6a14b17d7e17fa0d207ac08642c8820f84f25ce17a442fd15e27ea18d67c59b"}, + {file = "cffi-1.16.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6602bc8dc6f3a9e02b6c22c4fc1e47aa50f8f8e6d3f78a5e16ac33ef5fefa324"}, + {file = "cffi-1.16.0-cp38-cp38-win32.whl", hash = "sha256:131fd094d1065b19540c3d72594260f118b231090295d8c34e19a7bbcf2e860a"}, + {file = "cffi-1.16.0-cp38-cp38-win_amd64.whl", hash = "sha256:31d13b0f99e0836b7ff893d37af07366ebc90b678b6664c955b54561fc36ef36"}, + {file = "cffi-1.16.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:582215a0e9adbe0e379761260553ba11c58943e4bbe9c36430c4ca6ac74b15ed"}, + {file = "cffi-1.16.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b29ebffcf550f9da55bec9e02ad430c992a87e5f512cd63388abb76f1036d8d2"}, + {file = "cffi-1.16.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dc9b18bf40cc75f66f40a7379f6a9513244fe33c0e8aa72e2d56b0196a7ef872"}, + {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cb4a35b3642fc5c005a6755a5d17c6c8b6bcb6981baf81cea8bfbc8903e8ba8"}, + {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b86851a328eedc692acf81fb05444bdf1891747c25af7529e39ddafaf68a4f3f"}, + {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c0f31130ebc2d37cdd8e44605fb5fa7ad59049298b3f745c74fa74c62fbfcfc4"}, + {file = "cffi-1.16.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f8e709127c6c77446a8c0a8c8bf3c8ee706a06cd44b1e827c3e6a2ee6b8c098"}, + {file = "cffi-1.16.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:748dcd1e3d3d7cd5443ef03ce8685043294ad6bd7c02a38d1bd367cfd968e000"}, + {file = "cffi-1.16.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8895613bcc094d4a1b2dbe179d88d7fb4a15cee43c052e8885783fac397d91fe"}, + {file = "cffi-1.16.0-cp39-cp39-win32.whl", hash = "sha256:ed86a35631f7bfbb28e108dd96773b9d5a6ce4811cf6ea468bb6a359b256b1e4"}, + {file = "cffi-1.16.0-cp39-cp39-win_amd64.whl", hash = "sha256:3686dffb02459559c74dd3d81748269ffb0eb027c39a6fc99502de37d501faa8"}, + {file = "cffi-1.16.0.tar.gz", hash = "sha256:bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0"}, +] + +[package.dependencies] +pycparser = "*" + +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + +[[package]] +name = "click" +version = "8.1.7" +description = "Composable command line interface toolkit" +optional = false +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "cryptography" +version = "41.0.5" +description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." +optional = false +python-versions = ">=3.7" +files = [ + {file = "cryptography-41.0.5-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:da6a0ff8f1016ccc7477e6339e1d50ce5f59b88905585f77193ebd5068f1e797"}, + {file = "cryptography-41.0.5-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:b948e09fe5fb18517d99994184854ebd50b57248736fd4c720ad540560174ec5"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d38e6031e113b7421db1de0c1b1f7739564a88f1684c6b89234fbf6c11b75147"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e270c04f4d9b5671ebcc792b3ba5d4488bf7c42c3c241a3748e2599776f29696"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ec3b055ff8f1dce8e6ef28f626e0972981475173d7973d63f271b29c8a2897da"}, + {file = "cryptography-41.0.5-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:7d208c21e47940369accfc9e85f0de7693d9a5d843c2509b3846b2db170dfd20"}, + {file = "cryptography-41.0.5-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:8254962e6ba1f4d2090c44daf50a547cd5f0bf446dc658a8e5f8156cae0d8548"}, + {file = "cryptography-41.0.5-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:a48e74dad1fb349f3dc1d449ed88e0017d792997a7ad2ec9587ed17405667e6d"}, + {file = "cryptography-41.0.5-cp37-abi3-win32.whl", hash = "sha256:d3977f0e276f6f5bf245c403156673db103283266601405376f075c849a0b936"}, + {file = "cryptography-41.0.5-cp37-abi3-win_amd64.whl", hash = "sha256:73801ac9736741f220e20435f84ecec75ed70eda90f781a148f1bad546963d81"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:3be3ca726e1572517d2bef99a818378bbcf7d7799d5372a46c79c29eb8d166c1"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:e886098619d3815e0ad5790c973afeee2c0e6e04b4da90b88e6bd06e2a0b1b72"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:573eb7128cbca75f9157dcde974781209463ce56b5804983e11a1c462f0f4e88"}, + {file = "cryptography-41.0.5-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:0c327cac00f082013c7c9fb6c46b7cc9fa3c288ca702c74773968173bda421bf"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:227ec057cd32a41c6651701abc0328135e472ed450f47c2766f23267b792a88e"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:22892cc830d8b2c89ea60148227631bb96a7da0c1b722f2aac8824b1b7c0b6b8"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:5a70187954ba7292c7876734183e810b728b4f3965fbe571421cb2434d279179"}, + {file = "cryptography-41.0.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:88417bff20162f635f24f849ab182b092697922088b477a7abd6664ddd82291d"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c707f7afd813478e2019ae32a7c49cd932dd60ab2d2a93e796f68236b7e1fbf1"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:580afc7b7216deeb87a098ef0674d6ee34ab55993140838b14c9b83312b37b86"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:fba1e91467c65fe64a82c689dc6cf58151158993b13eb7a7f3f4b7f395636723"}, + {file = "cryptography-41.0.5-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:0d2a6a598847c46e3e321a7aef8af1436f11c27f1254933746304ff014664d84"}, + {file = "cryptography-41.0.5.tar.gz", hash = "sha256:392cb88b597247177172e02da6b7a63deeff1937fa6fec3bbf902ebd75d97ec7"}, +] + +[package.dependencies] +cffi = ">=1.12" + +[package.extras] +docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.1.1)"] +docstest = ["pyenchant (>=1.6.11)", "sphinxcontrib-spelling (>=4.0.1)", "twine (>=1.12.0)"] +nox = ["nox"] +pep8test = ["black", "check-sdist", "mypy", "ruff"] +sdist = ["build"] +ssh = ["bcrypt (>=3.1.5)"] +test = ["pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] +test-randomorder = ["pytest-randomly"] + +[[package]] +name = "distlib" +version = "0.3.7" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.7-py2.py3-none-any.whl", hash = "sha256:2e24928bc811348f0feb63014e97aaae3037f2cf48712d51ae61df7fd6075057"}, + {file = "distlib-0.3.7.tar.gz", hash = "sha256:9dafe54b34a028eafd95039d5e5d4851a13734540f1331060d31c9916e7147a8"}, +] + +[[package]] +name = "django" +version = "4.2.6" +description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Django-4.2.6-py3-none-any.whl", hash = "sha256:a64d2487cdb00ad7461434320ccc38e60af9c404773a2f95ab0093b4453a3215"}, + {file = "Django-4.2.6.tar.gz", hash = "sha256:08f41f468b63335aea0d904c5729e0250300f6a1907bf293a65499496cdbc68f"}, +] + +[package.dependencies] +asgiref = ">=3.6.0,<4" +sqlparse = ">=0.3.1" +tzdata = {version = "*", markers = "sys_platform == \"win32\""} + +[package.extras] +argon2 = ["argon2-cffi (>=19.1.0)"] +bcrypt = ["bcrypt"] + +[[package]] +name = "django-environ" +version = "0.11.2" +description = "A package that allows you to utilize 12factor inspired environment variables to configure your Django application." +optional = false +python-versions = ">=3.6,<4" +files = [ + {file = "django-environ-0.11.2.tar.gz", hash = "sha256:f32a87aa0899894c27d4e1776fa6b477e8164ed7f6b3e410a62a6d72caaf64be"}, + {file = "django_environ-0.11.2-py2.py3-none-any.whl", hash = "sha256:0ff95ab4344bfeff693836aa978e6840abef2e2f1145adff7735892711590c05"}, +] + +[package.extras] +develop = ["coverage[toml] (>=5.0a4)", "furo (>=2021.8.17b43,<2021.9.dev0)", "pytest (>=4.6.11)", "sphinx (>=3.5.0)", "sphinx-notfound-page"] +docs = ["furo (>=2021.8.17b43,<2021.9.dev0)", "sphinx (>=3.5.0)", "sphinx-notfound-page"] +testing = ["coverage[toml] (>=5.0a4)", "pytest (>=4.6.11)"] + +[[package]] +name = "django-filter" +version = "23.3" +description = "Django-filter is a reusable Django application for allowing users to filter querysets dynamically." +optional = false +python-versions = ">=3.7" +files = [ + {file = "django-filter-23.3.tar.gz", hash = "sha256:015fe155582e1805b40629344e4a6cf3cc40450827d294d040b4b8c1749a9fa6"}, + {file = "django_filter-23.3-py3-none-any.whl", hash = "sha256:65bc5d1d8f4fff3aaf74cb5da537b6620e9214fb4b3180f6c560776b1b6dccd0"}, +] + +[package.dependencies] +Django = ">=3.2" + +[[package]] +name = "djangorestframework" +version = "3.14.0" +description = "Web APIs for Django, made easy." +optional = false +python-versions = ">=3.6" +files = [ + {file = "djangorestframework-3.14.0-py3-none-any.whl", hash = "sha256:eb63f58c9f218e1a7d064d17a70751f528ed4e1d35547fdade9aaf4cd103fd08"}, + {file = "djangorestframework-3.14.0.tar.gz", hash = "sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8"}, +] + +[package.dependencies] +django = ">=3.0" +pytz = "*" + +[[package]] +name = "djangorestframework-camel-case" +version = "1.4.2" +description = "Camel case JSON support for Django REST framework." +optional = false +python-versions = ">=3.5" +files = [ + {file = "djangorestframework-camel-case-1.4.2.tar.gz", hash = "sha256:cdae75846648abb6585c7470639a1d2fb064dc45f8e8b62aaa50be7f1a7a61f4"}, +] + +[[package]] +name = "djangorestframework-simplejwt" +version = "5.3.0" +description = "A minimal JSON Web Token authentication plugin for Django REST Framework" +optional = false +python-versions = ">=3.7" +files = [ + {file = "djangorestframework_simplejwt-5.3.0-py3-none-any.whl", hash = "sha256:631d7ae2ed4365d7196a35d3cc0f6d382f7bd3361fb24c894f8f92b4da5db27d"}, + {file = "djangorestframework_simplejwt-5.3.0.tar.gz", hash = "sha256:8e4c5dfca8d11c0b8a66dfd8a4e3fc1c6aa7ea188d10907ff91c942f4b52ed66"}, +] + +[package.dependencies] +django = ">=3.2" +djangorestframework = ">=3.10" +pyjwt = ">=1.7.1,<3" + +[package.extras] +crypto = ["cryptography (>=3.3.1)"] +dev = ["Sphinx (>=1.6.5,<2)", "cryptography", "flake8", "ipython", "isort", "pep8", "pytest", "pytest-cov", "pytest-django", "pytest-watch", "pytest-xdist", "python-jose (==3.3.0)", "sphinx-rtd-theme (>=0.1.9)", "tox", "twine", "wheel"] +doc = ["Sphinx (>=1.6.5,<2)", "sphinx-rtd-theme (>=0.1.9)"] +lint = ["flake8", "isort", "pep8"] +python-jose = ["python-jose (==3.3.0)"] +test = ["cryptography", "pytest", "pytest-cov", "pytest-django", "pytest-xdist", "tox"] + +[[package]] +name = "drf-yasg" +version = "1.21.7" +description = "Automated generation of real Swagger/OpenAPI 2.0 schemas from Django Rest Framework code." +optional = false +python-versions = ">=3.6" +files = [ + {file = "drf-yasg-1.21.7.tar.gz", hash = "sha256:4c3b93068b3dfca6969ab111155e4dd6f7b2d680b98778de8fd460b7837bdb0d"}, + {file = "drf_yasg-1.21.7-py3-none-any.whl", hash = "sha256:f85642072c35e684356475781b7ecf5d218fff2c6185c040664dd49f0a4be181"}, +] + +[package.dependencies] +django = ">=2.2.16" +djangorestframework = ">=3.10.3" +inflection = ">=0.3.1" +packaging = ">=21.0" +pytz = ">=2021.1" +pyyaml = ">=5.1" +uritemplate = ">=3.0.0" + +[package.extras] +coreapi = ["coreapi (>=2.3.3)", "coreschema (>=0.0.4)"] +validation = ["swagger-spec-validator (>=2.1.0)"] + +[[package]] +name = "filelock" +version = "3.12.4" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.12.4-py3-none-any.whl", hash = "sha256:08c21d87ded6e2b9da6728c3dff51baf1dcecf973b768ef35bcbc3447edb9ad4"}, + {file = "filelock-3.12.4.tar.gz", hash = "sha256:2e6f249f1f3654291606e046b09f1fd5eac39b360664c27f5aad072012f8bcbd"}, +] + +[package.extras] +docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] +typing = ["typing-extensions (>=4.7.1)"] + +[[package]] +name = "flake8" +version = "6.1.0" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.8.1" +files = [ + {file = "flake8-6.1.0-py2.py3-none-any.whl", hash = "sha256:ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5"}, + {file = "flake8-6.1.0.tar.gz", hash = "sha256:d5b3857f07c030bdb5bf41c7f53799571d75c4491748a3adcd47de929e34cd23"}, +] + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.11.0,<2.12.0" +pyflakes = ">=3.1.0,<3.2.0" + +[[package]] +name = "identify" +version = "2.5.30" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.30-py2.py3-none-any.whl", hash = "sha256:afe67f26ae29bab007ec21b03d4114f41316ab9dd15aa8736a167481e108da54"}, + {file = "identify-2.5.30.tar.gz", hash = "sha256:f302a4256a15c849b91cfcdcec052a8ce914634b2f77ae87dad29cd749f2d88d"}, +] + +[package.extras] +license = ["ukkonen"] + +[[package]] +name = "inflection" +version = "0.5.1" +description = "A port of Ruby on Rails inflector to Python" +optional = false +python-versions = ">=3.5" +files = [ + {file = "inflection-0.5.1-py2.py3-none-any.whl", hash = "sha256:f38b2b640938a4f35ade69ac3d053042959b62a0f1076a5bbaa1b9526605a8a2"}, + {file = "inflection-0.5.1.tar.gz", hash = "sha256:1a29730d366e996aaacffb2f1f1cb9593dc38e2ddd30c91250c6dde09ea9b417"}, +] + +[[package]] +name = "isort" +version = "5.12.0" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, + {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, +] + +[package.extras] +colors = ["colorama (>=0.4.3)"] +pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] +plugins = ["setuptools"] +requirements-deprecated-finder = ["pip-api", "pipreqs"] + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + +[[package]] +name = "mypy" +version = "1.6.1" +description = "Optional static typing for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "mypy-1.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e5012e5cc2ac628177eaac0e83d622b2dd499e28253d4107a08ecc59ede3fc2c"}, + {file = "mypy-1.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d8fbb68711905f8912e5af474ca8b78d077447d8f3918997fecbf26943ff3cbb"}, + {file = "mypy-1.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21a1ad938fee7d2d96ca666c77b7c494c3c5bd88dff792220e1afbebb2925b5e"}, + {file = "mypy-1.6.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b96ae2c1279d1065413965c607712006205a9ac541895004a1e0d4f281f2ff9f"}, + {file = "mypy-1.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:40b1844d2e8b232ed92e50a4bd11c48d2daa351f9deee6c194b83bf03e418b0c"}, + {file = "mypy-1.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:81af8adaa5e3099469e7623436881eff6b3b06db5ef75e6f5b6d4871263547e5"}, + {file = "mypy-1.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8c223fa57cb154c7eab5156856c231c3f5eace1e0bed9b32a24696b7ba3c3245"}, + {file = "mypy-1.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8032e00ce71c3ceb93eeba63963b864bf635a18f6c0c12da6c13c450eedb183"}, + {file = "mypy-1.6.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4c46b51de523817a0045b150ed11b56f9fff55f12b9edd0f3ed35b15a2809de0"}, + {file = "mypy-1.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:19f905bcfd9e167159b3d63ecd8cb5e696151c3e59a1742e79bc3bcb540c42c7"}, + {file = "mypy-1.6.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:82e469518d3e9a321912955cc702d418773a2fd1e91c651280a1bda10622f02f"}, + {file = "mypy-1.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d4473c22cc296425bbbce7e9429588e76e05bc7342da359d6520b6427bf76660"}, + {file = "mypy-1.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59a0d7d24dfb26729e0a068639a6ce3500e31d6655df8557156c51c1cb874ce7"}, + {file = "mypy-1.6.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:cfd13d47b29ed3bbaafaff7d8b21e90d827631afda134836962011acb5904b71"}, + {file = "mypy-1.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:eb4f18589d196a4cbe5290b435d135dee96567e07c2b2d43b5c4621b6501531a"}, + {file = "mypy-1.6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:41697773aa0bf53ff917aa077e2cde7aa50254f28750f9b88884acea38a16169"}, + {file = "mypy-1.6.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7274b0c57737bd3476d2229c6389b2ec9eefeb090bbaf77777e9d6b1b5a9d143"}, + {file = "mypy-1.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bbaf4662e498c8c2e352da5f5bca5ab29d378895fa2d980630656178bd607c46"}, + {file = "mypy-1.6.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bb8ccb4724f7d8601938571bf3f24da0da791fe2db7be3d9e79849cb64e0ae85"}, + {file = "mypy-1.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:68351911e85145f582b5aa6cd9ad666c8958bcae897a1bfda8f4940472463c45"}, + {file = "mypy-1.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:49ae115da099dcc0922a7a895c1eec82c1518109ea5c162ed50e3b3594c71208"}, + {file = "mypy-1.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8b27958f8c76bed8edaa63da0739d76e4e9ad4ed325c814f9b3851425582a3cd"}, + {file = "mypy-1.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:925cd6a3b7b55dfba252b7c4561892311c5358c6b5a601847015a1ad4eb7d332"}, + {file = "mypy-1.6.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8f57e6b6927a49550da3d122f0cb983d400f843a8a82e65b3b380d3d7259468f"}, + {file = "mypy-1.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:a43ef1c8ddfdb9575691720b6352761f3f53d85f1b57d7745701041053deff30"}, + {file = "mypy-1.6.1-py3-none-any.whl", hash = "sha256:4cbe68ef919c28ea561165206a2dcb68591c50f3bcf777932323bc208d949cf1"}, + {file = "mypy-1.6.1.tar.gz", hash = "sha256:4d01c00d09a0be62a4ca3f933e315455bde83f37f892ba4b08ce92f3cf44bcc1"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +typing-extensions = ">=4.1.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + +[[package]] +name = "packaging" +version = "23.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] + +[[package]] +name = "pathspec" +version = "0.11.2" +description = "Utility library for gitignore style pattern matching of file paths." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"}, + {file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"}, +] + +[[package]] +name = "platformdirs" +version = "3.11.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.7" +files = [ + {file = "platformdirs-3.11.0-py3-none-any.whl", hash = "sha256:e9d171d00af68be50e9202731309c4e658fd8bc76f55c11c7dd760d023bda68e"}, + {file = "platformdirs-3.11.0.tar.gz", hash = "sha256:cf8ee52a3afdb965072dcc652433e0c7e3e40cf5ea1477cd4b3b1d2eb75495b3"}, +] + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] + +[[package]] +name = "pre-commit" +version = "3.5.0" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.8" +files = [ + {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, + {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + +[[package]] +name = "psycopg2-binary" +version = "2.9.9" +description = "psycopg2 - Python-PostgreSQL Database Adapter" +optional = false +python-versions = ">=3.7" +files = [ + {file = "psycopg2-binary-2.9.9.tar.gz", hash = "sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c2470da5418b76232f02a2fcd2229537bb2d5a7096674ce61859c3229f2eb202"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c6af2a6d4b7ee9615cbb162b0738f6e1fd1f5c3eda7e5da17861eacf4c717ea7"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:75723c3c0fbbf34350b46a3199eb50638ab22a0228f93fb472ef4d9becc2382b"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ef4854e82c09e84cc63084a9e4ccd6d9b154f1dbdd283efb92ecd0b5e2b8c84"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed1184ab8f113e8d660ce49a56390ca181f2981066acc27cf637d5c1e10ce46e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d2997c458c690ec2bc6b0b7ecbafd02b029b7b4283078d3b32a852a7ce3ddd98"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b58b4710c7f4161b5e9dcbe73bb7c62d65670a87df7bcce9e1faaad43e715245"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:0c009475ee389757e6e34611d75f6e4f05f0cf5ebb76c6037508318e1a1e0d7e"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8dbf6d1bc73f1d04ec1734bae3b4fb0ee3cb2a493d35ede9badbeb901fb40f6f"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win32.whl", hash = "sha256:3f78fd71c4f43a13d342be74ebbc0666fe1f555b8837eb113cb7416856c79682"}, + {file = "psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:876801744b0dee379e4e3c38b76fc89f88834bb15bf92ee07d94acd06ec890a0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ee825e70b1a209475622f7f7b776785bd68f34af6e7a46e2e42f27b659b5bc26"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1ea665f8ce695bcc37a90ee52de7a7980be5161375d42a0b6c6abedbf0d81f0f"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:143072318f793f53819048fdfe30c321890af0c3ec7cb1dfc9cc87aa88241de2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c332c8d69fb64979ebf76613c66b985414927a40f8defa16cf1bc028b7b0a7b0"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7fc5a5acafb7d6ccca13bfa8c90f8c51f13d8fb87d95656d3950f0158d3ce53"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:977646e05232579d2e7b9c59e21dbe5261f403a88417f6a6512e70d3f8a046be"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b6356793b84728d9d50ead16ab43c187673831e9d4019013f1402c41b1db9b27"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:bc7bb56d04601d443f24094e9e31ae6deec9ccb23581f75343feebaf30423359"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:77853062a2c45be16fd6b8d6de2a99278ee1d985a7bd8b103e97e41c034006d2"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win32.whl", hash = "sha256:dc4926288b2a3e9fd7b50dc6a1909a13bbdadfc67d93f3374d984e56f885579d"}, + {file = "psycopg2_binary-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:b76bedd166805480ab069612119ea636f5ab8f8771e640ae103e05a4aae3e417"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f8544b092a29a6ddd72f3556a9fcf249ec412e10ad28be6a0c0d948924f2212"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2d423c8d8a3c82d08fe8af900ad5b613ce3632a1249fd6a223941d0735fce493"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2e5afae772c00980525f6d6ecf7cbca55676296b580c0e6abb407f15f3706996"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c77e3d1862452565875eb31bdb45ac62502feabbd53429fdc39a1cc341d681ba"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:cb16c65dcb648d0a43a2521f2f0a2300f40639f6f8c1ecbc662141e4e3e1ee07"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:911dda9c487075abd54e644ccdf5e5c16773470a6a5d3826fda76699410066fb"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2293b001e319ab0d869d660a704942c9e2cce19745262a8aba2115ef41a0a42a"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a602ea5aff39bb9fac6308e9c9d82b9a35c2bf288e184a816002c9fae930b77"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:275ff571376626195ab95a746e6a04c7df8ea34638b99fc11160de91f2fef503"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9b5571d33660d5009a8b3c25dc1db560206e2d2f89d3df1cb32d72c0d117d52"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:420f9bbf47a02616e8554e825208cb947969451978dceb77f95ad09c37791dae"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4154ad09dac630a0f13f37b583eae260c6aa885d67dfbccb5b02c33f31a6d420"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:a148c5d507bb9b4f2030a2025c545fccb0e1ef317393eaba42e7eabd28eb6041"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692"}, + {file = "psycopg2_binary-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:281309265596e388ef483250db3640e5f414168c5a67e9c665cafce9492eda2f"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:246b123cc54bb5361588acc54218c8c9fb73068bf227a4a531d8ed56fa3ca7d6"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:34eccd14566f8fe14b2b95bb13b11572f7c7d5c36da61caf414d23b91fcc5d94"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18d0ef97766055fec15b5de2c06dd8e7654705ce3e5e5eed3b6651a1d2a9a152"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d3f82c171b4ccd83bbaf35aa05e44e690113bd4f3b7b6cc54d2219b132f3ae55"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ead20f7913a9c1e894aebe47cccf9dc834e1618b7aa96155d2091a626e59c972"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ca49a8119c6cbd77375ae303b0cfd8c11f011abbbd64601167ecca18a87e7cdd"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:323ba25b92454adb36fa425dc5cf6f8f19f78948cbad2e7bc6cdf7b0d7982e59"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:1236ed0952fbd919c100bc839eaa4a39ebc397ed1c08a97fc45fee2a595aa1b3"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win32.whl", hash = "sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5"}, + {file = "psycopg2_binary-2.9.9-cp38-cp38-win_amd64.whl", hash = "sha256:a6cdcc3ede532f4a4b96000b6362099591ab4a3e913d70bcbac2b56c872446f7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:72dffbd8b4194858d0941062a9766f8297e8868e1dd07a7b36212aaa90f49472"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:30dcc86377618a4c8f3b72418df92e77be4254d8f89f14b8e8f57d6d43603c0f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31a34c508c003a4347d389a9e6fcc2307cc2150eb516462a7a17512130de109e"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:15208be1c50b99203fe88d15695f22a5bed95ab3f84354c494bcb1d08557df67"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1873aade94b74715be2246321c8650cabf5a0d098a95bab81145ffffa4c13876"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a58c98a7e9c021f357348867f537017057c2ed7f77337fd914d0bedb35dace7"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:ebdc36bea43063116f0486869652cb2ed7032dbc59fbcb4445c4862b5c1ecf7f"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:ca08decd2697fdea0aea364b370b1249d47336aec935f87b8bbfd7da5b2ee9c1"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ac05fb791acf5e1a3e39402641827780fe44d27e72567a000412c648a85ba860"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win32.whl", hash = "sha256:9dba73be7305b399924709b91682299794887cbbd88e38226ed9f6712eabee90"}, + {file = "psycopg2_binary-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:f7ae5d65ccfbebdfa761585228eb4d0df3a8b15cfb53bd953e713e09fbb12957"}, +] + +[[package]] +name = "pycodestyle" +version = "2.11.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, + {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, +] + +[[package]] +name = "pycparser" +version = "2.21" +description = "C parser in Python" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, + {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, +] + +[[package]] +name = "pyflakes" +version = "3.1.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyflakes-3.1.0-py2.py3-none-any.whl", hash = "sha256:4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774"}, + {file = "pyflakes-3.1.0.tar.gz", hash = "sha256:a0aae034c444db0071aa077972ba4768d40c830d9539fd45bf4cd3f8f6992efc"}, +] + +[[package]] +name = "pyjwt" +version = "2.8.0" +description = "JSON Web Token implementation in Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "PyJWT-2.8.0-py3-none-any.whl", hash = "sha256:59127c392cc44c2da5bb3192169a91f429924e17aff6534d70fdc02ab3e04320"}, + {file = "PyJWT-2.8.0.tar.gz", hash = "sha256:57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"}, +] + +[package.extras] +crypto = ["cryptography (>=3.4.0)"] +dev = ["coverage[toml] (==5.0.4)", "cryptography (>=3.4.0)", "pre-commit", "pytest (>=6.0.0,<7.0.0)", "sphinx (>=4.5.0,<5.0.0)", "sphinx-rtd-theme", "zope.interface"] +docs = ["sphinx (>=4.5.0,<5.0.0)", "sphinx-rtd-theme", "zope.interface"] +tests = ["coverage[toml] (==5.0.4)", "pytest (>=6.0.0,<7.0.0)"] + +[[package]] +name = "pytz" +version = "2023.3.post1" +description = "World timezone definitions, modern and historical" +optional = false +python-versions = "*" +files = [ + {file = "pytz-2023.3.post1-py2.py3-none-any.whl", hash = "sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7"}, + {file = "pytz-2023.3.post1.tar.gz", hash = "sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b"}, +] + +[[package]] +name = "pyyaml" +version = "6.0.1" +description = "YAML parser and emitter for Python" +optional = false +python-versions = ">=3.6" +files = [ + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, + {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, + {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, + {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, + {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, +] + +[[package]] +name = "setuptools" +version = "68.2.2" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "setuptools-68.2.2-py3-none-any.whl", hash = "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a"}, + {file = "setuptools-68.2.2.tar.gz", hash = "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + +[[package]] +name = "sqlparse" +version = "0.4.4" +description = "A non-validating SQL parser." +optional = false +python-versions = ">=3.5" +files = [ + {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, + {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, +] + +[package.extras] +dev = ["build", "flake8"] +doc = ["sphinx"] +test = ["pytest", "pytest-cov"] + +[[package]] +name = "typing-extensions" +version = "4.8.0" +description = "Backported and Experimental Type Hints for Python 3.8+" +optional = false +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, + {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, +] + +[[package]] +name = "tzdata" +version = "2023.3" +description = "Provider of IANA time zone data" +optional = false +python-versions = ">=2" +files = [ + {file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"}, + {file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"}, +] + +[[package]] +name = "uritemplate" +version = "4.1.1" +description = "Implementation of RFC 6570 URI Templates" +optional = false +python-versions = ">=3.6" +files = [ + {file = "uritemplate-4.1.1-py2.py3-none-any.whl", hash = "sha256:830c08b8d99bdd312ea4ead05994a38e8936266f84b9a7878232db50b044e02e"}, + {file = "uritemplate-4.1.1.tar.gz", hash = "sha256:4346edfc5c3b79f694bccd6d6099a322bbeb628dbf2cd86eea55a456ce5124f0"}, +] + +[[package]] +name = "virtualenv" +version = "20.24.6" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.24.6-py3-none-any.whl", hash = "sha256:520d056652454c5098a00c0f073611ccbea4c79089331f60bf9d7ba247bb7381"}, + {file = "virtualenv-20.24.6.tar.gz", hash = "sha256:02ece4f56fbf939dbbc33c0715159951d6bf14aaf5457b092e4548e1382455af"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<4" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.11" +content-hash = "b298590f281c93c72ca4fc9644daf53605d7e2eed620f11d674f6583c54f1ec9" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b2742cc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[tool.poetry] +name = "social media integration feed service" +version = "0.1.0" +description = "" +authors = ["SaJH "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.11" +django = "^4.2.5" +django-environ = "^0.11.2" +djangorestframework = "^3.14.0" +cryptography = "^41.0.4" +drf-yasg = "^1.21.7" +djangorestframework-simplejwt = "^5.3.0" +djangorestframework-camel-case = "^1.4.2" +psycopg2-binary = "^2.9.9" +django-filter = "^23.3" + +[tool.poetry.group.dev.dependencies] +mypy = "^1.5.1" + +flake8 = "^6.1.0" +isort = "^5.12.0" +black = "^23.9.1" +pre-commit = "^3.4.0" + +[tool.black] +line-length = 140 +target-version = ['py311'] +force-exclude = 'migrations' + +[tool.isort] +profile = "black" +filter_files = true +skip_glob = ["*/migrations/*", "config/*"] + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..aba2714 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[flake8] +max-line-length = 140 +extend-ignore = E203 +exclude = + .git, + __pycache__, + */migrations/* diff --git a/src/common/__init__.py b/src/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/common/apps.py b/src/common/apps.py new file mode 100644 index 0000000..3e1544e --- /dev/null +++ b/src/common/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CommonConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "common" diff --git a/src/common/decorator.py b/src/common/decorator.py new file mode 100644 index 0000000..4fdb8d5 --- /dev/null +++ b/src/common/decorator.py @@ -0,0 +1,30 @@ +from common.utils import mandatory_key, optional_key + + +def mandatories(*keys): + def decorate(func): + def wrapper(View, *args, **kwargs): + mandatory = dict() + for key in keys: + data = mandatory_key(View.request, key) + mandatory[key] = data + return func(View, m=mandatory, *args, **kwargs) + + return wrapper + + return decorate + + +def optionals(*keys): + def decorate(func): + def wrapper(View, *args, **kwargs): + optional = dict() + for arg in keys: + for key, val in arg.items(): + data = optional_key(View.request, key, val) + optional[key] = data + return func(View, o=optional, *args, **kwargs) + + return wrapper + + return decorate diff --git a/src/common/exceptions.py b/src/common/exceptions.py new file mode 100644 index 0000000..dfbe77f --- /dev/null +++ b/src/common/exceptions.py @@ -0,0 +1,26 @@ +from rest_framework import status +from rest_framework.exceptions import APIException + + +class MissingMandatoryParameterException(APIException): + status_code = status.HTTP_400_BAD_REQUEST + default_detail = "Missing mandatory parameter" + default_code = "missing_mandatory_parameter" + + +class InvalidParameterException(APIException): + status_code = status.HTTP_400_BAD_REQUEST + default_detail = "Invalid parameter" + default_code = "invalid_parameter" + + +class UnknownServerErrorException(APIException): + status_code = status.HTTP_400_BAD_REQUEST + default_detail = "Unknown server error" + default_code = "unknown_server_error" + + +class InvalidPasswordException(APIException): + status_code = status.HTTP_400_BAD_REQUEST + default_detail = "Invalid password" + default_code = "Invalid password" diff --git a/src/common/tests/__init__.py b/src/common/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/common/tests/decorator/__init__.py b/src/common/tests/decorator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/common/tests/decorator/test_query_parameter_decorator.py b/src/common/tests/decorator/test_query_parameter_decorator.py new file mode 100644 index 0000000..8aeb584 --- /dev/null +++ b/src/common/tests/decorator/test_query_parameter_decorator.py @@ -0,0 +1,38 @@ +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + + +class QueryTest(APITestCase): + def test_get_query(self): + response = self.client.get( + path=reverse("query"), + data={ + "name": "John", + "age": "30", + }, + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data["name"], "John") + self.assertEqual(response.data["age"], "30") + + def test_post_query(self): + response = self.client.post( + path=reverse("query"), + data={ + "city": "New York", + "occupation": "Engineer", + }, + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data["city"], "New York") + self.assertEqual(response.data["occupation"], "Engineer") + + def test_query_fail(self): + response = self.client.get( + path=reverse("query"), + data={ + "name": "John", + }, + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/common/tests/utils/__init__.py b/src/common/tests/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/common/tests/utils/test_date_utils.py b/src/common/tests/utils/test_date_utils.py new file mode 100644 index 0000000..fe236b1 --- /dev/null +++ b/src/common/tests/utils/test_date_utils.py @@ -0,0 +1,16 @@ +from django.test import TestCase +from django.utils import timezone + +from common.utils import get_before_week, get_now + + +class DateUtilityTest(TestCase): + def test_get_now(self): + now = get_now() + current_date = timezone.now().strftime("%Y-%m-%d") + self.assertEqual(now, current_date) + + def test_get_before_week(self): + before_week = get_before_week() + expected_date = (timezone.now() - timezone.timedelta(days=7)).strftime("%Y-%m-%d") + self.assertEqual(before_week, expected_date) diff --git a/src/common/urls.py b/src/common/urls.py new file mode 100644 index 0000000..03826d5 --- /dev/null +++ b/src/common/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from common.views import QueryTestView + +urlpatterns = [ + path("query/", QueryTestView.as_view(), name="query"), +] diff --git a/src/common/utils.py b/src/common/utils.py new file mode 100644 index 0000000..11a61c9 --- /dev/null +++ b/src/common/utils.py @@ -0,0 +1,64 @@ +import random +import string + +from django.utils import timezone +from rest_framework.request import Request + +from common.exceptions import MissingMandatoryParameterException + + +#################### +# Request Decorator +#################### +def mandatory_key(request: Request, name: str) -> any: + try: + if request.method == "GET": + data = request.GET[name] + else: + data = request.POST[name] + if data in ["", None]: + raise MissingMandatoryParameterException() + except Exception: + try: + json_body = request.data + data = json_body[name] + if data in ["", None]: + raise MissingMandatoryParameterException() + except Exception: + raise MissingMandatoryParameterException() + + return data + + +def optional_key(request: Request, name: str, default_value="") -> any: + try: + if request.method == "GET": + data = request.GET[name] + else: + data = request.POST[name] + if data in ["", None]: + data = default_value + except Exception: + try: + json_body = request.data + data = json_body[name] + if data in ["", None]: + data = default_value + except Exception: + data = default_value + return data + + +#################### +# Date +#################### +def get_now() -> timezone: + return timezone.now().strftime("%Y-%m-%d") + + +def get_before_week() -> timezone: + return (timezone.now() - timezone.timedelta(days=7)).strftime("%Y-%m-%d") + + +def get_random_string(length=6) -> string: + return "".join(random.choice(string.ascii_letters + string.digits) for i in range(length)) diff --git a/src/common/views.py b/src/common/views.py new file mode 100644 index 0000000..4845097 --- /dev/null +++ b/src/common/views.py @@ -0,0 +1,16 @@ +from rest_framework.response import Response +from rest_framework.views import APIView + +from common.decorator import mandatories, optionals + + +class QueryTestView(APIView): + @mandatories("name", "age") + def get(self, request, m): + response_data = {"name": m["name"], "age": m["age"]} + return Response(response_data) + + @optionals({"city": "New York", "occupation": "Engineer"}) + def post(self, request, o): + response_data = {"city": o["city"], "occupation": o["occupation"]} + return Response(response_data) diff --git a/src/config/__init__.py b/src/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/config/asgi.py b/src/config/asgi.py new file mode 100644 index 0000000..856079b --- /dev/null +++ b/src/config/asgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/src/config/settings.py b/src/config/settings.py new file mode 100644 index 0000000..3465ab1 --- /dev/null +++ b/src/config/settings.py @@ -0,0 +1,205 @@ +import os +from datetime import timedelta +from pathlib import Path + +import environ + +BASE_DIR = Path(__file__).resolve().parent.parent + +env = environ.Env(DEBUG=(bool, True)) + +environ.Env.read_env(env_file=os.path.join(BASE_DIR, ".env")) + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = env.str("SECRET_KEY", default="test") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = env.bool("DEBUG", default=True) + +ALLOWED_HOSTS = ["*"] + +# Application definition +THIRD_PARTY_APPS = [ + "rest_framework", + "drf_yasg", + "django_filters", +] + +LOCAL_APPS = [ + "users", + "common", + "posts", + "likes", + "shares", +] + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + *THIRD_PARTY_APPS, + *LOCAL_APPS, +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "config.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "config.wsgi.application" + + +# Database +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": env("POSTGRESQL_DATABASE", default="repo_1"), + "USER": env("POSTGRESQL_USER", default="postgres"), + "PASSWORD": env("POSTGRESQL_PASSWORD", default="password"), + "HOST": env("POSTGRESQL_HOST", default="localhost"), + "PORT": env("POSTGRESQL_PORT", default="5432"), + } +} + + +# Password validation +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + "OPTIONS": { + "min_length": 10, + }, + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +LANGUAGE_CODE = "ko-kr" + +TIME_ZONE = "Asia/Seoul" + +USE_I18N = True + +USE_L10N = True + +# Static files (CSS, JavaScript, Images) +STATIC_ROOT = os.path.join(BASE_DIR, "static") +STATIC_URL = "/static/" + +MEDIA_ROOT = os.path.join(BASE_DIR, "media") +MEDIA_URL = "/media/" + + +# Default primary key field type +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +AUTH_USER_MODEL = "users.User" + +# Swagger settings +SWAGGER_SETTINGS = {"SECURITY_DEFINITIONS": {"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header"}}} + +# DRF settings +REST_FRAMEWORK = { + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework_simplejwt.authentication.JWTAuthentication", + ], + "DEFAULT_RENDERER_CLASSES": ("djangorestframework_camel_case.render.CamelCaseJSONRenderer",), + "DEFAULT_PARSER_CLASSES": ("djangorestframework_camel_case.parser.CamelCaseJSONParser",), + "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", + "PAGE_SIZE": 10, +} + + +# Logging settings +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "filters": { + "require_debug_true": { + "()": "django.utils.log.RequireDebugTrue", + }, + "require_debug_false": { + "()": "django.utils.log.RequireDebugFalse", + }, + }, + "formatters": { + "django.server": { + "format": "[%(asctime)s] %(levelname)s [PID: %(process)d - %(processName)s] | [TID: %(thread)d - %(threadName)s] %(message)s", + "datefmt": "%Y-%m-%d %H:%M:%S", + }, + }, + "handlers": { + "console": { + "level": "INFO", + "class": "logging.StreamHandler", + "filters": ["require_debug_true"], + "formatter": "django.server", + }, + "file": { + "level": "INFO", + "filters": ["require_debug_false"], + "class": "logging.handlers.RotatingFileHandler", + "filename": "app.log", + "maxBytes": 1024 * 1024 * 10, # 10 MB + "backupCount": 5, + "formatter": "django.server", + }, + }, + "loggers": { + "django": { + "handlers": ["console", "file"], + "level": "INFO", + } + }, +} + +SIMPLE_JWT = { + "ACCESS_TOKEN_LIFETIME": timedelta(minutes=30), + "REFRESH_TOKEN_LIFETIME": timedelta(days=7), + "ROTATE_REFRESH_TOKENS": False, + "BLACKLIST_AFTER_ROTATION": True, + "ALGORITHM": "HS256", + "SIGNING_KEY": SECRET_KEY, + "VERIFYING_KEY": None, + "AUTH_HEADER_TYPES": ("Bearer",), + "USER_ID_FIELD": "id", + "USER_ID_CLAIM": "user_id", + "AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",), + "TOKEN_TYPE_CLAIM": "token_type", + "JTI_CLAIM": "jti", +} diff --git a/src/config/urls.py b/src/config/urls.py new file mode 100644 index 0000000..2bfe39e --- /dev/null +++ b/src/config/urls.py @@ -0,0 +1,38 @@ +from django.conf import settings +from django.conf.urls.static import static +from django.contrib import admin +from django.urls import include, path +from drf_yasg import openapi +from drf_yasg.views import get_schema_view +from rest_framework import permissions + +schema_view = get_schema_view( + openapi.Info( + title="소셜 미디어 통합 Feed 서비스", + default_version="v1", + description="원티드 프리온보딩 과제 1", + contact=openapi.Contact(email="wogur981208@gmail.com"), + ), + public=True, + permission_classes=[permissions.AllowAny], +) + +urlpatterns = [ + # Admin + path("admin/", admin.site.urls), + # API + path("api/users/", include("users.urls")), + path("api/posts/", include("posts.urls")), + path("api/common/", include("common.urls")), + path("api/likes/", include("likes.urls")), + path("api/shares/", include("shares.urls")), + # Swagger + path( + "swagger/docs/", + schema_view.with_ui("swagger", cache_timeout=0), + name="schema-swagger-ui", + ), +] + +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/src/config/wsgi.py b/src/config/wsgi.py new file mode 100644 index 0000000..8509335 --- /dev/null +++ b/src/config/wsgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/src/likes/__init__.py b/src/likes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/likes/apps.py b/src/likes/apps.py new file mode 100644 index 0000000..f4dbbf7 --- /dev/null +++ b/src/likes/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class LikesConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "likes" diff --git a/src/likes/migrations/__init__.py b/src/likes/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/likes/serializers.py b/src/likes/serializers.py new file mode 100644 index 0000000..14f2d7b --- /dev/null +++ b/src/likes/serializers.py @@ -0,0 +1,9 @@ +from rest_framework.serializers import ModelSerializer + +from posts.models import Post + + +class PostLikeIncrementSerializer(ModelSerializer): + class Meta: + model = Post + fields = ("like_count",) diff --git a/src/likes/tests.py b/src/likes/tests.py new file mode 100644 index 0000000..cab7496 --- /dev/null +++ b/src/likes/tests.py @@ -0,0 +1,49 @@ +from django.urls import reverse +from rest_framework.test import APIClient, APITestCase + +from posts.models import Post +from users.models import User + + +class LikeAPITestCase(APITestCase): + client = APIClient(enforce_csrf_checks=True) + viewname = "likes" + + def setUp(self): + self.user = User.objects.create(email="user") + + self.post = Post.objects.create(title="title", post_type="facebook", content="content") + + def test_post_without_auth(self): + """logout and post like""" + + self.client.logout() + + response = self.client.post( + path=reverse( + viewname=self.viewname, + kwargs={ + "content_id": self.post.content_id, + }, + ), + ) + + self.assertEqual(response.status_code, 401) + + def test_post_with_auth(self): + """login and post like""" + + # self.client.force_login(self.user) + self.client.force_authenticate(user=self.user) + + response = self.client.post( + path=reverse( + viewname=self.viewname, + kwargs={ + "content_id": self.post.content_id, + }, + ), + ) + + self.assertEqual(response.status_code, 200) + self.assertEqual(self.post.like_count, Post.objects.first().like_count - 1) diff --git a/src/likes/urls.py b/src/likes/urls.py new file mode 100644 index 0000000..69c972d --- /dev/null +++ b/src/likes/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from likes import views + +urlpatterns = [ + path("/", views.LikesAPIView.as_view(), name="likes"), +] diff --git a/src/likes/views.py b/src/likes/views.py new file mode 100644 index 0000000..18492c2 --- /dev/null +++ b/src/likes/views.py @@ -0,0 +1,35 @@ +from django.shortcuts import get_object_or_404 +from drf_yasg import openapi +from drf_yasg.utils import swagger_auto_schema +from rest_framework.permissions import IsAuthenticatedOrReadOnly +from rest_framework.response import Response +from rest_framework.status import HTTP_200_OK, HTTP_401_UNAUTHORIZED +from rest_framework.views import APIView + +from likes.serializers import PostLikeIncrementSerializer +from posts.models import Post + + +class LikesAPIView(APIView): + permission_classes = [IsAuthenticatedOrReadOnly] + + @swagger_auto_schema( + operation_summary="게시물에 좋아요", + responses={ + HTTP_200_OK: openapi.Response(description="ok"), + HTTP_401_UNAUTHORIZED: openapi.Response(description="unauthorized"), + }, + ) + def post(self, request, content_id): + post = get_object_or_404(Post, content_id=content_id) + + serializer = PostLikeIncrementSerializer( + post, + data={"like_count": post.like_count + 1}, + partial=True, + ) + + serializer.is_valid(raise_exception=True) + serializer.save() + + return Response(status=200) diff --git a/src/manage.py b/src/manage.py new file mode 100755 index 0000000..f06c858 --- /dev/null +++ b/src/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/src/posts/__init__.py b/src/posts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/posts/admin.py b/src/posts/admin.py new file mode 100644 index 0000000..846f6b4 --- /dev/null +++ b/src/posts/admin.py @@ -0,0 +1 @@ +# Register your models here. diff --git a/src/posts/apps.py b/src/posts/apps.py new file mode 100644 index 0000000..cd95585 --- /dev/null +++ b/src/posts/apps.py @@ -0,0 +1,9 @@ +from django.apps import AppConfig + + +class PostsConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "posts" + + def ready(self): + import posts.signals # noqa diff --git a/src/posts/filters.py b/src/posts/filters.py new file mode 100644 index 0000000..a1c8555 --- /dev/null +++ b/src/posts/filters.py @@ -0,0 +1,26 @@ +import django_filters + +from .models import Post + + +class PostFilter(django_filters.FilterSet): + ordering = django_filters.OrderingFilter( + fields=( + ("created_at", "created_at"), + ("-created_at", "-created_at"), + ("updated_at", "updated_at"), + ("-updated_at", "-updated_at"), + ("view_count", "view_count"), + ("-view_count", "-view_count"), + ("share_count", "share_count"), + ("-share_count", "-share_count"), + ("like_count", "like_count"), + ("-like_count", "-like_count"), + ), + field_name="ordering", + help_text="정렬 기준과 방향", + ) + + class Meta: + model = Post + fields = ["ordering"] diff --git a/src/posts/migrations/0001_initial.py b/src/posts/migrations/0001_initial.py new file mode 100644 index 0000000..60bcec4 --- /dev/null +++ b/src/posts/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# Generated by Django 4.2.6 on 2023-10-27 23:13 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='HashTag', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=32)), + ('hashtag_count', models.IntegerField(default=0)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + options={ + 'db_table': 'hashtag', + }, + ), + migrations.CreateModel( + name='Post', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('post_type', models.CharField(choices=[('facebook', 'Facebook'), ('twitter', 'Twitter'), ('instagram', 'Instagram'), ('threads', 'Threads')], max_length=16)), + ('title', models.CharField(max_length=32)), + ('content', models.TextField()), + ('view_count', models.IntegerField(default=0)), + ('like_count', models.IntegerField(default=0)), + ('share_count', models.IntegerField(default=0)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('hashtag', models.ManyToManyField(related_name='posts', to='posts.hashtag')), + ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'db_table': 'posts', + }, + ), + ] diff --git a/src/posts/migrations/0002_post_content_id.py b/src/posts/migrations/0002_post_content_id.py new file mode 100644 index 0000000..bd36b80 --- /dev/null +++ b/src/posts/migrations/0002_post_content_id.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.6 on 2023-10-27 23:19 + + + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='content_id', + field=models.UUIDField(default=uuid.uuid4, editable=False), + ), + ] diff --git a/src/posts/migrations/__init__.py b/src/posts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/posts/models.py b/src/posts/models.py new file mode 100644 index 0000000..5c66c5c --- /dev/null +++ b/src/posts/models.py @@ -0,0 +1,43 @@ +import uuid + +from django.db import models + +from users.models import User + + +class Post(models.Model): + class PostType(models.TextChoices): + FACEBOOK = "facebook" + TWITTER = "twitter" + INSTAGRAM = "instagram" + THREADS = "threads" + + content_id = models.UUIDField(default=uuid.uuid4, editable=False) + post_type = models.CharField(max_length=16, choices=PostType.choices) + title = models.CharField(max_length=32) + content = models.TextField() + view_count = models.IntegerField(default=0) + like_count = models.IntegerField(default=0) + share_count = models.IntegerField(default=0) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) + hashtag = models.ManyToManyField("HashTag", related_name="posts") + + class Meta: + db_table = "posts" + + def __str__(self): + return f"{self.title} by {self.user.email}" + + +class HashTag(models.Model): + name = models.CharField(max_length=32) + hashtag_count = models.IntegerField(default=0) + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + db_table = "hashtag" + + def __str__(self): + return self.name diff --git a/src/posts/paginations.py b/src/posts/paginations.py new file mode 100644 index 0000000..4640d55 --- /dev/null +++ b/src/posts/paginations.py @@ -0,0 +1,20 @@ +class PaginationHandlerMixin(object): + @property + def paginator(self): + if not hasattr(self, "_paginator"): + if self.pagination_class is None: + self._paginator = None + else: + self._paginator = self.pagination_class() + else: + pass + return self._paginator + + def paginate_queryset(self, queryset): + if self.paginator is None: + return None + return self.paginator.paginate_queryset(queryset, self.request, view=self) + + def get_paginated_response(self, data): + assert self.paginator is not None + return self.paginator.get_paginated_response(data) diff --git a/src/posts/serializers.py b/src/posts/serializers.py new file mode 100644 index 0000000..0dfd789 --- /dev/null +++ b/src/posts/serializers.py @@ -0,0 +1,96 @@ +from rest_framework import serializers + +from .models import HashTag, Post + + +class StatisticsQuerySerializer(serializers.Serializer): + type = serializers.ChoiceField(choices=["date", "hour"]) + start = serializers.DateTimeField(required=False) + end = serializers.DateTimeField(required=False) + hashtag = serializers.CharField(required=False) + value = serializers.CharField(required=False) + + +class StatisticsListSerializer(serializers.Serializer): + datetime = serializers.DateTimeField() + count = serializers.IntegerField() + + +class HashTagSerializer(serializers.ModelSerializer): + class Meta: + model = HashTag + fields = [ + "name", + ] + + +class PostListSerializer(serializers.ModelSerializer): + hashtag = HashTagSerializer(many=True, read_only=True) + content = serializers.SerializerMethodField() + + def get_content(self, obj): + return obj.content[:20] if obj.content else "" + + class Meta: + model = Post + fields = [ + "content_id", + "post_type", + "title", + "content", + "view_count", + "like_count", + "share_count", + "created_at", + "updated_at", + "hashtag", + "user", + ] + + +class PostQuerySerializer(serializers.Serializer): + type = serializers.ChoiceField( + choices=["all", "facebook", "twitter", "instagram", "threads"], + required=False, + default="all", + help_text="게시물 타입 중 하나를 선택하여 조회합니다. (default: 모든 게시물 타입)", + ) + search = serializers.CharField(required=False, help_text="title, content, title + content 내에 존재하는 키워드를 검색하여 일치하는 데이터들을 조회합니다.") + ordering = serializers.ChoiceField( + choices=[ + "created_at", + "updated_at", + "view_count", + "like_count", + "share_count", + "-created_at", + "-updated_at", + "-view_count", + "-like_count", + "-share_count", + ], + required=False, + default="created_at", + help_text="created_at, updated_at, view_count, like_count, share_count를 기준으로 오름차순/내림차순으로 정렬하여 조회합니다. (default: created_at)", + ) + hashtag = serializers.CharField(required=False, help_text="조회할 해시태그입니다. (default: 본인계정)") + + +class PostDetailSerializer(serializers.ModelSerializer): + hashtag = HashTagSerializer(many=True, read_only=True) + + class Meta: + model = Post + fields = [ + "content_id", + "post_type", + "title", + "content", + "view_count", + "like_count", + "share_count", + "created_at", + "updated_at", + "hashtag", + "user", + ] diff --git a/src/posts/signals.py b/src/posts/signals.py new file mode 100644 index 0000000..c1115f0 --- /dev/null +++ b/src/posts/signals.py @@ -0,0 +1,10 @@ +from django.db.models.signals import pre_save +from django.dispatch import receiver + +from posts.models import Post + + +@receiver(pre_save, sender=Post) +def increment_view_count(sender, instance, **kwargs): + # 게시글을 조회할 때 조회수 증가 + instance.view_count += 1 diff --git a/src/posts/tests/__init__.py b/src/posts/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/posts/tests/views/__init__.py b/src/posts/tests/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/posts/tests/views/test_posts_detail_view.py b/src/posts/tests/views/test_posts_detail_view.py new file mode 100644 index 0000000..b36725f --- /dev/null +++ b/src/posts/tests/views/test_posts_detail_view.py @@ -0,0 +1,82 @@ +import uuid + +from django.contrib.auth import get_user_model +from django.db import transaction +from django.urls import reverse +from django.utils import timezone +from rest_framework import status +from rest_framework.test import APITestCase + +from posts.models import HashTag, Post + +User = get_user_model() + + +class PostDetailViewTest(APITestCase): + @classmethod + def setUpTestData(cls): + # 테스트 사용자 생성 + cls.user = User.objects.create_user(username="testuser1", password="testpass1", email="test1@email.com") + + # 테스트 해시태그 생성 + cls.hashtag = HashTag.objects.create(name="hashtag1") + + # 테스트 게시물 생성 및 content_id 저장 + cls.content_ids = [] + + # 테스트 게시물 생성 + for i in range(1, 6): + post = Post.objects.create( + content_id=uuid.uuid4(), + user=cls.user, + post_type="facebook", + title=f"test title {i}", + content=f"test content {i}", + view_count=10 * i, + like_count=5 * i, + share_count=2 * i, + created_at=timezone.now(), + updated_at=timezone.now(), + ) + post.hashtag.set([cls.hashtag]) + cls.content_ids.append(str(post.content_id)) + + def setUp(self): + pass + + def test_get_existing_post_content_id(self): + response = self.client.get( + path=reverse("post-detail", kwargs={"content_id": self.content_ids[0]}), + data={"type": "all", "hashtag": self.hashtag.id, "ordering": "created_at", "search": ""}, + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_get_not_existing_post_content_id(self): + non_existing_content_id = "00000000-0000-0000-0000-000000000001" + response = self.client.get( + path=reverse("post-detail", kwargs={"content_id": non_existing_content_id}), + data={"type": "all", "hashtag": self.hashtag.id, "ordering": "created_at", "search": ""}, + ) + self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + + def test_increment_view_count(self): + content_id = self.content_ids[0] + + # 현재 조회수 가져오기 + # 초기값 - 1 (조회와 동시에 count가 됨) + post = Post.objects.get(content_id=content_id) + initial_view_count = post.view_count - 1 + + # 게시물 조회 + with transaction.atomic(): + response = self.client.get( + path=reverse("post-detail", kwargs={"content_id": content_id}), + data={"type": "all", "hashtag": self.hashtag.id, "ordering": "created_at", "search": ""}, + ) + + # 조회수 업데이트 확인 + post.refresh_from_db() + updated_view_count = post.view_count + + self.assertEqual(updated_view_count, initial_view_count + 1) + self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/src/posts/tests/views/test_posts_list_view.py b/src/posts/tests/views/test_posts_list_view.py new file mode 100644 index 0000000..7174dec --- /dev/null +++ b/src/posts/tests/views/test_posts_list_view.py @@ -0,0 +1,80 @@ +from django.contrib.auth import get_user_model +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from posts.models import HashTag, Post + +User = get_user_model() + + +class PostListViewTest(APITestCase): + def setUp(self): + # 테스트 사용자 생성 + self.user1 = User.objects.create_user(username="testuser1", password="testpass1", email="test1@email.com") + self.user2 = User.objects.create_user(username="testuser2", password="testpass2", email="test2@email.com") + + # 테스트 해시태그 생성 + self.hashtag1 = HashTag.objects.create(name="hashtag1") + self.hashtag2 = HashTag.objects.create(name="hashtag2") + + # 테스트 게시물 생성 + self.post1 = Post.objects.create( + user=self.user1, + post_type="facebook", + title="test title 1", + content="test content 1", + view_count=10, + like_count=5, + share_count=2, + ) + self.post1.hashtag.set([self.hashtag1]) + + self.post2 = Post.objects.create( + user=self.user2, + post_type="twitter", + title="test title 2", + content="test content 2", + view_count=20, + like_count=10, + share_count=4, + ) + self.post2.hashtag.set([self.hashtag2]) + + # 추가 게시물 생성 + for i in range(3, 6): + post = Post.objects.create( + user=self.user1, + post_type="facebook", + title=f"test title {i}", + content=f"test content {i}", + view_count=10 * i, + like_count=5 * i, + share_count=2 * i, + ) + post.hashtag.set([self.hashtag1]) + + def test_get_posts_list_success(self): + response = self.client.get( + path=reverse("list"), + data={"type": "all", "hashtag": self.hashtag1.id, "ordering": "created_at", "search": ""}, + ) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(len(response.data), 4) # 예상되는 게시물 개수 확인 + for item in response.data: + self.assertEqual(item["hashtag"][0]["name"], self.hashtag1.name) # 수정된 부분 + + def test_get_posts_list_invalid_type(self): + response = self.client.get( + path=reverse("list"), + data={"type": "invalid_type", "hashtag": "hashtag", "ordering": "created_at", "search": ""}, # 잘못된 타입 + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_get_posts_list_invalid_ordering(self): + response = self.client.get( + path=reverse("list"), + data={"type": "all", "hashtag": "hashtag", "ordering": "invalid_ordering", "search": ""}, # 잘못된 ordering 값 + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/posts/tests/views/test_statistics_list_view.py b/src/posts/tests/views/test_statistics_list_view.py new file mode 100644 index 0000000..5ba61ac --- /dev/null +++ b/src/posts/tests/views/test_statistics_list_view.py @@ -0,0 +1,131 @@ +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from posts.models import HashTag, Post +from users.models import User + + +class StatisticsListViewTest(APITestCase): + @classmethod + def setUpTestData(cls): + cls.hasgtag = HashTag.objects.create( + name="hashtag", + ) + for i in range(1, 11): + cls.users = User.objects.create_user( + email=f"user{i}@example.com", + password="testpassword", + username=f"testuser{i}", + ) + cls.posts = Post.objects.create( + post_type="facebook", + title=f"title {i}", + content=f"content {i}", + view_count=i, + like_count=i, + share_count=i, + user=cls.users, + ) + cls.posts.hashtag.set([cls.hasgtag]) + + def setUp(self): + pass + # self.access_token = self.client.post(reverse("token_obtain_pair"), self.user_data).data["access"] + + def test_get_statistics_list_date_success(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "date", + "hashtag": "hashtag", + "value": "count", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_get_statistics_list_hour_success(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "hour", + "hashtag": "hashtag", + "value": "count", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_get_statistics_list_not_found(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "date", + "hashtag": "hashtag1", + "value": "count", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data, []) + + # @TODO: 로그인 로직 구현 후 주석 풀기 @SaJH + # def test_get_statistics_list_fail_unauthenticated(self): + # response = self.client.get( + # path=reverse("statistics"), + # data={ + # "type": "date", + # "hashtag": "hashtag", + # "value": "count", + # }, + # ) + # self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + + def test_get_statistics_list_fail_missing_parameter(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "hashtag": "hashtag", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_get_statistics_list_fail_invalid_parameter_type(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "test", + "hashtag": "hashtag", + "value": "count", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_get_statistics_list_fail_invalid_parameter_max_days(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "date", + "start": "2023-10-1", + "end": "2023-11-10", + "hashtag": "hashtag", + "value": "count", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_get_statistics_list_fail_invalid_parameter_value(self): + response = self.client.get( + path=reverse("statistics"), + data={ + "type": "date", + "hashtag": "hashtag", + "value": "test", + }, + # HTTP_AUTHORIZATION=f"Bearer {self.access_token}", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/posts/urls.py b/src/posts/urls.py new file mode 100644 index 0000000..302e8ab --- /dev/null +++ b/src/posts/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from posts.views import PostDetailView, PostListView, StatisticsListView + +urlpatterns = [ + path("statistics/", StatisticsListView.as_view(), name="statistics"), + path("", PostListView.as_view(), name="list"), + path("/", PostDetailView.as_view(), name="post-detail"), +] diff --git a/src/posts/views.py b/src/posts/views.py new file mode 100644 index 0000000..29a446c --- /dev/null +++ b/src/posts/views.py @@ -0,0 +1,231 @@ +from datetime import datetime, timedelta + +from django.db.models import Count, Q, Sum +from django.db.models.functions import TruncDay, TruncHour +from django.db.models.query import QuerySet +from django.shortcuts import get_object_or_404 +from drf_yasg.utils import swagger_auto_schema +from rest_framework import status +from rest_framework.pagination import LimitOffsetPagination +from rest_framework.permissions import AllowAny +from rest_framework.request import Request +from rest_framework.response import Response +from rest_framework.views import APIView + +from common.decorator import mandatories, optionals +from common.exceptions import InvalidParameterException, UnknownServerErrorException +from common.utils import get_before_week, get_now +from posts.filters import PostFilter +from posts.models import Post +from posts.paginations import PaginationHandlerMixin +from posts.serializers import ( + PostDetailSerializer, + PostListSerializer, + PostQuerySerializer, + StatisticsListSerializer, + StatisticsQuerySerializer, +) + + +class StatisticsListView(APIView): + # @TODO: IsAuthenticated로 변경 @SaJH + permission_classes = [AllowAny] + + @swagger_auto_schema( + operation_summary="통계 정보를 조회", + query_serializer=StatisticsQuerySerializer, + responses={ + status.HTTP_200_OK: StatisticsListSerializer, + }, + ) + @mandatories("type") + @optionals({"start": get_before_week()}, {"end": get_now()}, {"hashtag": None}, {"value": "count"}) + def get(self, request: Request, m: dict, o: dict) -> Response: + """ + query parameter로 type, start, end, hashtag, value를 받아 통계 정보를 조회합니다. + + Args: + type: date, hour 중 하나를 선택합니다. + start: 조회 시작 날짜입니다. (default: 7일 전) + end: 조회 종료 날짜입니다. (default: 현재) + hashtag: 조회할 해시태그입니다. (default: 본인계정) + value: count, view_count, share_count, like_count 조회할 값입니다. (default: count) + + Returns: + date: 날짜/시간 + count: 조회할 값의 수 + """ + try: + # 쿼리 매개변수 받기 + date_type = m["type"] + start_date, end_date, value = o["start"], o["end"], o["value"] + hashtag = request.user.email if o["hashtag"] is None else o["hashtag"] + + # date type에 따른 필드, 기간, 집계 정보 가져오기 + max_days, aggregation_field, aggregation_type = self.get_aggregation_info(date_type) + + # date type에 따른 최대 기간 체크 or 날짜 데이터 타입 변환 + start_date, end_date = self.get_dates(date_type, max_days, start_date, end_date) + + # 필터링된 queryset 가져오기 + queryset = self.get_filtered_queryset(start_date, end_date, hashtag) + + # 집계 정보 가져오기 + statistics = self.get_statistics(queryset, aggregation_field, value, aggregation_type) + + # 집계 정보 serialize + serializer = StatisticsListSerializer(statistics, many=True) + except Exception as e: + raise UnknownServerErrorException(e) + return Response(serializer.data, status=status.HTTP_200_OK) + + def get_aggregation_info(self, date_type: str) -> tuple: + if date_type == "date": + max_days = 30 + aggregation_field = "created_at" + aggregation_type = TruncDay + elif date_type == "hour": + max_days = 7 + aggregation_field = "created_at" + aggregation_type = TruncHour + else: + raise InvalidParameterException("type은 date, hour 중 선택 가능합니다.") + return max_days, aggregation_field, aggregation_type + + def get_dates(self, date_type: str, max_days: int, start_date: str, end_date: str) -> None: + if isinstance(start_date, str) and isinstance(end_date, str): + start_date = datetime.strptime(start_date, "%Y-%m-%d") + end_date = datetime.strptime(end_date, "%Y-%m-%d") + timedelta(days=1) - timedelta(seconds=1) + + if (end_date - start_date).days > max_days: + raise InvalidParameterException(f"{date_type}는 최대 {max_days}일 조회 가능합니다.") + + return start_date, end_date + + def get_filtered_queryset(self, start_date: str, end_date: str, hashtag: str) -> Post: + q = Q(created_at__range=(start_date, end_date)) & Q(hashtag__name=hashtag) + return Post.objects.prefetch_related("hashtag").filter(q) + + def get_statistics(self, queryset: Post, aggregation_field: str, value: str, aggregation_type) -> QuerySet[dict]: + if value == "count": + statistics = queryset.annotate(datetime=aggregation_type(aggregation_field)).values("datetime").annotate(count=Count("id")) + elif value in ["view_count", "like_count", "share_count"]: + statistics = queryset.annotate(datetime=aggregation_type(aggregation_field)).values("datetime").annotate(count=Sum(value)) + else: + raise InvalidParameterException("value는 count, view_count, share_count, like_count 중 선택 가능합니다.") + return statistics + + +class PostListView(PaginationHandlerMixin, APIView): + # @TODO: IsAuthenticated로 변경 @simseulnyang + permission_classes = [AllowAny] + pagination_class = LimitOffsetPagination + + @swagger_auto_schema( + operation_summary="게시물 리스트를 조회", + query_serializer=PostQuerySerializer, + responses={ + status.HTTP_200_OK: PostListSerializer, + }, + ) + @optionals({"hashtag": None}, {"type": ["all", "facebook", "twitter", "instagram", "threads"]}) + def get(self, request: Request, o: dict) -> Response: + """ + query parameter로 type, search, ordering, hashtag를 받아 게시물 목록을 조회 + + Args: + type: 게시물 타입으로 facebook, twitter, instagram, threads 중에 1개를 선택하여 조회 가능합니다. (default : 모든 게시물 타입) + search : title, content, title + content 내에 존재하는 키워드를 검색하여 일치하는 데이터들을 조회합니다. + ordering : created_at, updated_at, view_count, like_count, share_count를 기준으로 오름차순/내림차순으로 정렬하여 조회합니다. (default: created_at) + hashtag: 조회할 해시태그입니다. (default: 본인계정) + + Returns: + content_id : 게시물 id + hashtag : 해시태그 + user : 게시글 작성 유저 + post_type : 게시물 타입 + title : 게시글 제목 + content : 게시글 내용 + view_count : 조회수 + like_count : 좋아요 수 + share_count : 공유 수 + created_at : 작성일자 + updated_at : 업데이트 일자 + """ + try: + # filter 객체 생성 및 적용하기 + filter = PostFilter(request.query_params, queryset=Post.objects.all()) + filtered_posts = filter.qs + + # 쿼리 매개변수 받기 + post_type = o["type"] + search_keyword = request.query_params.get("search", "") + hashtag = request.user.username if o["hashtag"] is None else o["hashtag"] + ordering = request.query_params.get("ordering", "created_at") # 기본 정렬은 created_at + + # 변수를 지정하여 필터링한 posts 목록 가져오기 + q = Q() + + # hashtag가 유저 계정과 동일 여부 판별 및 조건에 따른 필터링 + if hashtag == request.user.username: + q = q & Q(user__username=hashtag) + else: + q = q & Q(hashtag__exact=hashtag) + + # search_keyword를 통해 title, content field 검색 + if search_keyword: + q = q | Q(title__icontains=search_keyword) | Q(content__icontains=search_keyword) + + posts = filtered_posts.filter(q) + + # ordering에 따라 정렬 적용하여 나열된 목록 가져오기 + posts = self.get_ordering(posts, ordering) + + # post_type에 따라 필터링 된 게시물 목록 가져오기 + if post_type != "all": + if post_type not in ["facebook", "twitter", "instagram", "threads"]: + raise InvalidParameterException(f"post_type 값 {post_type}를 잘못 선택하셨습니다.") + posts = posts.filter(post_type=post_type) + + # 게시물 목록 serialize + serializer = PostListSerializer(posts, many=True) + except Exception as e: + raise UnknownServerErrorException(e) + return Response(serializer.data, status=status.HTTP_200_OK) + + def get_ordering(self, posts: QuerySet[Post], ordering: str) -> QuerySet[Post]: + # 사용 가능한 필드 목록 + allowed_fields = [ + "created_at", + "-created_at", + "updated_at", + "-updated_at", + "view_count", + "-view_count", + "like_count", + "-like_count", + "share_count", + "-share_count", + ] + + if ordering in allowed_fields: + return posts.order_by(ordering) + else: + raise InvalidParameterException(f"ordering 값 {ordering}를 잘못 선택하셨습니다.") + + +class PostDetailView(APIView): + # @TODO: IsAuthenticated로 변경 @simseulnyang + permission_classes = [AllowAny] + + @swagger_auto_schema( + operation_summary="content_id에 해당하는 게시글 상세 조회", + responses={ + status.HTTP_200_OK: PostDetailSerializer, + }, + ) + def get(self, request: Request, content_id: str) -> Response: + post = get_object_or_404(Post, content_id=content_id) + serializer = PostDetailSerializer(post) + + return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/src/shares/__init__.py b/src/shares/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/shares/apps.py b/src/shares/apps.py new file mode 100644 index 0000000..578ee6a --- /dev/null +++ b/src/shares/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SharesConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "shares" diff --git a/src/shares/migrations/__init__.py b/src/shares/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/shares/serializers.py b/src/shares/serializers.py new file mode 100644 index 0000000..3b198f5 --- /dev/null +++ b/src/shares/serializers.py @@ -0,0 +1,9 @@ +from rest_framework.serializers import ModelSerializer + +from posts.models import Post + + +class PostShareCountIncrementSerializer(ModelSerializer): + class Meta: + model = Post + fields = ("share_count",) diff --git a/src/shares/tests/__init__.py b/src/shares/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/shares/tests/test_shares_api.py b/src/shares/tests/test_shares_api.py new file mode 100644 index 0000000..07ec3bf --- /dev/null +++ b/src/shares/tests/test_shares_api.py @@ -0,0 +1,55 @@ +from django.contrib.auth import get_user_model +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from posts.models import Post + + +class SharesAPITestCase(APITestCase): + """ + /shares// post 에 대한 테스트 케이스 + """ + + viewname = "shares" + + def test_post_failure_no_api(self): + """ + 해당 view가 없으면 NoReverseMatch 예외가 수반됩니다. + """ + reverse(self.viewname, kwargs={"content_id": None}) + + def test_post_without_auth(self): + """ + 인증되지 않은 사용자가 shares에 post 요청을 전달하고, + 401(unauth) 응답을 얻습니다. + """ + + post = Post.objects.create(title="title") + self.client.logout() + response = self.client.post( + path=reverse(self.viewname, kwargs={"content_id": post.content_id}), + data=None, + ) + + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) # status 401 + + def test_post_with_auth(self): + """ + 인증된 사용자가 shares에 post 요청을 전달하고, + 200(Ok) 응답을 얻으며 share_count가 증가합니다. + """ + + post = Post.objects.create(title="title") + + user = get_user_model().objects.create(username="username") + self.client.force_authenticate(user=user) + + response = self.client.post( + path=reverse(self.viewname, kwargs={"content_id": post.content_id}), + data=None, + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) # status 200 + + post_after_response = Post.objects.get(content_id=post.content_id) + self.assertEqual(post.share_count + 1, post_after_response.share_count) # share_count diff 1 diff --git a/src/shares/urls.py b/src/shares/urls.py new file mode 100644 index 0000000..b912074 --- /dev/null +++ b/src/shares/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from shares.views import SharesAPIView + +urlpatterns = [ + path("/", SharesAPIView.as_view(), name="shares"), +] diff --git a/src/shares/views.py b/src/shares/views.py new file mode 100644 index 0000000..591895a --- /dev/null +++ b/src/shares/views.py @@ -0,0 +1,42 @@ +from django.shortcuts import get_object_or_404 +from drf_yasg import openapi +from drf_yasg.utils import swagger_auto_schema +from rest_framework import status +from rest_framework.permissions import IsAuthenticatedOrReadOnly +from rest_framework.response import Response +from rest_framework.views import APIView + +from posts.models import Post +from shares.serializers import PostShareCountIncrementSerializer + + +class SharesAPIView(APIView): + permission_classes = [IsAuthenticatedOrReadOnly] + + @swagger_auto_schema( + operation_summary="게시물 좋아요", + responses={ + status.HTTP_200_OK: openapi.Response(description="ok"), + status.HTTP_401_UNAUTHORIZED: openapi.Response(description="unauthorized"), + }, + ) + def post(self, request, content_id): + """ + 게시물(content_id)에 대해 공유 요청을 합니다. + """ + + post = get_object_or_404(Post, content_id=content_id) + + # TODO : how to increment share_count using serializer not passing data. + serializer = PostShareCountIncrementSerializer( + instance=post, + data={ + "share_count": post.share_count + 1, + }, + partial=True, + ) + + serializer.is_valid(raise_exception=True) + serializer.save() + + return Response(status=status.HTTP_200_OK) diff --git a/src/users/__init__.py b/src/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/users/admin.py b/src/users/admin.py new file mode 100644 index 0000000..846f6b4 --- /dev/null +++ b/src/users/admin.py @@ -0,0 +1 @@ +# Register your models here. diff --git a/src/users/apps.py b/src/users/apps.py new file mode 100644 index 0000000..88f7b17 --- /dev/null +++ b/src/users/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "users" diff --git a/src/users/managers.py b/src/users/managers.py new file mode 100644 index 0000000..d791615 --- /dev/null +++ b/src/users/managers.py @@ -0,0 +1,14 @@ +from django.contrib.auth.base_user import BaseUserManager + + +class UserManager(BaseUserManager): + def create_user(self, email, username, password, **extra_fields): + email = self.normalize_email(email) + user = self.model(email=email, username=username, **extra_fields) + user.set_password(password) + user.save() + return user + + def create_superuser(self, email, username, password, **extra_fields): + extra_fields.setdefault("is_admin", True) + return self.create_user(email, username, password, **extra_fields) diff --git a/src/users/migrations/0001_initial.py b/src/users/migrations/0001_initial.py new file mode 100644 index 0000000..b99a290 --- /dev/null +++ b/src/users/migrations/0001_initial.py @@ -0,0 +1,45 @@ +# Generated by Django 4.2.6 on 2023-10-27 23:13 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('email', models.EmailField(max_length=128, unique=True)), + ('password', models.CharField(max_length=128)), + ('is_confirmed', models.BooleanField(default=False)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('is_admin', models.BooleanField(default=False)), + ('is_active', models.BooleanField(default=True)), + ], + options={ + 'db_table': 'users', + }, + ), + migrations.CreateModel( + name='UserConfirmCode', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('code', models.CharField(max_length=32)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ], + options={ + 'db_table': 'user_confirm_codes', + }, + ), + ] diff --git a/src/users/migrations/0002_user_username.py b/src/users/migrations/0002_user_username.py new file mode 100644 index 0000000..104d077 --- /dev/null +++ b/src/users/migrations/0002_user_username.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.6 on 2023-10-27 23:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='username', + field=models.CharField(default=1, max_length=128, unique=True), + preserve_default=False, + ), + ] diff --git a/src/users/migrations/__init__.py b/src/users/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/users/models.py b/src/users/models.py new file mode 100644 index 0000000..9b419da --- /dev/null +++ b/src/users/models.py @@ -0,0 +1,42 @@ +from django.contrib.auth.models import AbstractBaseUser +from django.db import models + +from users.managers import UserManager + + +class User(AbstractBaseUser): + email = models.EmailField(max_length=128, unique=True) + username = models.CharField(max_length=128, unique=True) + password = models.CharField(max_length=128) + is_confirmed = models.BooleanField(default=False) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + is_admin = models.BooleanField(default=False) + is_active = models.BooleanField(default=True) + + objects = UserManager() + + USERNAME_FIELD = "username" + REQUIRED_FIELDS = ["email"] + + class Meta: + db_table = "users" + + def __str__(self): + return self.username + + @property + def is_staff(self): + return self.is_admin + + +class UserConfirmCode(models.Model): + code = models.CharField(max_length=32) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) + created_at = models.DateTimeField(auto_now_add=True) + + class Meta: + db_table = "user_confirm_codes" + + def __str__(self): + return f"{[self.user.email]}: {self.code}" diff --git a/src/users/serializers.py b/src/users/serializers.py new file mode 100644 index 0000000..3bfeee1 --- /dev/null +++ b/src/users/serializers.py @@ -0,0 +1,87 @@ +from django.contrib.auth import authenticate, get_user_model, password_validation +from rest_framework import serializers +from rest_framework_simplejwt.serializers import TokenObtainPairSerializer + +from common.utils import get_random_string +from users.models import UserConfirmCode + + +class UserSerializer(serializers.ModelSerializer): + class Meta: + model = get_user_model() + fields = ("email", "username", "password") + extra_kwargs = {"password": {"write_only": True}} + + def validate_password(self, data): + password_validation.validate_password(data) + return data + + def create(self, validated_data): + user = get_user_model().objects.create_user(validated_data["email"], validated_data["username"], validated_data["password"]) + return user + + +class UserConfirmCodeSerializer(UserSerializer): + def create(self, validated_data): + user = super().create(validated_data) + + confirm_code = get_random_string() + user_confirm_code = UserConfirmCode.objects.create(code=confirm_code, user=user) + return user_confirm_code + + +class UserConfirmSerializer(serializers.Serializer): + username = serializers.CharField(max_length=128) + password = serializers.CharField(max_length=128, write_only=True) + code = serializers.CharField(max_length=32) + + def validate(self, data): + user = self.instance + if not user.check_password(data["password"]): + raise serializers.ValidationError("Password is incorrect") + + if user.is_confirmed: + raise serializers.ValidationError("User is already confirmed") + + confirm_code = UserConfirmCode.objects.get(user=user).code + if confirm_code != data["code"]: + raise serializers.ValidationError("Confirmation code is incorrect") + + return data + + def update(self, user, validated_data): + user.is_confirmed = True + user.save() + return user + + +class UserLoginSerializer(serializers.Serializer): + username = serializers.CharField(required=True) + password = serializers.CharField(required=True, write_only=True) + token = serializers.SerializerMethodField(read_only=True) + + def get_token(self, user): + if user is not None: + refresh = TokenObtainPairSerializer.get_token(user) + refresh["username"] = user.username + data = { + "refresh": str(refresh), + "access": str(refresh.access_token), + } + return data + return None + + def validate(self, data): + user = authenticate(username=data["username"], password=data["password"]) + if user is None: + raise serializers.ValidationError("Username or Password is Incorrect") + if not user.is_confirmed: + raise serializers.ValidationError("User is not confirmed yet") + return data + + def create(self, validated_data): + user = authenticate(username=validated_data["username"], password=validated_data["password"]) + if user is not None: + user.is_active = True + user.save() + return user diff --git a/src/users/tests/__init__.py b/src/users/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/users/tests/views/__init__.py b/src/users/tests/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/users/tests/views/test_confirm_user_view.py b/src/users/tests/views/test_confirm_user_view.py new file mode 100644 index 0000000..27ace61 --- /dev/null +++ b/src/users/tests/views/test_confirm_user_view.py @@ -0,0 +1,94 @@ +import json + +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from users.models import User, UserConfirmCode + + +class SignupViewTest(APITestCase): + @classmethod + def setUpTestData(cls): + cls.user = User.objects.create_user( + email="testuser1@example.com", + username="testusername1", + password="testpassword", + ) + + cls.userconfirmcode = UserConfirmCode.objects.create( + code="abcdef", + user=cls.user, + ) + + def test_post_signup_success(self): + response = self.client.post( + path=reverse("confirm"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword", + "code": "abcdef", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + + def test_post_signup_fail_user_not_found(self): + response = self.client.post( + path=reverse("confirm"), + data=json.dumps( + { + "username": "testusername2", + "password": "testpassword", + "code": "abcdef", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + + def test_post_signup_fail_invalid_password(self): + response = self.client.post( + path=reverse("confirm"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword2", + "code": "abcdef", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_signup_fail_invalid_code(self): + response = self.client.post( + path=reverse("confirm"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword", + "code": "aaaaaa", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_signup_fail_already_confirmed(self): + self.user.is_confirmed = True + self.user.save() + response = self.client.post( + path=reverse("confirm"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword", + "code": "abcdef", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/users/tests/views/test_login_view.py b/src/users/tests/views/test_login_view.py new file mode 100644 index 0000000..e046610 --- /dev/null +++ b/src/users/tests/views/test_login_view.py @@ -0,0 +1,71 @@ +import json + +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from users.models import User + + +class SignupViewTest(APITestCase): + @classmethod + def setUpTestData(cls): + cls.confirmed_user = User.objects.create_user( + email="testuser1@example.com", username="testusername1", password="testpassword", is_confirmed=True + ) + cls.not_confirmed_user = User.objects.create_user( + email="testuser2@example.com", username="testusername2", password="testpassword", is_confirmed=False + ) + + def test_post_login_success(self): + response = self.client.post( + path=reverse("login"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(self.confirmed_user.is_active, True) + + def test_post_login_fail_user_not_found(self): + response = self.client.post( + path=reverse("login"), + data=json.dumps( + { + "username": "testusername3", + "password": "testpassword", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_login_fail_invalid_password(self): + response = self.client.post( + path=reverse("login"), + data=json.dumps( + { + "username": "testusername1", + "password": "testpassword2", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_login_fail_not_confirmed_user(self): + response = self.client.post( + path=reverse("login"), + data=json.dumps( + { + "username": "testusername2", + "password": "testpassword", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/users/tests/views/test_signup_view.py b/src/users/tests/views/test_signup_view.py new file mode 100644 index 0000000..69c918c --- /dev/null +++ b/src/users/tests/views/test_signup_view.py @@ -0,0 +1,73 @@ +import json + +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase + +from users.models import User + + +class SignupViewTest(APITestCase): + @classmethod + def setUpTestData(cls): + cls.user = User.objects.create_user( + email="testuser1@example.com", + username="testusername1", + password="testpassword", + ) + + def test_post_signup_success(self): + response = self.client.post( + path=reverse("signup"), + data=json.dumps( + { + "email": "testuser2@example.com", + "username": "testusername2", + "password": "testpassword", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + def test_post_signup_fail_invalid_password(self): + response = self.client.post( + path=reverse("signup"), + data=json.dumps( + { + "email": "testuser2@example.com", + "username": "testusername2", + "password": "1234", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_signup_fail_already_existing_email(self): + response = self.client.post( + path=reverse("signup"), + data=json.dumps( + { + "email": "testuser1@example.com", + "username": "testusername2", + "password": "1234", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + + def test_post_signup_fail_already_existing_username(self): + response = self.client.post( + path=reverse("signup"), + data=json.dumps( + { + "email": "testuser2@example.com", + "username": "testusername1", + "password": "1234", + } + ), + content_type="application/json", + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/src/users/urls.py b/src/users/urls.py new file mode 100644 index 0000000..8e6b4ef --- /dev/null +++ b/src/users/urls.py @@ -0,0 +1,11 @@ +from django.urls import path +from rest_framework_simplejwt.views import TokenRefreshView + +from users.views import ConfirmUserView, LoginView, SignupView + +urlpatterns = [ + path("signup/", SignupView.as_view(), name="signup"), + path("confirm/", ConfirmUserView.as_view(), name="confirm"), + path("login/", LoginView.as_view(), name="login"), + path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), +] diff --git a/src/users/views.py b/src/users/views.py new file mode 100644 index 0000000..f84fc67 --- /dev/null +++ b/src/users/views.py @@ -0,0 +1,98 @@ +from django.contrib.auth import get_user_model +from django.shortcuts import get_object_or_404 +from drf_yasg.utils import swagger_auto_schema +from rest_framework import status +from rest_framework.request import Request +from rest_framework.response import Response +from rest_framework.views import APIView + +from users.serializers import ( + UserConfirmCodeSerializer, + UserConfirmSerializer, + UserLoginSerializer, + UserSerializer, +) + + +class SignupView(APIView): + @swagger_auto_schema( + operation_summary="유저 회원가입", + request_body=UserConfirmCodeSerializer, + responses={ + status.HTTP_201_CREATED: UserConfirmCodeSerializer, + }, + ) + def post(self, request: Request) -> Response: + """ + username, email, paswword를 받아 유저 계정과 인증 코드를 생성합니다. + Args: + email: 이메일 + username: 이름 + password: 비밀번호 + Returns: + email: 생성된 계정 이메일 + username: 생성된 계정 이름 + code: 생성된 인증 코드 + """ + serializer = UserConfirmCodeSerializer(data=request.data) + serializer.is_valid(raise_exception=True) + user_confirm_code = serializer.save() + + response_data = UserSerializer(user_confirm_code.user).data + response_data["confirm_code"] = user_confirm_code.code + return Response(response_data, status=status.HTTP_201_CREATED) + + +class ConfirmUserView(APIView): + @swagger_auto_schema( + operation_summary="유저 가입 승인", + request_body=UserConfirmSerializer, + responses={ + status.HTTP_200_OK: UserConfirmSerializer, + }, + ) + def post(self, request: Request) -> Response: + """ + username, paswword, code를 받아 code가 user의 인증코드와 같을 경우 회원가입을 승인합니다. + Args: + username: 이름 + password: 비밀번호 + Returns: + username: 이름 + is_confirmed: 인증 여부 + """ + user = get_object_or_404(get_user_model(), username=request.data["username"]) + serializer = UserConfirmSerializer(user, data=request.data) + serializer.is_valid(raise_exception=True) + serializer.save() + + response_data = {} + response_data["username"] = user.username + response_data["is_confirmed"] = user.is_confirmed + + return Response(response_data, status=status.HTTP_200_OK) + + +class LoginView(APIView): + @swagger_auto_schema( + operation_summary="유저 로그인", + request_body=UserLoginSerializer, + responses={ + status.HTTP_200_OK: UserLoginSerializer, + }, + ) + def post(self, request: Request) -> Response: + """ + username, paswword를 받아 유저 계정을 활성화하고 JWT 토큰을 발급합니다. + Args: + username: 이름 + password: 비밀번호 + Returns: + username: 이름 + token: access token과 refresh token + """ + serializer = UserLoginSerializer(data=request.data) + serializer.is_valid(raise_exception=True) + serializer.save() + + return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/test.png b/test.png new file mode 100644 index 0000000..38e591b Binary files /dev/null and b/test.png differ