diff --git a/.gitignore b/.gitignore index b7df758..2dcd820 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ .vscode/ __pycache__ db.sqlite3 -media/ \ No newline at end of file +media/ +venv/ +/geekshop/.env diff --git a/README.md b/README.md index c2399ac..a509d4d 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# Django_Advanced \ No newline at end of file +# django_geekshop + +Shop for django course diff --git a/adminapp/__init__.py b/adminapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/adminapp/admin.py b/adminapp/admin.py new file mode 100644 index 0000000..846f6b4 --- /dev/null +++ b/adminapp/admin.py @@ -0,0 +1 @@ +# Register your models here. diff --git a/adminapp/apps.py b/adminapp/apps.py new file mode 100644 index 0000000..9d2445c --- /dev/null +++ b/adminapp/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AdminappConfig(AppConfig): + name = 'adminapp' diff --git a/adminapp/forms.py b/adminapp/forms.py new file mode 100644 index 0000000..42a436c --- /dev/null +++ b/adminapp/forms.py @@ -0,0 +1,39 @@ +from django import forms + +from authapp.forms import ShopUserRegisterForm, ShopUserProfileForm +from authapp.models import User +from mainapp.models import Product + + +class NewAdminRegisterForm(ShopUserRegisterForm): + avatar = forms.ImageField(widget=forms.FileInput(), required=False) + + class Meta: + model = User + fields = '__all__' + + def __init__(self, *args, **kwargs): + super(NewAdminRegisterForm, self).__init__(*args, **kwargs) + self.fields['avatar'].widget.attrs['class'] = 'custom-file-input' + + +class NewAdminProfileForm(ShopUserProfileForm): + avatar = forms.ImageField(widget=forms.FileInput(), required=False) + + def __init__(self, *args, **kwargs): + super(NewAdminProfileForm, self).__init__(*args, **kwargs) + self.fields['username'].widget.attrs['readonly'] = False + self.fields['email'].widget.attrs['readonly'] = False + + +class ProductCreateForm(forms.ModelForm): + image = forms.ImageField(widget=forms.FileInput(), required=False) + + class Meta: + model = Product + fields = '__all__' + + def __init__(self, *args, **kwargs): + super(ProductCreateForm, self).__init__(*args, **kwargs) + for field_name, field in self.fields.items(): + field.widget.attrs['class'] = 'form-control' diff --git a/adminapp/migrations/__init__.py b/adminapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/adminapp/models.py b/adminapp/models.py new file mode 100644 index 0000000..6b20219 --- /dev/null +++ b/adminapp/models.py @@ -0,0 +1 @@ +# Create your models here. diff --git a/adminapp/templates/adminapp/admin-product-create.html b/adminapp/templates/adminapp/admin-product-create.html new file mode 100644 index 0000000..50a1da0 --- /dev/null +++ b/adminapp/templates/adminapp/admin-product-create.html @@ -0,0 +1,56 @@ +{% extends "adminapp/base.html" %} +{% load staticfiles %} +{% block content %} +
| Название товара | +Категория | +Краткое описание | +Кол-во | +Цена за шт | +
|---|---|---|---|---|
| Название товара | +Категория | +Краткое описание | +Кол-во | +Цена за шт | +
| {{ product.name }} | +{{ product.category.name }} | +{{ product.short_description }} | +{{ product.quantity }} | +{{ product.price }} | +
| Имя пользователя | +Имя | +Фамилия | +Адрес эл. почты | +Персонал сайта | +Активный | +
|---|---|---|---|---|---|
| Имя пользователя | +Имя | +Фамилия | +Адрес эл. почты | +Персонал сайта | +Активный | +
| {{ user.username }} | +{{ user.first_name }} | +{{ user.last_name }} | +{{ user.email }} | ++ {% if user.is_staff or user.is_superuser %} + + {% else %} + + {% endif %} + | ++ {% if user.is_active %} + + {% else %} + + {% endif %} + | +
{{ user_product.product.short_description }}
++ Новые образы и лучшие бренды на GeekShop Store. + Бесплатная доставка по всему миру! Аутлет: до -70% Собственный бренд. -20% новым покупателям. +
++ {% now "jS F Y H:i" %} +
+ +| ID | +Создан | +Обновлен | +Статус | +|||
|---|---|---|---|---|---|---|
| {{ item.pk }} | +{{ item.created|date:"Y-m-d H:i:s" }} | +{{ item.updated|date:"Y-m-d H:i:s" }} | +{{ item.get_status_display }} | ++ + посмотреть + + | ++ {% if item.status == 'FM' %} + + редактировать + + {% endif %} + | ++ {% if item.status == 'FM' %} + + удалить + + {% endif %} + | +
`s get reset. However, we also reset the\n// bottom margin to use `rem` units instead of `em`.\np {\n margin-top: 0;\n margin-bottom: $paragraph-margin-bottom;\n}\n\n// Abbreviations\n//\n// 1. Duplicate behavior to the data-* attribute for our tooltip plugin\n// 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n// 3. Add explicit cursor to indicate changed behavior.\n// 4. Remove the bottom border in Firefox 39-.\n// 5. Prevent the text-decoration to be skipped.\n\nabbr[title],\nabbr[data-original-title] { // 1\n text-decoration: underline; // 2\n text-decoration: underline dotted; // 2\n cursor: help; // 3\n border-bottom: 0; // 4\n text-decoration-skip-ink: none; // 5\n}\n\naddress {\n margin-bottom: 1rem;\n font-style: normal;\n line-height: inherit;\n}\n\nol,\nul,\ndl {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nol ol,\nul ul,\nol ul,\nul ol {\n margin-bottom: 0;\n}\n\ndt {\n font-weight: $dt-font-weight;\n}\n\ndd {\n margin-bottom: .5rem;\n margin-left: 0; // Undo browser default\n}\n\nblockquote {\n margin: 0 0 1rem;\n}\n\nb,\nstrong {\n font-weight: $font-weight-bolder; // Add the correct font weight in Chrome, Edge, and Safari\n}\n\nsmall {\n @include font-size(80%); // Add the correct font size in all browsers\n}\n\n//\n// Prevent `sub` and `sup` elements from affecting the line height in\n// all browsers.\n//\n\nsub,\nsup {\n position: relative;\n @include font-size(75%);\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub { bottom: -.25em; }\nsup { top: -.5em; }\n\n\n//\n// Links\n//\n\na {\n color: $link-color;\n text-decoration: $link-decoration;\n background-color: transparent; // Remove the gray background on active links in IE 10.\n\n @include hover() {\n color: $link-hover-color;\n text-decoration: $link-hover-decoration;\n }\n}\n\n// And undo these styles for placeholder links/named anchors (without href).\n// It would be more straightforward to just use a[href] in previous block, but that\n// causes specificity issues in many other styles that are too complex to fix.\n// See https://github.com/twbs/bootstrap/issues/19402\n\na:not([href]):not([class]) {\n color: inherit;\n text-decoration: none;\n\n @include hover() {\n color: inherit;\n text-decoration: none;\n }\n}\n\n\n//\n// Code\n//\n\npre,\ncode,\nkbd,\nsamp {\n font-family: $font-family-monospace;\n @include font-size(1em); // Correct the odd `em` font sizing in all browsers.\n}\n\npre {\n // Remove browser default top margin\n margin-top: 0;\n // Reset browser default of `1em` to use `rem`s\n margin-bottom: 1rem;\n // Don't allow content to break outside\n overflow: auto;\n // Disable auto-hiding scrollbar in IE & legacy Edge to avoid overlap,\n // making it impossible to interact with the content\n -ms-overflow-style: scrollbar;\n}\n\n\n//\n// Figures\n//\n\nfigure {\n // Apply a consistent margin strategy (matches our type styles).\n margin: 0 0 1rem;\n}\n\n\n//\n// Images and content\n//\n\nimg {\n vertical-align: middle;\n border-style: none; // Remove the border on images inside links in IE 10-.\n}\n\nsvg {\n // Workaround for the SVG overflow bug in IE10/11 is still required.\n // See https://github.com/twbs/bootstrap/issues/26878\n overflow: hidden;\n vertical-align: middle;\n}\n\n\n//\n// Tables\n//\n\ntable {\n border-collapse: collapse; // Prevent double borders\n}\n\ncaption {\n padding-top: $table-cell-padding;\n padding-bottom: $table-cell-padding;\n color: $table-caption-color;\n text-align: left;\n caption-side: bottom;\n}\n\n// 1. Removes font-weight bold by inheriting\n// 2. Matches default `