-
Notifications
You must be signed in to change notification settings - Fork 1
Issues #22, #28, #29, README.md update #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
155cb13
Initial commit
Wudext ef3c496
Black doesn`t like me :(
Wudext 9945876
ISort
Wudext 6dfb524
Update category.py
Wudext 16cabed
Fixing #22
Wudext f22b360
Update .gitignore
Wudext e44e6f2
CONTRIBUTING.md and README.md
Wudext 1d4f44a
Merge branch '#22-#28-#29-README' of https://github.com/profcomff/ser…
Wudext 4cb350a
Descriptions
Wudext 3baf8cf
Black and Isort (again)
Wudext 7c43f85
Final commit (i hope)
Wudext 1dd9056
Update button.py
Wudext 90b8f90
Enum + README + migrations
Wudext 73518e7
Update conftest.py
Wudext 7f3718c
Update button.py
Wudext ec098ec
Fixing migrations
Wudext 767b2d3
Black and Isort (надоели уже)
Wudext 27361ad
Fixing
Wudext 11459c1
Last commint (again)
Wudext 56e9d52
Please let it end
Wudext fbc2b4b
Update 6a486347af93_order.py
Wudext ecc1a90
Black (3d time)
Wudext c7e0c6b
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Wudext f8ebef9
Update d35e88f39f85_fixing.py
Wudext File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # services-api | ||
|
|
||
| Ссылки: | ||
|
|
||
| 1) Backend разработка – https://github.com/profcomff/.github/wiki/%5Bdev%5D-Backend-разработка | ||
|
|
||
|
|
||
| Для запуска проекта нужно иметь доступ к БД профкома/иметь локальную БД. | ||
|
|
||
| Локальную БД можно поднять так: | ||
| - Установить Docker | ||
| - В терминале запустить: ```docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-services-backend postgres:15``` | ||
|
|
||
|
|
||
| Переменные: | ||
| 1) DB_DSN = 'postgres://логин:пароль@адрес:порт/бд' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,68 @@ | ||
| # services-api | ||
|
|
||
| Бэкэдн сервисов приложения Твой ФФ для профкома ФФ МГУ | ||
| Бэкэдн сервисов приложения Твой ФФ для профкома ФФ МГУ. Реализует логику работы с кнопками и категориями в приложении. | ||
| Репозиторий был создан для упрощения работы фронтэнд-разработчиков с бэкэндом сервисов, для переноса данных кнопок и категорий из захардкодженного json файла в Postgresql базу данных (cringe) и для разграничения доступа. | ||
|
|
||
| ## Запуск | ||
| ## Функционал | ||
|
|
||
| - Создание кнопок и категорий для отображения на фронте (в приложении) | ||
| - Управление доступами к категориям кнопок | ||
| - Редактирование любых атрибутов/полей кнопое и категорий | ||
|
|
||
|
|
||
| ## Разработка | ||
| Backend разработка – https://github.com/profcomff/.github/wiki/%5Bdev%5D-Backend-разработка | ||
|
|
||
| CONTRIBUTING.md - [CONTRIBUTING.md](services-api/CONTRIBUTING.md) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| 1) Перейдите в папку проекта | ||
|
|
||
| 2) Создайте виртуальное окружение командой: | ||
| ```console | ||
| foo@bar:~$ python3 -m venv ./venv/ | ||
| ``` | ||
|
|
||
| 3) Установите библиотеки | ||
| ```console | ||
| foo@bar:~$ pip install -m requirements.txt | ||
| ``` | ||
| 4) Запускайте приложение! | ||
| 4) Установите все переменные окружения (см. CONTRIBUTING.md) | ||
|
|
||
| 5) Запускайте приложение! | ||
| ```console | ||
| foo@bar:~$ python -m services-backend | ||
| ``` | ||
|
|
||
| ## ENV-file description | ||
|
|
||
| DB_DSN= | ||
| ## Использование | ||
| 1) Создание категории кнопок | ||
| *Необходимо иметь права services.category.create* | ||
| 1. Создать новую категорию по запросу `POST /category` с телом `{"name": "имя_категории", "type": "тип отображения категории в приложении"}` | ||
|
|
||
| 2. *Необходимо иметь права services.button.create* Создать в категории новую кнопку по запросу `POST /category/id_категории/button` с телом `{"name": "имя кнопки", "icon": "ссылка на иконку", "link": "ссылка сервиса, на которую ведет кнопка", "type": "тип ссылки"}` | ||
|
|
||
| 3. *Опционально* Навесить права запросом `POST /category/{category_id}/scope` с телом `{"name": "название права доступа"}` | ||
|
|
||
|
|
||
| 2) Получение категорий кнопок | ||
| *Нет необходимых прав* | ||
| 1. Получить категории по запросу `GET /category` | ||
| 2. *Опционально* Выбрать отображение кнопок принадлежащих категории по запросу `GET /category?info=buttons` | ||
|
|
||
|
|
||
| 3) Удаление категории кнопок. *Необходимо иметь права services.category.delete* | ||
|
|
||
| ВАЖНОЕ УТОЧНЕНИЕ: При удалении категории все кнопки, принадлежащей ей также удаляются. | ||
| 1. Удалить категорию кнопок по запросу 'DELETE /category/{category_id} | ||
|
|
||
| ## Параметризация и плагины: | ||
| Никаких настроек кроме стандартных нет | ||
|
|
||
| ## Ссылки: | ||
| Документация проекта - https://api.test.profcomff.com/?urls.primaryName=services# | ||
|
|
||
| Backend разработка – https://github.com/profcomff/.github/wiki/%5Bdev%5D-Backend-разработка | ||
|
|
||
| CONTRIBUTING.md - [CONTRIBUTING.md](services-api/CONTRIBUTING.md) | ||
|
|
||
| --- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Fixing | ||
|
|
||
| Revision ID: d35e88f39f85 | ||
| Revises: 660bb7891726 | ||
| Create Date: 2023-04-09 11:28:59.326067 | ||
|
|
||
| """ | ||
| import operator | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = 'd35e88f39f85' | ||
| down_revision = '660bb7891726' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| conn = op.get_bind() | ||
| res_c = conn.execute(sa.text("select * from category ORDER BY category.order")).fetchall() | ||
| for category in res_c: | ||
| res_b = conn.execute( | ||
| sa.text(f"select * from button WHERE category_id={category[0]} ORDER BY button.order") | ||
| ).fetchall() | ||
| for i in range(0, len(res_b)): | ||
| conn.execute( | ||
| sa.text( | ||
| f"""UPDATE "button" | ||
| SET "order"={i + 1}, | ||
| "link"='{res_b[i][5]}', | ||
| "type"='{res_b[i][6]}' | ||
| WHERE id={res_b[i][0]}""" | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| def downgrade(): | ||
| k = 0 | ||
| conn = op.get_bind() | ||
| res_c = conn.execute(sa.text("select * from category ORDER BY category.order")).fetchall() | ||
| for category in res_c: | ||
| res_b = conn.execute( | ||
| sa.text(f"select * from button WHERE category_id={category[0]} ORDER BY button.order") | ||
| ).fetchall() | ||
| for i in range(0, len(res_b)): | ||
| conn.execute( | ||
| sa.text( | ||
| f"""UPDATE "button" | ||
| SET "order"={k + 1}, | ||
| "link"='{res_b[i][5]}', | ||
| "type"='{res_b[i][6]}' | ||
| WHERE id={res_b[i][0]}""" | ||
| ) | ||
| ) | ||
| k += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,29 @@ | ||
| from pydantic import Field | ||
|
|
||
| from ...models.database import Type | ||
| from .base import Base | ||
|
|
||
|
|
||
| class ButtonCreate(Base): | ||
| icon: str | None | ||
| name: str | None | ||
| link: str | None | ||
| type: str | None | ||
| icon: str = Field(description='Иконка кнопки') | ||
| name: str = Field(description='Название кнопки') | ||
| link: str = Field(description='Ссылка, на которую перенаправляет кнопка') | ||
| type: Type = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') | ||
|
|
||
|
|
||
| class ButtonUpdate(Base): | ||
| category_id: int | None | ||
| icon: str | None | ||
| name: str | None | ||
| order: int | None | ||
| link: str | None | ||
| type: str | None | ||
| category_id: int | None = Field(description='Айди категории') | ||
| icon: str | None = Field(description='Иконка кнопки') | ||
| name: str | None = Field(description='Название кнопки') | ||
| order: int | None = Field(description='Порядок, в котором отображаются кнопки') | ||
| link: str | None = Field(description='Ссылка, на которую перенаправляет кнопка') | ||
| type: str | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') | ||
|
|
||
|
|
||
| class ButtonGet(Base): | ||
| id: int | ||
| order: int | ||
| icon: str | None | ||
| name: str | None | ||
| link: str | None | ||
| type: str | None | ||
| id: int = Field(description='Айди кнопки') | ||
| order: int = Field(description='Порядок, в котором отображаются кнопки') | ||
| icon: str | None = Field(description='Иконка кнопки') | ||
| name: str | None = Field(description='Название кнопки') | ||
| link: str | None = Field(description='Ссылка, на которую перенаправляет кнопка') | ||
| type: str | None = Field(description='Тип открываемой ссылки (Ссылка приложения/Браузер в приложении/Браузер') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.