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

Lesson 7 opt #14

Open
wants to merge 61 commits into
base: lesson_1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ec18a78
init adminapp
t-rexamarin Dec 2, 2021
05014c0
1) base logout url
t-rexamarin Dec 2, 2021
9a0cf0a
users read controller
t-rexamarin Dec 2, 2021
2470c07
users create controller
t-rexamarin Dec 2, 2021
2cd0bf5
users update controller
t-rexamarin Dec 4, 2021
711335d
users delete controller
t-rexamarin Dec 4, 2021
6054627
import fix
t-rexamarin Dec 4, 2021
82c962b
admin custom table
t-rexamarin Dec 4, 2021
9bf31c8
admin categories read and create
t-rexamarin Dec 5, 2021
21b5dda
admin categories update and delete
t-rexamarin Dec 5, 2021
ae457a1
1) admin products read
t-rexamarin Dec 5, 2021
905847a
admin products create
t-rexamarin Dec 5, 2021
982e8ee
admin products update and delete
t-rexamarin Dec 5, 2021
6490119
few QOLs (quality of life) features:
t-rexamarin Dec 6, 2021
7863224
products pagination
t-rexamarin Dec 8, 2021
c39e3c3
- admin users CBV full
t-rexamarin Dec 10, 2021
18901be
- admin product category CBV full
t-rexamarin Dec 10, 2021
027c266
class for index page
t-rexamarin Dec 11, 2021
e687b36
add mixin
t-rexamarin Dec 11, 2021
e7671ee
- move navbar to includes to make it easier to rerender while product…
t-rexamarin Dec 11, 2021
6c7d597
authapp CBV
t-rexamarin Dec 12, 2021
90278f5
add requirements.txt
t-rexamarin Dec 12, 2021
d4fa794
mixin name fix
t-rexamarin Dec 12, 2021
6275909
registration form message refactor
t-rexamarin Dec 12, 2021
dba1f8b
mixins small fixes
t-rexamarin Dec 12, 2021
e41cc2a
email verification
t-rexamarin Dec 12, 2021
6b6d0c2
url change
t-rexamarin Dec 14, 2021
57503c7
git ignore change
t-rexamarin Dec 14, 2021
952347e
email resend
t-rexamarin Dec 16, 2021
f96e21d
vk registration
t-rexamarin Dec 16, 2021
6f516e6
update_db command to take data from User
t-rexamarin Dec 17, 2021
571d841
user profile extend
t-rexamarin Dec 17, 2021
496618f
registration backend fix
t-rexamarin Dec 17, 2021
d5e5280
1) vk authentication
t-rexamarin Dec 18, 2021
b4fcaae
1) ordersapp
t-rexamarin Dec 21, 2021
21e2a3d
1) orders
t-rexamarin Dec 24, 2021
dde955b
quantity migration
t-rexamarin Dec 25, 2021
358e3ba
js formset
t-rexamarin Dec 27, 2021
32356d3
js async price and value update
t-rexamarin Dec 27, 2021
8dc2342
1) set postgres as db
t-rexamarin Dec 28, 2021
ac4d725
fixture fix
t-rexamarin Dec 28, 2021
eefcc8b
model fix
t-rexamarin Dec 28, 2021
6217ca5
model fix
t-rexamarin Dec 28, 2021
d886f9c
model fix
t-rexamarin Dec 28, 2021
d0f30b1
settings hosts fix
t-rexamarin Dec 28, 2021
32c0b2a
requirements update (gunicorn)
t-rexamarin Dec 28, 2021
a8af4bf
js basket fix
t-rexamarin Dec 29, 2021
96b1eaf
fix create first user with vk, if there is no user_image dir
t-rexamarin Dec 29, 2021
db13059
setting ignore
t-rexamarin Dec 31, 2021
00bc0f0
remove settings.py
t-rexamarin Dec 31, 2021
5340b51
1) requirements update
t-rexamarin Dec 31, 2021
d143a1f
debug toolbar static
t-rexamarin Dec 31, 2021
9e03394
add select_related
t-rexamarin Jan 2, 2022
751adec
update requirements
t-rexamarin Jan 2, 2022
0ab1b3f
update requirements
t-rexamarin Jan 2, 2022
f1ee89d
remove couple dublicates in user/profile
t-rexamarin Jan 5, 2022
0a50e43
cache
t-rexamarin Jan 15, 2022
c547841
disable csrf
t-rexamarin Jan 15, 2022
015c383
Merge remote-tracking branch 'origin/lesson_7_opt' into lesson_7_opt
t-rexamarin Jan 15, 2022
175f9f4
disable csrf
t-rexamarin Jan 15, 2022
65fe7e9
add cache
t-rexamarin Jan 16, 2022
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
3 changes: 3 additions & 0 deletions geekshop/.env_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EMAIL_HOST_USER =
EMAIL_HOST_PASSWORD =
EMAIL_USE_TLS = 'True'
140 changes: 139 additions & 1 deletion geekshop/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,141 @@
/.idea
__pycache__/

# Django #
*.log
*.pot
*.pyc
__pycache__
db.sqlite3
__pycache__/
media
geekshop/settings.py

# Backup files #
*.bak

# If you are using PyCharm #
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# File-based project format
*.iws

# IntelliJ
out/

# JIRA plugin
atlassian-ide-plugin.xml

# Python #
*.py[cod]
*$py.class

# Distribution / packaging
.Python build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery
celerybeat-schedule.*

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/

# Sublime Text #
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files Package
Control.last-run
Control.ca-list
Control.ca-bundle
Control.system-ca-bundle
GitHub.sublime-settings

# Visual Studio Code #
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
Empty file added geekshop/adminapp/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions geekshop/adminapp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions geekshop/adminapp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AdminappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'adminapp'
63 changes: 63 additions & 0 deletions geekshop/adminapp/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from django import forms
from authapp.forms import UserRegistrationForm, UserChangeProfileForm
from authapp.models import User
from mainapp.models import ProductCategory, Product


class UserAdminRegisterForm(UserRegistrationForm):
class Meta:
model = User
fields = ('username', 'email', 'age', 'image', 'first_name', 'last_name', 'password1', 'password2')

def __init__(self, *args, **kwargs):
super(UserAdminRegisterForm, self).__init__(*args, **kwargs)

for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control py-4'

self.fields['image'].widget.attrs['class'] = 'custom-file-input'


class UserAdminProfileForm(UserChangeProfileForm):
email = forms.EmailField(widget=forms.EmailInput())
username = forms.CharField(widget=forms.TextInput())

def __init__(self, *args, **kwargs):
super(UserAdminProfileForm, self).__init__(*args, **kwargs)

self.fields['email'].widget.attrs['readonly'] = False
self.fields['username'].widget.attrs['readonly'] = False
for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control py-4'

self.fields['image'].widget.attrs['class'] = 'custom-file-input'


class ProductCategoryEditForm(forms.ModelForm):
class Meta:
model = ProductCategory
fields = ('name', 'description', 'is_active')

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control'
self.fields['description'].widget.attrs['rows'] = 1
# self.fields['description'].widget.attrs['columns'] = 15


class ProductEditForm(forms.ModelForm):
image = forms.ImageField(widget=forms.FileInput())

class Meta:
model = Product
fields = ('name', 'description', 'image', 'category', 'price', 'quantity', 'is_active')

def __init__(self, *args, **kwargs):
super(ProductEditForm, self).__init__(*args, **kwargs)

for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control py-4'

self.fields['image'].widget.attrs['class'] = 'custom-file-input'
Empty file.
3 changes: 3 additions & 0 deletions geekshop/adminapp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
44 changes: 44 additions & 0 deletions geekshop/adminapp/templates/adminapp/admin-categories-create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% extends 'adminapp/base.html' %}

{% block content %}
<div id="layoutSidenav_content">
<main>
<div class="container-fluid">
<h1 class="mt-4">Создание категории</h1>
<form action="{% url 'adminapp:admin_categories_create' %}" method="post">
{% csrf_token %}
<div class="form-row">
<div class="col-lg-5">
<div class="form-group">
<label class="small mb-1" for="{{ form.name.id_for_label }}">Название</label>
{{ form.name }}
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="small mb-1" for="{{ form.description.id_for_label }}">Описание</label>
{{ form.description }}
</div>
</div>
<div class="col-lg-0">
<label class="small mb-1" for="{{ form.is_active.id_for_label }}">Активна</label>
{{ form.is_active }}
</div>
</div>
<div class="form-row">
<div class="col-lg-12" style="margin-top: 33px;">
<input class="btn btn-info btn-block" type="submit" value="Сохранить">
</div>
</div>
</form>
</div>
</main>
<footer class="py-4 bg-light mt-auto">
<div class="container-fluid">
<div class="d-flex align-items-center justify-content-between small">
<div class="text-muted">Copyright &copy; GeekShop 2021</div>
</div>
</div>
</footer>
</div>
{% endblock %}
70 changes: 70 additions & 0 deletions geekshop/adminapp/templates/adminapp/admin-categories-read.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{% extends 'adminapp/base.html' %}

{% block content %}
<div id="layoutSidenav_content">
<main>
<div class="container-fluid">
<h1 class="mt-4">Категории</h1>
<div class="card mb-4">
<div class="card-header">
<i class="fas fa-table mr-1"></i>
Категории
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Категория</th>
<th>Описание</th>
<th>Дата создания</th>
<th>Дата изменения</th>
<th>Активна</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Категория</th>
<th>Описание</th>
<th>Дата создания</th>
<th>Дата изменения</th>
<th>Активна</th>
</tr>
</tfoot>
<tbody>
{% for category in object_list %}
<tr class="{% if not category.is_active %} inactive-obj {% endif %}">
<td><a href="{% url 'adminapp:admin_categories_update' category.id %}" style="color: dodgerblue">{{ category.name }}</a></td>
<td>{{ category.description }}</td>
<td>{{ category.created_at }}</td>
<td>{{ category.updated_at }}</td>
<td class="text-center">
{% if category.is_active %}
<i class="fas fa-check-circle"></i>
{% else %}
<i class="fas fa-times-circle"></i>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<a href="{% url 'adminapp:admin_categories_create' %}">
<button class="btn btn-success">Создать категорию</button>
</a>
</div>
</div>
</div>
</main>
<footer class="py-4 bg-light mt-auto">
<div class="container-fluid">
<div class="d-flex align-items-center justify-content-between small">
<div class="text-muted">Copyright &copy; GeekShop 2021</div>
</div>
</div>
</footer>
</div>
{% endblock %}
Loading