Forráskód Böngészése

http://gogs.tomtit.tomsk.ru:3000/gr421_isghdo/proekr.git

gr421_isghdo 1 éve
commit
735fa721b3

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Black">
+    <option name="sdkName" value="Python 3.12 (pythonProject)" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
+    </modules>
+  </component>
+</project>

+ 10 - 0
.idea/pythonProject.iml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.venv" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 0 - 0
Qwe/Qwe/__init__.py


+ 16 - 0
Qwe/Qwe/asgi.py

@@ -0,0 +1,16 @@
+"""
+ASGI config for Qwe 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/5.0/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qwe.settings")
+
+application = get_asgi_application()

+ 123 - 0
Qwe/Qwe/settings.py

@@ -0,0 +1,123 @@
+"""
+Django settings for Qwe project.
+
+Generated by 'django-admin startproject' using Django 5.0.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/5.0/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/5.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/5.0/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = "django-insecure-5f2bb-!nfu08l$+s&e&@3e1y8&4)e5gu_vk*_13q8_63^((5-r"
+
+# 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",
+    'main.apps.MainConfig',
+]
+
+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 = "Qwe.urls"
+
+TEMPLATES = [
+    {
+        "BACKEND": "django.template.backends.django.DjangoTemplates",
+        "DIRS": [],
+        "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 = "Qwe.wsgi.application"
+
+# Database
+# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
+
+DATABASES = {
+    "default": {
+        "ENGINE": "django.db.backends.sqlite3",
+        "NAME": BASE_DIR / "db.sqlite3",
+    }
+}
+
+# Password validation
+# https://docs.djangoproject.com/en/5.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/5.0/topics/i18n/
+
+LANGUAGE_CODE = "en-us"
+
+TIME_ZONE = "UTC"
+
+USE_I18N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/5.0/howto/static-files/
+
+STATIC_URL = "static/"
+
+# Default primary key field type
+# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
+
+DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+
+LOGOUT_REDIRECT_URL = 'CreatProduct'
+LOGIN_REDIRECT_URL = 'home'
+
+# AUTH_USER_MODEL = 'main.User'

+ 23 - 0
Qwe/Qwe/urls.py

@@ -0,0 +1,23 @@
+"""
+URL configuration for Qwe project.
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/5.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,include
+
+urlpatterns = [
+    path("admin/", admin.site.urls),
+    path("", include('main.urls')),
+]

+ 16 - 0
Qwe/Qwe/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for Qwe 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/5.0/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qwe.settings")
+
+application = get_wsgi_application()

BIN
Qwe/db.sqlite3


+ 0 - 0
Qwe/main/__init__.py


+ 6 - 0
Qwe/main/admin.py

@@ -0,0 +1,6 @@
+from django.contrib import admin
+from .models import *
+
+
+admin.site.register(Product)
+# admin.site.register(User)

+ 6 - 0
Qwe/main/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class MainConfig(AppConfig):
+    default_auto_field = "django.db.models.BigAutoField"
+    name = "main"

+ 12 - 0
Qwe/main/forms.py

@@ -0,0 +1,12 @@
+from django import forms
+
+from .models import Product
+
+
+class ProductForm(forms.ModelForm):
+    class Meta:
+        model = Product
+        fields = '__all__'
+
+
+

+ 37 - 0
Qwe/main/migrations/0001_initial.py

@@ -0,0 +1,37 @@
+# Generated by Django 4.2.8 on 2023-12-26 03:40
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    initial = True
+
+    dependencies = []
+
+    operations = [
+        migrations.CreateModel(
+            name="Product",
+            fields=[
+                (
+                    "id",
+                    models.BigAutoField(
+                        auto_created=True,
+                        primary_key=True,
+                        serialize=False,
+                        verbose_name="ID",
+                    ),
+                ),
+                ("name", models.CharField(max_length=256)),
+                ("opisanie", models.TextField(max_length=999)),
+                ("price", models.DecimalField(decimal_places=2, max_digits=50)),
+                ("image", models.ImageField(upload_to="media/product")),
+                (
+                    "type",
+                    models.CharField(
+                        choices=[("Услуги", "Услуги"), ("Товари", "Товари")],
+                        max_length=6,
+                    ),
+                ),
+            ],
+        ),
+    ]

+ 0 - 0
Qwe/main/migrations/__init__.py


+ 19 - 0
Qwe/main/models.py

@@ -0,0 +1,19 @@
+from django.contrib.auth.models import AbstractUser
+from django.db import models
+
+
+# class User(AbstractUser):
+#     avatar = models.ImageField(upload_to='media/profiles')
+
+
+class Product(models.Model):
+    name = models.CharField(max_length=256)
+    opisanie = models.TextField(max_length=999)
+    price = models.DecimalField(max_digits=50, decimal_places=2)
+    image = models.ImageField(upload_to='media/product')
+
+    types = (
+        ('Услуги', 'Услуги'),
+        ('Товари', 'Товари')
+    )
+    type = models.CharField(max_length=6, choices=types)

+ 6 - 0
Qwe/main/templates/Profile.html

@@ -0,0 +1,6 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+<h2>Профиль - {{ user.username }}</h2>
+{%  endblock%}

+ 70 - 0
Qwe/main/templates/base.html

@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
+          integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
+            integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
+            crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
+            integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
+            crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js"
+            integrity="sha384-BBtl+eGJRgqQAUMxJ7pMwbEyER4l1g+O15P+16Ep7Q9Q+zqX6gSbd85u4mG4QzX+"
+            crossorigin="anonymous"></script>
+    <title>Title</title>
+</head>
+<body>
+<nav class="navbar navbar-expand-lg bg-body-tertiary">
+  <div class="container-fluid">
+    <a class="navbar-brand" href="{% url 'home'%}">Главная</a>
+    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+      <span class="navbar-toggler-icon"></span>
+    </button>
+    <div class="collapse navbar-collapse" id="navbarSupportedContent">
+      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
+
+        <li class="nav-item">
+          <a class="nav-link active" aria-current="page" href="{% url 'CreatProduct'%}">Создание Товара\УСЛУГИ</a>
+        </li>
+        <li class="nav-item">
+          <a class="nav-link" href="{% url 'Profile'%}"> Профиль</a>
+        </li>
+          <li class="nav-item">
+          <a class="dropdown-item" href="{% url 'Logout'%}">Logout</a>
+        </li>
+          <br>
+          <li class="nav-item">
+          <li><a class="dropdown-item" href="{% url 'Login'%}">Login</a></li>
+        </li>
+
+        <li class="nav-item dropdown">
+          <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+            Dropdown
+          </a>
+          <ul class="dropdown-menu">
+            <li><a class="dropdown-item" href="{% url 'home'%}">Action</a></li>
+            <li><a class="dropdown-item" href="{% url 'home'%}">Another action</a></li>
+            <li><hr class="dropdown-divider"></li>
+            <li><a class="dropdown-item" href="{% url 'home'%}">Something else here</a></li>
+          </ul>
+        </li>
+        <li class="nav-item">
+          <a class="nav-link disabled" aria-disabled="true">Disabled</a>
+        </li>
+      </ul>
+        <form class="d-flex" role="search">
+        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
+        <button class="btn btn-outline-success" type="submit">Search</button>
+      </form>
+
+        <br>
+
+    </div>
+  </div>
+</nav>
+{%block content%}
+        {%  endblock%}
+</body>
+</html>

+ 9 - 0
Qwe/main/templates/createProduct.html

@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+{%block content%}
+<form method="post" enctype="multipart/form-data">
+     {% csrf_token %}
+    {{ form.as_p}}
+    <button type="submit" class="btn btn-success">Создать Товар\Услугу</button>
+
+</form>
+{%  endblock%}

+ 18 - 0
Qwe/main/templates/index.html

@@ -0,0 +1,18 @@
+{% extends 'base.html' %}
+
+{% block content %}
+
+
+
+<h2>Название: {{ product.product.name }}</h2>
+
+<p>Описание: {{ product.product.opisanie }}</p>
+
+<p>Тип товара: {{ product.product.type }}</p>
+
+<img src="{{ product.product.image.url }}" alt="Изображение отсутствует" width="300px" height="300px">
+
+
+
+
+{% endblock %}

+ 9 - 0
Qwe/main/templates/login.html

@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+{%block content%}
+<form method="post" enctype="multipart/form-data">
+     {% csrf_token %}
+    {{ form.as_p}}
+    <button type="submit" class="btn btn-success">Войти</button>
+
+</form>
+{%  endblock%}

+ 10 - 0
Qwe/main/templates/logout.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+
+</body>
+</html>

+ 0 - 0
Qwe/main/templates/register.html


+ 3 - 0
Qwe/main/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 14 - 0
Qwe/main/urls.py

@@ -0,0 +1,14 @@
+from django.conf import settings
+from django.conf.urls.static import static
+from django.urls import path
+from .views import *
+
+urlpatterns = [
+                  path('', HomeView.as_view(), name='home'),
+                  path('CreatProduct/', CreatProduct.as_view(), name='CreatProduct'),
+                  path('Login/', Login.as_view(), name='Login'),
+                  path('Logout/', Logout.as_view(), name='Logout'),
+                  path('Profile/', Profile.as_view(), name='Profile'),
+                  # path('register/', views.sign_up, name='register'),
+
+              ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

+ 34 - 0
Qwe/main/views.py

@@ -0,0 +1,34 @@
+from django.contrib.auth.views import LoginView, LogoutView
+from django.shortcuts import render
+from django.urls import reverse_lazy
+from django.views.generic import TemplateView, ListView, CreateView, UpdateView, DeleteView
+from .models import *
+from .forms import *
+
+
+class HomeView(ListView):
+    model = Product
+    template_name = 'index.html'
+    context_object_name = 'products'
+
+    def get_queryset(self):
+        return Product
+
+
+class CreatProduct(CreateView):
+    model = Product
+    form_class = ProductForm
+    template_name = 'createProduct.html'
+    success_url = reverse_lazy('home')
+
+
+class Login(LoginView):
+    template_name = 'login.html'
+
+
+class Logout(LogoutView):
+    template_name = 'logout.html'
+
+
+class Profile(TemplateView):
+        template_name = 'Profile.html'

+ 22 - 0
Qwe/manage.py

@@ -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", "Qwe.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()

BIN
Qwe/media/product/the-cat-on-the-grass-shows-his-tongue.jpg


BIN
Qwe/media/product/the-cat-on-the-grass-shows-his-tongue_Ilv7aiF.jpg


BIN
Qwe/media/product/the-cat-on-the-grass-shows-his-tongue_WIJ72bl.jpg