Skip to content

Commit

Permalink
Merge branch 'dev' into docx_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Raidzin authored Nov 1, 2023
2 parents c2a45e5 + f5abcf6 commit 74df814
Show file tree
Hide file tree
Showing 43 changed files with 686 additions and 35 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/mypy_flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: flake8 Lint

on: [push, pull_request]

jobs:
flake8-lint:
runs-on: ubuntu-latest
name: Проверка flake8
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: flake8 Lint
uses: py-actions/flake8@v2

run_mypy:
runs-on: ubuntu-latest
name: Mypy
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Mypy
uses: jashparekh/mypy-action@v2
with:
requirements: django-stubs django
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ cython_debug/

# PyCharm
.idea/

static/
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim-bullseye AS builder

RUN mkdir /app
WORKDIR /app
COPY poetry.lock pyproject.toml ./

RUN python -m pip install --no-cache-dir poetry==1.6.1 \
&& poetry config virtualenvs.in-project true \
&& poetry install --without dev --with test

FROM python:3.11-slim-bullseye

COPY --from=builder /app /app
COPY adaptive_hockey_federation/ ./

CMD ["/app/.venv/bin/gunicorn", "adaptive_hockey_federation.wsgi:application", "--bind", "0:8000" ]
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ git clone https://github.com/Studio-Yandex-Practicum/adaptive_hockey_federation.
cd adaptive_hockey_federation
```

##### Установить зависимости
##### СОбрать образ и запустить приложение из Dockerfile

```shell
poetry install --with dev --with test
docker build -t adaptive-hockey-federation .
docker run --name adaptive-hockey-federation -it -p 8000:8000 adaptive-hockey-federation
```

## Локальный запуск

### **TODO**
```shell
cd adaptive_hockey_federation
python manage.py runserver
```
Empty file.
10 changes: 10 additions & 0 deletions adaptive_hockey_federation/adaptive_hockey_federation/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

from django.core.asgi import get_asgi_application

os.environ.setdefault(
'DJANGO_SETTINGS_MODULE',
'adaptive_hockey_federation.settings'
)

application = get_asgi_application()
129 changes: 129 additions & 0 deletions adaptive_hockey_federation/adaptive_hockey_federation/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
"""
Django settings for adaptive_hockey_federation project.
Generated by 'django-admin startproject' using Django 4.2.6.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import os

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-))v)^p&_y!_-dsc7p)v%b@yi+#)k^34mp^ai8jc^9v)jpu2xn1'

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

ALLOWED_HOSTS: list = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main.apps.MainConfig',
'users.apps.UsersConfig',
]

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 = 'adaptive_hockey_federation.urls'

TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR],
'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 = 'adaptive_hockey_federation.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'ru'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
9 changes: 9 additions & 0 deletions adaptive_hockey_federation/adaptive_hockey_federation/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin
from django.urls import path, include


urlpatterns = [
path('admin/', admin.site.urls),
path('', include('main.urls', namespace='main')),
path('auth/', include('users.urls', namespace='users')),
]
10 changes: 10 additions & 0 deletions adaptive_hockey_federation/adaptive_hockey_federation/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault(
'DJANGO_SETTINGS_MODULE',
'adaptive_hockey_federation.settings'
)

application = get_wsgi_application()
Empty file.
3 changes: 3 additions & 0 deletions adaptive_hockey_federation/main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin # noqa

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


class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'
verbose_name = 'Главное'
Empty file.
3 changes: 3 additions & 0 deletions adaptive_hockey_federation/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models # noqa

# Create your models here.
20 changes: 20 additions & 0 deletions adaptive_hockey_federation/main/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.urls import path

from . import views

app_name = 'main'


urlpatterns = [
path('users/', views.users, name='users'),
path('teams/<int:id>/', views.teams_id, name='teams_id'),
path('teams/', views.teams, name='teams'),
path(
'competitions/<int:id>/',
views.competitions_id,
name='competitions_id',
),
path('competitions/', views.competitions, name='competitions'),
path('analytics/', views.analytics, name='analytics'),
path('unloads/', views.unloads, name='unloads'),
]
29 changes: 29 additions & 0 deletions adaptive_hockey_federation/main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.shortcuts import render


def users(request):
return render(request, 'main/users.html')


def teams_id(request, id):
return render(request, 'main/teams_id.html')


def teams(request):
return render(request, 'main/teams.html')


def competitions_id(request, id):
return render(request, 'main/competitions_id.html')


def competitions(request):
return render(request, 'main/competitions.html')


def analytics(request):
return render(request, 'main/analitics.html')


def unloads(request):
return render(request, 'main/unloads.html')
23 changes: 23 additions & 0 deletions adaptive_hockey_federation/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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',
'adaptive_hockey_federation.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()
30 changes: 30 additions & 0 deletions adaptive_hockey_federation/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<script src="https://cdn.tailwindcss.com"></script>
<title>
{% block title %}
Тут будет заголовок
{% endblock %}
</title>
</head>
<body class="d-flex flex-column min-vh-100">
<header>
{% include 'includes/header.html' %}
</header>
<main class="container py-5 text-center text-2xl">
{% block content %}
Основной текст
{% endblock %}
</main>
<footer class="mt-auto">
{% include 'includes/footer.html' %}
</footer>
{% include 'includes/drawer.html' %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions adaptive_hockey_federation/templates/includes/button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% with request.path as current_url_name %}
<a href="{{ url_name }}"
class="nav-link border border-2 border-white hover:bg-[#340061] text-white p-2 mx-1 w-44 text-left
{% if current_url_name == url_name %}bg-[#340061]{% else %}bg-[#64c2d1]{% endif %}">
{{ name }}
</a>
{% endwith %}
Loading

0 comments on commit 74df814

Please sign in to comment.