Skip to content
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

created custom page #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
inline-quotes = "
ignore = E203, E266, W503, N807, N818, F401
max-line-length = 79
max-complexity = 18
select = B,C,E,F,W,T4,B9,Q0,N8,VNE
exclude =
**migrations
venv
tests
32 changes: 32 additions & 0 deletions .github/workflows/cl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: cl

on:
push:
branches:
- "develop"

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Set Up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install requirements.txt
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run flake8
run: flake8

- name: Run tests
timeout-minutes: 5
run: python manage.py test
17 changes: 11 additions & 6 deletions Lab1/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# 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-6d$y7d(mbj*goqxon!s9v%!pjortap#xroe+95!lxve2xwr=y1'
SECRET_KEY = 'django-insecure-6d$y7d(mbj*goqxon!s9v%!p' \
'jortap#xroe+95!lxve2xwr=y1'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down Expand Up @@ -88,19 +89,23 @@

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

AUTH_USER_MODEL = "my_app.User"

# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
Expand Down
3 changes: 2 additions & 1 deletion Lab1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path("", include("my_app.urls", namespace="my_app"))
]
22 changes: 22 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import subprocess


def build_project():
print("Початок збірки Django проекту")

# Створення віртуального середовища
subprocess.run(["python", "-m", "venv", "venv"])

# Активація віртуального середовища на Windows
subprocess.run([r".\venv\Scripts\activate.bat"])

# Встановлення залежностей Python з requirements.txt
subprocess.run(["pip", "install", "-r", "requirements.txt"])

subprocess.run(["python", "manage.py", "runserver"])

print("Збірка завершена")


if __name__ == "__main__":
build_project()
148 changes: 148 additions & 0 deletions my_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Generated by Django 3.2.7 on 2023-10-29 15:44

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):
initial = True

dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
]

operations = [
migrations.CreateModel(
name="Cars",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("model", models.CharField(max_length=255)),
("country", models.CharField(max_length=255)),
("age", models.IntegerField(blank=True)),
],
),
migrations.CreateModel(
name="User",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("password", models.CharField(max_length=128, verbose_name="password")),
(
"last_login",
models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
(
"username",
models.CharField(
error_messages={
"unique": "A user with that username already exists."
},
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
max_length=150,
unique=True,
validators=[
django.contrib.auth.validators.UnicodeUsernameValidator()
],
verbose_name="username",
),
),
(
"first_name",
models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
(
"last_name",
models.CharField(
blank=True, max_length=150, verbose_name="last name"
),
),
(
"email",
models.EmailField(
blank=True, max_length=254, verbose_name="email address"
),
),
(
"is_staff",
models.BooleanField(
default=False,
help_text="Designates whether the user can log into this admin site.",
verbose_name="staff status",
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
verbose_name="active",
),
),
(
"date_joined",
models.DateTimeField(
default=django.utils.timezone.now, verbose_name="date joined"
),
),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.Group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.Permission",
verbose_name="user permissions",
),
),
],
options={
"verbose_name": "user",
"verbose_name_plural": "users",
"abstract": False,
},
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
]
11 changes: 11 additions & 0 deletions my_app/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.


class User(AbstractUser):
pass


class Cars(models.Model):
model = models.CharField(max_length=255)
country = models.CharField(max_length=255)
age = models.IntegerField(blank=True)
3 changes: 0 additions & 3 deletions my_app/tests.py

This file was deleted.

Empty file added my_app/tests/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions my_app/tests/test_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.test import TestCase
from django.urls import reverse

from my_app.models import Cars

CARS = {
"model": "Test",
"country": "Ukraine",
"age": 5
}


class MyappTests(TestCase):
def test_index_status_code(self):
response = self.client.get(reverse("my_app:index"))
self.assertEqual(response.status_code, 200)

def test_index(self):
response = self.client.get(reverse("my_app:index"))
self.assertContains(response, "nazar")

def test_count_cars(self):
Cars.objects.create(**CARS)
self.assertEqual(Cars.objects.count(), 1)
26 changes: 26 additions & 0 deletions my_app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
URL configuration for Lab1 project.

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/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 my_app.views import index

urlpatterns = [
path("", index, name="index"),
]

app_name = "my_app"
4 changes: 4 additions & 0 deletions my_app/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from django.shortcuts import render

# Create your views here.


def index(request):
return render(request, 'index.html',)
Binary file added requirements.txt
Binary file not shown.
10 changes: 10 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
lorem ipsum fhfghfghf nazar 5 parahghf
</body>
</html>
Loading