From e22835fd7bc996a8907cc01676549db883fd697a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Oct 2023 19:10:28 +0300 Subject: [PATCH 01/13] created custom page --- my_app/urls.py | 0 templates/index.html | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 my_app/urls.py create mode 100644 templates/index.html diff --git a/my_app/urls.py b/my_app/urls.py new file mode 100644 index 0000000..e69de29 diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..4bdcfcb --- /dev/null +++ b/templates/index.html @@ -0,0 +1,10 @@ + + + + + $Title$ + + +$END$ + + \ No newline at end of file From c2a4cd064d3118b90f703ed0f56851510342d0b2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Oct 2023 19:17:30 +0300 Subject: [PATCH 02/13] created custom page --- Lab1/urls.py | 5 +++-- my_app/urls.py | 26 ++++++++++++++++++++++++++ my_app/views.py | 2 ++ templates/index.html | 10 ++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 my_app/urls.py create mode 100644 templates/index.html diff --git a/Lab1/urls.py b/Lab1/urls.py index 306f148..c615368 100644 --- a/Lab1/urls.py +++ b/Lab1/urls.py @@ -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")) +] \ No newline at end of file diff --git a/my_app/urls.py b/my_app/urls.py new file mode 100644 index 0000000..40a4ced --- /dev/null +++ b/my_app/urls.py @@ -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" \ No newline at end of file diff --git a/my_app/views.py b/my_app/views.py index 91ea44a..f7be34d 100644 --- a/my_app/views.py +++ b/my_app/views.py @@ -1,3 +1,5 @@ from django.shortcuts import render # Create your views here. +def index(request): + return render(request, 'index.html',) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/templates/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file From 192e903d1d69eaf63197b0ae011fab64db7adda1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Oct 2023 19:20:30 +0300 Subject: [PATCH 03/13] new page --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 566549b..a11e75e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,6 @@ Title - +lorem ipsum \ No newline at end of file From e793274ce2fb866111113388035879034db48e89 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Oct 2023 19:38:58 +0300 Subject: [PATCH 04/13] third modification --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index f888efa..51984cc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,6 @@ Title -lorem ipsum fhfghfghf +lorem ipsum fhfghfghf nazar \ No newline at end of file From f67d061311825652f0e4e1d2f6c8e50d99f28813 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 18:16:36 +0200 Subject: [PATCH 05/13] Lab2-3 --- .flake8 | 10 ++ build.py | 22 +++++ my_app/migrations/0001_initial.py | 148 ++++++++++++++++++++++++++++++ my_app/tests/__init__.py | 0 my_app/tests/test_view.py | 20 ++++ requirements.txt | Bin 0 -> 320 bytes 6 files changed, 200 insertions(+) create mode 100644 .flake8 create mode 100644 build.py create mode 100644 my_app/migrations/0001_initial.py create mode 100644 my_app/tests/__init__.py create mode 100644 my_app/tests/test_view.py create mode 100644 requirements.txt diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..b5381af --- /dev/null +++ b/.flake8 @@ -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 \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..7737b16 --- /dev/null +++ b/build.py @@ -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() diff --git a/my_app/migrations/0001_initial.py b/my_app/migrations/0001_initial.py new file mode 100644 index 0000000..0aeff67 --- /dev/null +++ b/my_app/migrations/0001_initial.py @@ -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()), + ], + ), + ] diff --git a/my_app/tests/__init__.py b/my_app/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/my_app/tests/test_view.py b/my_app/tests/test_view.py new file mode 100644 index 0000000..3042548 --- /dev/null +++ b/my_app/tests/test_view.py @@ -0,0 +1,20 @@ +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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..8bc3ff2091375291c58cba0e38f15a2d763b09da GIT binary patch literal 320 zcmY+9!3x4K5JcxJ_$f-87WLxIli+iQMMx$Q6UhaaHbEa3nE literal 0 HcmV?d00001 From b9595e8a3487389566852e285689ddc091c804aa Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 18:22:25 +0200 Subject: [PATCH 06/13] Lab4 --- .github/workflows/cl.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/cl.yml diff --git a/.github/workflows/cl.yml b/.github/workflows/cl.yml new file mode 100644 index 0000000..a14a8f2 --- /dev/null +++ b/.github/workflows/cl.yml @@ -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 From ef744dc27f2cac15126bee3c472e965979d271b4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 18:26:47 +0200 Subject: [PATCH 07/13] updated Lab4 --- .github/workflows/cl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cl.yml b/.github/workflows/cl.yml index a14a8f2..9e30f8b 100644 --- a/.github/workflows/cl.yml +++ b/.github/workflows/cl.yml @@ -24,7 +24,7 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - - name: Run .flake8 + - name: Run flake8 run: flake8 - name: Run tests From 51221ada24742631002887e8478e6f487de3af6a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 18:32:18 +0200 Subject: [PATCH 08/13] updated Lab2-3 --- requirements.txt | Bin 320 -> 350 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8bc3ff2091375291c58cba0e38f15a2d763b09da..d4def7799329a5fa9af4aab8d5c5a7c0c5414936 100644 GIT binary patch delta 38 qcmX@WbdPC+1EX9TLk>eCLpDPyg9U>v5SlUQF&F}|0Rt}s7XtvQd Date: Mon, 30 Oct 2023 18:35:38 +0200 Subject: [PATCH 09/13] updated Lab2-3 --- Lab1/settings.py | 15 ++++++++++----- Lab1/urls.py | 2 +- my_app/urls.py | 4 ++-- my_app/views.py | 4 +++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Lab1/settings.py b/Lab1/settings.py index 32ce6f1..a202cd6 100644 --- a/Lab1/settings.py +++ b/Lab1/settings.py @@ -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 @@ -88,16 +89,20 @@ 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', }, ] diff --git a/Lab1/urls.py b/Lab1/urls.py index c615368..5c00b34 100644 --- a/Lab1/urls.py +++ b/Lab1/urls.py @@ -20,4 +20,4 @@ urlpatterns = [ path('admin/', admin.site.urls), path("", include("my_app.urls", namespace="my_app")) -] \ No newline at end of file +] diff --git a/my_app/urls.py b/my_app/urls.py index 40a4ced..dde2da1 100644 --- a/my_app/urls.py +++ b/my_app/urls.py @@ -20,7 +20,7 @@ from my_app.views import index urlpatterns = [ - path("",index,name="index"), + path("", index, name="index"), ] -app_name = "my_app" \ No newline at end of file +app_name = "my_app" diff --git a/my_app/views.py b/my_app/views.py index f7be34d..4cd5f15 100644 --- a/my_app/views.py +++ b/my_app/views.py @@ -1,5 +1,7 @@ from django.shortcuts import render # Create your views here. + + def index(request): - return render(request, 'index.html',) \ No newline at end of file + return render(request, 'index.html',) From 3da65f317263fa11a7be077f319534194467688c Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 20:27:28 +0200 Subject: [PATCH 10/13] updated Lab2-3 --- Lab1/settings.py | 2 +- my_app/models.py | 11 +++++++++++ my_app/tests/test_view.py | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Lab1/settings.py b/Lab1/settings.py index a202cd6..f96e358 100644 --- a/Lab1/settings.py +++ b/Lab1/settings.py @@ -105,7 +105,7 @@ 'dation.NumericPasswordValidator', }, ] - +AUTH_USER_MODEL = "my_app.User" # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ diff --git a/my_app/models.py b/my_app/models.py index 71a8362..24563cf 100644 --- a/my_app/models.py +++ b/my_app/models.py @@ -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) diff --git a/my_app/tests/test_view.py b/my_app/tests/test_view.py index 3042548..1d8ad63 100644 --- a/my_app/tests/test_view.py +++ b/my_app/tests/test_view.py @@ -3,7 +3,11 @@ from my_app.models import Cars -CARS = {"model": "Test", "country": "Ukraine", "age": 5} +CARS = { + "model": "Test", + "country": "Ukraine", + "age": 5 +} class MyappTests(TestCase): From e6e98f5a5db56fc2c409c8eaaac64d05dbf7e9b7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Oct 2023 20:29:41 +0200 Subject: [PATCH 11/13] updated Lab2-3 --- my_app/tests.py | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 my_app/tests.py diff --git a/my_app/tests.py b/my_app/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/my_app/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. From ce12f88c35d78dbe557fc792926802a0f82bf0ee Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 31 Oct 2023 15:49:14 +0200 Subject: [PATCH 12/13] Lab1 --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 51984cc..04dae51 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,6 @@ Title -lorem ipsum fhfghfghf nazar +lorem ipsum fhfghfghf nazar 5 para \ No newline at end of file From b961784f956a3cc97aef5a08bced0c81a665b765 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 7 Nov 2023 15:37:11 +0200 Subject: [PATCH 13/13] Lab5 --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 04dae51..f581a2f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,6 @@ Title -lorem ipsum fhfghfghf nazar 5 para +lorem ipsum fhfghfghf nazar 5 parahghf \ No newline at end of file