Commit f48de9fc authored by yevgeniy's avatar yevgeniy

inital

parents
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="db.sqlite3" uuid="cc613ac2-2629-4409-b88f-2c317c47e54b">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (webinartest)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/webinartest.iml" filepath="$PROJECT_DIR$/.idea/webinartest.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="webinartest/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/templates" />
</list>
</option>
</component>
</module>
\ No newline at end of file
File added
#!/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', 'webinartest.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()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style>
.deadline-field > input {
border-radius: 3px;
border: 1px solid blue;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Todos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<h1>Создайте задачу</h1>
<div class="container w-50">
<form action="/create/" class="form" method="POST">
{% csrf_token %}
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">{{ form.title.label }}</label>
{# <input type="text" class="form-control" name="title" id="exampleInputEmail1" aria-describedby="emailHelp">#}
{{ form.title }}
{% if form.title.errors %}
<p class="text-danger">{{ form.title.errors }}</p>
{% endif %}
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">{{ form.deadline.label }}</label>
<div class="deadline-field">
{{ form.deadline }}
{% if form.deadline.errors %}
<p class="text-danger">{{ form.deadline.errors }}</p>
{% endif %}
</div>
{# <input type="datetime-local" name="deadline" class="form-control" id="exampleInputPassword1">#}
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">{{ form.status.label }}</label>
{# <select name="status" class="form-select" aria-label="Default select example">#}
{# <option selected>Open this select menu</option>#}
{# {% for choice in choices %}#}
{# <option value="{{ choice.0 }}">{{ choice.1 }}</option>#}
{# {% endfor %}#}
{# </select>#}
{{ form.status }}
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Todos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/create/">Create page</a>
</li>
</ul>
</div>
</div>
</nav>
<h1>Задачи</h1>
<div class="container">
<div class="row">
{% for todo in todos %}
<div class="col-4">
<h5>Заголовок {{ todo.title }}</h5>
<p>Статус {{ todo.status }}</p>
<p>Дедлайн {{ todo.deadline }}</p>
</div>
{% endfor %}
</div>
</div>
</body>
</html>
\ No newline at end of file
from django.contrib import admin
from .models import Todo
# Register your models here.
admin.site.register(Todo)
from django.apps import AppConfig
class WebappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'webapp'
from django import forms
from .models import Todo
class TodoForm(forms.Form):
title = forms.CharField(max_length=15, min_length=3, required=True, label="Заголовок", error_messages={
'required': "Введи пожалуйста",
'max_length': "Слишком много!"
})
status = forms.ChoiceField(choices=Todo.STATUS_CHOICES, required=True, label="Статус")
deadline = forms.DateTimeField(required=True, label="Дедлайн")
# Generated by Django 4.0 on 2021-12-22 13:46
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Todo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=256, verbose_name='Заголовок')),
('status', models.CharField(choices=[('NEW', 'Новая'), ('WORK', 'В работе'), ('FINISHED', 'Завершенные')], max_length=256, verbose_name='Заголовок')),
('deadline', models.DateTimeField()),
],
),
]
from django.db import models
# Create your models here.
class Todo(models.Model):
STATUS_CHOICES = [
("NEW", "Новая"),
("WORK", "В работе"),
("FINISHED", "Завершенные"),
]
title = models.CharField(max_length=256, null=False, blank=False, verbose_name="Заголовок")
status = models.CharField(max_length=256, choices=STATUS_CHOICES, null=False, blank=False, verbose_name="Статус")
deadline = models.DateTimeField(verbose_name="Дата выполнения")
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render, redirect
from .models import Todo
from .forms import TodoForm
# Create your views here.
def home_page(request):
todos = Todo.objects.all()
context = {
'todos': todos
}
return render(request, "index.html", context)
def create_todo_page(request):
if request.method == "GET":
form = TodoForm()
choices = Todo.STATUS_CHOICES
context = {
"choices": choices,
"form": form
}
return render(request, "create_todo.html", context)
elif request.method == "POST":
form = TodoForm(request.POST)
if form.is_valid():
Todo.objects.create(title=request.POST.get("title"), status=request.POST.get('status'),
deadline=request.POST.get("deadline"))
return redirect("/")
else:
context = {
'form': form
}
return render(request, "create_todo.html", context)
# if len(title) < 3:
# choices = Todo.STATUS_CHOICES
# context = {
# "choices": choices,
# "error_title": "Длина должна быть больше 3"
# }
# return render(request, "create_todo.html", context)
# return redirect("/")
"""
ASGI config for webinartest project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webinartest.settings')
application = get_asgi_application()
"""
Django settings for webinartest project.
Generated by 'django-admin startproject' using Django 4.0.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
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.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-^xql6ycqjg2zt$xxxl2=709i0alpw7dajs$s*$m)v2v^3#kze@'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webapp'
]
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 = 'webinartest.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates']
,
'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 = 'webinartest.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/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.0/topics/i18n/
LANGUAGE_CODE = 'ru-ru'
TIME_ZONE = 'Asia/Almaty'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
"""webinartest URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from webapp import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home_page),
path('create/', views.create_todo_page),
]
"""
WSGI config for webinartest project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webinartest.settings')
application = get_wsgi_application()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment