Skip to content

Commit bf5c22a

Browse files
authored
django 3.1 service
# multifunctional landing page on django 3.1 with CRM service + TeleBot (ORM)
1 parent 2f4f0ae commit bf5c22a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1055
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# DjangoServiceCRM
2-
Landing page + CRM service on Django 3.2 + TeleBot + Nginx
1+
# Учебный проект курса 'Python + Django'
2+
### Проект полностью готов к выгрузке, необходимо провести миграции и создать суперюзера

cms/__init__.py

Whitespace-only changes.

cms/admin.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from django.contrib import admin
2+
from django.utils.safestring import mark_safe
3+
4+
from .models import CmsSlider
5+
6+
# Register your models here.
7+
class CmsAdmin(admin.ModelAdmin):
8+
list_display = ('cms_title', 'cms_text', 'cms_css', 'get_img')
9+
list_display_links = ('cms_title',)
10+
list_editable = ('cms_css',)
11+
fields = ('cms_title', 'cms_text', 'cms_css', 'cms_img', 'get_img')
12+
readonly_fields = ('get_img',)
13+
14+
def get_img(self, obj):
15+
if obj.cms_img:
16+
return mark_safe(f'<img src="{obj.cms_img.url}" width="80px"')
17+
else:
18+
return 'нет картинки'
19+
20+
get_img.short_description = 'Миниатюра'
21+
22+
# phone.png
23+
admin.site.register(CmsSlider, CmsAdmin)

cms/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CmsConfig(AppConfig):
5+
name = 'cms'

cms/migrations/0001_initial.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Generated by Django 3.1.3 on 2020-11-17 15:59
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='CmsSlider',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('cms_img', models.ImageField(upload_to='sliderimg/')),
19+
('cms_title', models.CharField(max_length=200, verbose_name='Заголовок')),
20+
('cms_text', models.CharField(max_length=200, verbose_name='Текст')),
21+
],
22+
options={
23+
'verbose_name': 'Слайд',
24+
'verbose_name_plural': 'Слайды',
25+
},
26+
),
27+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.1.3 on 2020-11-17 16:10
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('cms', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='cmsslider',
15+
name='cms_css',
16+
field=models.CharField(default='-', max_length=200, null=True, verbose_name='CSS класс'),
17+
),
18+
]

cms/migrations/__init__.py

Whitespace-only changes.

cms/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
class CmsSlider(models.Model):
5+
cms_img = models.ImageField(upload_to='sliderimg/')
6+
cms_title = models.CharField(max_length=200, verbose_name='Заголовок')
7+
cms_text = models.CharField(max_length=200, verbose_name='Текст')
8+
cms_css = models.CharField(max_length=200, null=True, default='-', verbose_name='CSS класс')
9+
10+
11+
def __str__(self):
12+
return self.cms_title
13+
14+
class Meta:
15+
verbose_name = 'Слайд'
16+
verbose_name_plural = 'Слайды'

cms/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

cms/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

config/__init__.py

Whitespace-only changes.

config/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for landingpagewebsite project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
15+
16+
application = get_asgi_application()

config/settings.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
"""
2+
Django settings for config project.
3+
4+
Generated by 'django-admin startproject' using Django 3.1.3.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.1/ref/settings/
11+
"""
12+
import os
13+
from pathlib import Path
14+
15+
S_KEY = os.environ.get('djangokey')
16+
SEC_KEY = f"'{S_KEY}'"
17+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18+
# Для дебаг версии
19+
# BASE_DIR = Path(__file__).resolve().parent.parent
20+
# Для сервер версии
21+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22+
23+
24+
# Quick-start development settings - unsuitable for production
25+
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
26+
27+
# SECURITY WARNING: keep the secret key used in production secret!
28+
SECRET_KEY = SEC_KEY
29+
30+
# SECURITY WARNING: don't run with debug turned on in production!
31+
DEBUG = True
32+
33+
ALLOWED_HOSTS = ['127.0.0.1',]
34+
35+
36+
# Application definition
37+
38+
INSTALLED_APPS = [
39+
'telebot.apps.TelebotConfig',
40+
'price.apps.PriceConfig',
41+
'cms.apps.CmsConfig',
42+
'crm.apps.CrmConfig',
43+
'django.contrib.admin',
44+
'django.contrib.auth',
45+
'django.contrib.contenttypes',
46+
'django.contrib.sessions',
47+
'django.contrib.messages',
48+
'django.contrib.staticfiles',
49+
]
50+
51+
MIDDLEWARE = [
52+
'django.middleware.security.SecurityMiddleware',
53+
'django.contrib.sessions.middleware.SessionMiddleware',
54+
'django.middleware.common.CommonMiddleware',
55+
'django.middleware.csrf.CsrfViewMiddleware',
56+
'django.contrib.auth.middleware.AuthenticationMiddleware',
57+
'django.contrib.messages.middleware.MessageMiddleware',
58+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
59+
]
60+
61+
ROOT_URLCONF = 'config.urls'
62+
63+
TEMPLATES = [
64+
{
65+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
66+
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
67+
'APP_DIRS': True,
68+
'OPTIONS': {
69+
'context_processors': [
70+
'django.template.context_processors.debug',
71+
'django.template.context_processors.request',
72+
'django.contrib.auth.context_processors.auth',
73+
'django.contrib.messages.context_processors.messages',
74+
],
75+
},
76+
},
77+
]
78+
79+
WSGI_APPLICATION = 'config.wsgi.application'
80+
81+
82+
# Database
83+
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
84+
85+
DATABASES = {
86+
'default': {
87+
'ENGINE': 'django.db.backends.sqlite3',
88+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
89+
}
90+
}
91+
92+
93+
# Password validation
94+
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
95+
96+
AUTH_PASSWORD_VALIDATORS = [
97+
{
98+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
99+
},
100+
{
101+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
102+
},
103+
{
104+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
105+
},
106+
{
107+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
108+
},
109+
]
110+
111+
112+
# Internationalization
113+
# https://docs.djangoproject.com/en/3.1/topics/i18n/
114+
115+
LANGUAGE_CODE = 'ru-RU'
116+
117+
TIME_ZONE = 'Europe/Moscow'
118+
119+
USE_I18N = True
120+
121+
USE_L10N = True
122+
123+
USE_TZ = True
124+
125+
126+
# Static files (CSS, JavaScript, Images)
127+
# https://docs.djangoproject.com/en/3.1/howto/static-files/
128+
129+
STATICFILES_DIRS = [
130+
os.path.join(BASE_DIR, "config/static/"),
131+
]
132+
133+
STATIC_URL = '/static/'
134+
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
135+
136+
MEDIA_URL = '/media/'
137+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
138+
139+

config/static/external.css

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*Heder*/
2+
.logo-top {
3+
width: 100px;
4+
height: 40px;
5+
float: left;
6+
margin: 0px 0px 5px 80px;
7+
}
8+
9+
.phone-number {
10+
width: 200px;
11+
height: 40px;
12+
float: right;
13+
margin: 20px 10px 5px 20px;
14+
}
15+
16+
.whatsapp-number {
17+
width: 35px;
18+
height: 35px;
19+
float: right;
20+
margin: 15px 30px 5px 20px;
21+
background: url(./img/wa-image-color.png) no-repeat center top / cover;
22+
transition: 0.5s ease-in-out;
23+
}
24+
.telegram-number {
25+
width: 35px;
26+
height: 35px;
27+
float: right;
28+
margin: 15px 30px 5px 20px;
29+
background: url(./img/tg-image-color.png) no-repeat center top / cover;
30+
transition: 0.5s ease-in-out;
31+
}
32+
33+
.slaider_h {
34+
height: 60px;
35+
width: 50%;
36+
margin: 30px 0px 10px 0px;
37+
padding-top: 20px;
38+
background-color: rgba(10, 77, 125, 0.5);
39+
text-align: center;
40+
}
41+
42+
.slaider_p {
43+
height: 100%;
44+
width: 80%;
45+
float: right;
46+
margin: 0px 0px 30px 0px;
47+
padding-top: 20px;
48+
padding-bottom: 20px;
49+
background-color: rgba(10, 77, 125, 0.5);
50+
text-align: center;
51+
}
52+
53+
.text-3 {
54+
color: rgb(10, 77, 125);
55+
/*font-family: arial;*/
56+
font-size: 2em;
57+
text-align: center;
58+
padding-top: 7%;
59+
padding-bottom: 7%;
60+
}
61+
62+
.product_card {
63+
margin: 10px;
64+
}
65+
66+
.table_one {
67+
font-size: 1.4em;
68+
}
69+
70+
.class_form {
71+
/*color: #fff;*/
72+
/*font-size: 2em;*/
73+
text-align: center;
74+
padding-bottom: 7%;
75+
}

config/static/favicon.ico

1.12 KB
Binary file not shown.

config/static/img/1.jpg

652 KB
Loading

config/static/img/2.jpg

207 KB
Loading

config/static/img/3.jpg

300 KB
Loading

config/static/img/4.jpg

801 KB
Loading

config/static/img/5.jpg

680 KB
Loading

config/static/img/6.jpg

3.53 MB
Loading

config/static/img/Logo.png

70.8 KB
Loading

config/static/img/tg-image-color.png

17.5 KB
Loading

config/static/img/wa-image-color.png

17.7 KB
Loading

config/urls.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""landingpagewebsite URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
from crm import views
19+
from django.conf.urls.static import static
20+
from django.conf import settings
21+
22+
23+
urlpatterns = [
24+
path('admin/', admin.site.urls),
25+
path('', views.first_page),
26+
path('thanks/', views.thanks_page, name='thanks_page')
27+
]
28+
if settings.DEBUG:
29+
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

config/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for landingpagewebsite project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
15+
16+
application = get_wsgi_application()

crm/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)