-
Notifications
You must be signed in to change notification settings - Fork 14
[#H25] HW TodoFront #99
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
Open
ShedkoV
wants to merge
4
commits into
Chudopal:main
Choose a base branch
from
ShedkoV:HW_TodoFrontService
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions
22
Shops/household_shop/homeworks/django_todo_front/manage.py
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,22 @@ | ||
| #!/usr/bin/env python | ||
| """Django's command-line utility for administrative tasks.""" | ||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| """Run administrative tasks.""" | ||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_service.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() |
31 changes: 31 additions & 0 deletions
31
Shops/household_shop/homeworks/django_todo_front/templates/base.html
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,31 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <!-- Кодировка веб-страницы --> | ||
| <meta charset="utf-8"> | ||
| <!-- Настройка viewport --> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| {% block title %}<title>Base title</title>{% endblock %} | ||
| <!-- Bootstrap CSS (jsDelivr CDN) --> | ||
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> | ||
| <!-- Bootstrap Bundle JS (jsDelivr CDN) --> | ||
| <script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="center-block "> | ||
|
|
||
| <nav class="navbar navbar-expand-lg navbar-light bg-light justify-content-center nav-pills nav-fill"> | ||
| <div class="nav-item"> | ||
| <a {% block bar_list %}class="nav-link"{% endblock %} href="{% url 'event-list' %}">Все события</a> | ||
| </div> | ||
| <div class="nav-item"> | ||
| <a {% block bar_add %}class="nav-link" {% endblock %} href="{% url 'event-add' %}">Добавить событие</a> | ||
| </div> | ||
| </nav> | ||
|
|
||
| {% block sidebar %}<!-- insert default navigation text for every page -->{% endblock %} | ||
| {% block content %}<!-- default content text (typically empty) -->{% endblock %} | ||
| </div> | ||
| </body> | ||
| </html> |
52 changes: 52 additions & 0 deletions
52
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_add.html
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,52 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block bar_add %}class="nav-link active" {% endblock %} | ||
|
|
||
|
|
||
| {% block content %} | ||
|
|
||
| <form action="" method="post"> | ||
| {% csrf_token %} | ||
|
|
||
| <div class="d-grid gap-2 col-6 mx-auto"> | ||
| <h3 class="h2 my-3">Добавить событие</h3> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text">Название</span> | ||
| {{ form.title }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Описание</span> | ||
| {{ form.description }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Статус</span> | ||
| {{ form.status }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Зависит от</span> | ||
| {{ form.depends_on }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" id="title-descr">Старт</span> | ||
| {{ form.started_at }} | ||
| <span class="input-group-text" id="title-descr">Дэдлайн</span> | ||
| {{ form.finished_at }} | ||
| </div> | ||
|
|
||
| {{form.started_at.errors}} | ||
| {{form.finished_at.errors}} | ||
| {{form.status.errors}} | ||
|
|
||
| <button class="btn btn-primary" type="submit"> | ||
| Создать событие | ||
| </button> | ||
|
|
||
| </div> | ||
| </form> | ||
|
|
||
| {% endblock %} |
19 changes: 19 additions & 0 deletions
19
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_analytics.html
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,19 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block bar_analitics %} class="nav-link active" {% endblock %} | ||
|
|
||
| {% block content %} | ||
| <div class="container"> | ||
|
|
||
| <h3 class="h2 my-3">Аналитика событий:</h3> | ||
|
|
||
| <div class="list-group"> | ||
|
|
||
| {% for status, percentage in events.items %} | ||
| <a class="list-group-item list-group-item-action ">{{ status }} - {{ percentage }}% </a> | ||
| {% endfor %} | ||
|
|
||
| </div> | ||
|
|
||
| </div> | ||
| {% endblock %} |
20 changes: 20 additions & 0 deletions
20
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_delete.html
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,20 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
|
|
||
| {% block content %} | ||
|
|
||
|
|
||
| <form method="post">{% csrf_token %} | ||
| <div class="d-grid gap-2 col-6 mx-auto"> | ||
| <h3 class="h4 my-4">А ты уверен, что хочешь удалить событие "{{ object.title }}"?</h3> | ||
|
|
||
| {{ form }} | ||
|
|
||
| <button class="btn btn-primary btn-danger" type="submit"> | ||
| Удалить событие | ||
| </button> | ||
|
|
||
| </div> | ||
| </form> | ||
|
|
||
| {% endblock %} |
48 changes: 48 additions & 0 deletions
48
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_detail.html
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,48 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block content %} | ||
|
|
||
| <div class="container"> | ||
|
|
||
| <h3 class="h2 my-3">{{ object.title }} ({{ object.status }})</h3> | ||
|
|
||
|
|
||
| <div class="list-group"> | ||
| <div class="list-group-item list-group-item"> | ||
| <div class="d-flex w-100 justify-content-between"> | ||
| <p class="mb-3">{{ object.description }}</p> | ||
|
|
||
| </div> | ||
|
|
||
|
|
||
| <div class="container overflow-hidden"> | ||
| <div class="row gy-5"> | ||
| <div class="col-6"> | ||
| <div class="p-3 border bg-light">Старт: {{ object.started_at }}</div> | ||
| </div> | ||
| <div class="col-6"> | ||
| <div class="p-3 border bg-light">Истекает: {{ object.finished_at }}</div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {% if object.depends_on %} | ||
| <div class="d-flex w-100 justify-content-between"> | ||
| <p class="mt-3">Зависит от <a href="{% url 'event-detail' object.depends_on.pk %}">{{ object.depends_on.title }} </a></p> | ||
| </div> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
|
|
||
| <ul class="nav nav-pills justify-content-end"> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="{% url 'event-update' object.id %}">Изменить</a> | ||
| </li> | ||
| <li class="nav-item nav-item-danger"> | ||
| <a class="nav-link list-group-item-danger" href="{% url 'event-delete' object.id %}">Удалить</a> | ||
| </li> | ||
| </ul> | ||
|
|
||
| </div> | ||
|
|
||
| {% endblock %} |
39 changes: 39 additions & 0 deletions
39
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_list.html
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,39 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block bar_list %}class="nav-link active" {% endblock %} | ||
|
|
||
| {% block content %} | ||
| <div class="container"> | ||
|
|
||
| <h3 class="h2 my-3">Твои события:</h3> | ||
|
|
||
| <div> | ||
|
|
||
| <a class="btn btn-outline-primary" href="{% url 'event-list' %}?status=in progress" role="button">In progress</a> | ||
| <a class="btn btn-outline-primary" href="{% url 'event-list' %}?status=finished" role="button">Finished</a> | ||
| <a class="btn btn-outline-primary" href="{% url 'event-list' %}?status=is waiting" role="button">Waiting</a> | ||
| <a class="btn btn-outline-primary" href="{% url 'event-list' %}?status=expired" role="button">Expired</a> | ||
| <a class="btn btn-outline-primary" href="{% url 'event-list' %}?status=blocked" role="button">Blocked</a> | ||
|
|
||
| </div> | ||
|
|
||
| <div class="list-group"> | ||
|
|
||
| {% for event in events %} | ||
| {% if event.status == "expired" %} | ||
| <a href="{% url 'event-detail' event.id %}" class="list-group-item list-group-item-action list-group-item-danger">{{ event.title }} </a> | ||
| {% elif event.status == "finished" %} | ||
| <a href="{% url 'event-detail' event.id %}" class="list-group-item list-group-item-action list-group-item-success">{{ event.title }} </a> | ||
| {% elif event.status == "in progress" %} | ||
| <a href="{% url 'event-detail' event.id %}" class="list-group-item list-group-item-action list-group-item-warning">{{ event.title }} </a> | ||
| {% else %} | ||
| <a href="{% url 'event-detail' event.id %}" class="list-group-item list-group-item-action ">{{ event.title }} </a> | ||
| {% endif %} | ||
| {% empty %} | ||
| <a href="{% url 'event-add'%}" class="list-group-item list-group-item-action">Попробуй добавь какое-нибудь событие... </a> | ||
| {% endfor %} | ||
|
|
||
| </div> | ||
|
|
||
| </div> | ||
| {% endblock %} |
52 changes: 52 additions & 0 deletions
52
Shops/household_shop/homeworks/django_todo_front/templates/plan/event_update.html
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,52 @@ | ||
| {% extends "base.html" %} | ||
|
|
||
| {% block bar_add %}class="nav-link active" {% endblock %} | ||
|
|
||
|
|
||
| {% block content %} | ||
|
|
||
| <form action="" method="post"> | ||
| {% csrf_token %} | ||
|
|
||
| <div class="d-grid gap-2 col-6 mx-auto"> | ||
|
|
||
| <h3 class="h2 my-3">Обновить событие</h3> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text">Название</span> | ||
| {{ form.title }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Описание</span> | ||
| {{ form.description }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Статус</span> | ||
| {{ form.status }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" >Зависит от</span> | ||
| {{ form.depends_on }} | ||
| </div> | ||
|
|
||
| <div class="input-group input-group-sm mb-3"> | ||
| <span class="input-group-text" id="title-descr">Старт</span> | ||
| {{ form.started_at }} | ||
| <span class="input-group-text" id="title-descr">Дэдлайн</span> | ||
| {{ form.finished_at }} | ||
| </div> | ||
|
|
||
| {{form.started_at.errors}} | ||
| {{form.finished_at.errors}} | ||
| {{form.status.errors}} | ||
|
|
||
| <button class="btn btn-primary btn-info" type="submit"> | ||
| Обновить событие | ||
| </button> | ||
| </div> | ||
| </form> | ||
|
|
||
| {% endblock %} |
Empty file.
3 changes: 3 additions & 0 deletions
3
Shops/household_shop/homeworks/django_todo_front/todo_front/admin.py
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,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
6 changes: 6 additions & 0 deletions
6
Shops/household_shop/homeworks/django_todo_front/todo_front/apps.py
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,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class TodoFrontConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'todo_front' |
Empty file.
13 changes: 13 additions & 0 deletions
13
Shops/household_shop/homeworks/django_todo_front/todo_front/models.py
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,13 @@ | ||
| from pydantic import BaseModel | ||
| from typing import Optional | ||
|
|
||
|
|
||
| class Event(BaseModel): | ||
| id: str | ||
| created_at: str | ||
| started_at: str | ||
| finished_at: str | ||
| title: str | ||
| description: str | ||
| depends_on: Optional[str] = '' | ||
| status: str | ||
22 changes: 22 additions & 0 deletions
22
Shops/household_shop/homeworks/django_todo_front/todo_front/request_service.py
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,22 @@ | ||
| import requests | ||
|
|
||
|
|
||
| class ConnectService: | ||
| def __init__(self, url) -> None: | ||
| self.url = url | ||
| self.headers = {"Content-type": "application/json"} | ||
|
|
||
| def get_list_events(self): | ||
| return requests.get(url=self.url).json() | ||
|
|
||
| def add_event(self, data): | ||
| return requests.post(url=self.url, data=data, headers=self.headers) | ||
|
|
||
| def get_event_detail(self): | ||
| return requests.get(url=self.url).json() | ||
|
|
||
| def delete_event(self): | ||
| return requests.delete(url=self.url) | ||
|
|
||
| def update_event(self, data): | ||
| return requests.put(url=self.url, data=data, headers=self.headers) |
3 changes: 3 additions & 0 deletions
3
Shops/household_shop/homeworks/django_todo_front/todo_front/tests.py
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,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
11 changes: 11 additions & 0 deletions
11
Shops/household_shop/homeworks/django_todo_front/todo_front/urls.py
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,11 @@ | ||
| from django.urls import path | ||
| from .views import get_events_list, create_new_event, get_event_detail, delete_event, update_event | ||
|
|
||
|
|
||
| urlpatterns = [ | ||
| path('list/', get_events_list, name='event-list'), | ||
| path('add/', create_new_event, name='event-add'), | ||
| path('<str:pk>/', get_event_detail, name='event-detail'), | ||
| path('<str:pk>/delete/', delete_event, name='event-delete'), | ||
| path('<str:pk>/update/', update_event, name='event-update'), | ||
| ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Жене в ПРе оставил замечания по этому классу данных, посмотри их
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вопрос решён, @mega-yujin дал добро