0.0.9 section view

This commit is contained in:
SDE
2023-11-26 18:29:37 +03:00
parent 8afefc9aff
commit eef2ca509a
13 changed files with 99 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ class Admin_Inline_WidgetForBlock(SuperInlineModelAdmin, Admin_Trans_BaseIconSta
('title', 'description', 'picture'),
('bg_color', ),
('but_title', 'but_color'),
('url',),
('url', 'order'),
]
})
]
@@ -56,7 +56,7 @@ class Admin_StackedInline_Block(Admin_Trans_GenericBaseIconStackedInline, SuperI
('bg_color', ),
('but_title', 'but_color'),
('url',),
('child_in_row_count',),
('child_in_row_count', 'order'),
]
})
]

View File

@@ -3,6 +3,12 @@ from django.http import HttpResponse, Http404, FileResponse
def get_inter_Dict(user):
Dict = {}
from ServicesApp.funcs import get_sections
sections = get_sections()
Dict.update({
'sections': sections
})
# from SubscribesApp.funcs import get_cur_user_subscribe
# user_subscribe = get_cur_user_subscribe(user)

View File

@@ -19,14 +19,11 @@ def MainPage(request):
page = StaticPage.objects.get(url='main')
from ServicesApp.funcs import get_sections
sections = get_sections()
# from ArticlesApp.models import ArticleModel
# arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4]
Dict = {
'page': page,
'sections': sections
# 'articles': arts,
}

View File

@@ -5,7 +5,7 @@ from django.conf import settings
from .views import *
urlpatterns = [
# path('', MainPage, name='main'),
path('section/<str:url>/', section_view, name='section_page'),
# path('page/<str:url>/', StaticPageView, name='static_page'),
# path('test_code', test_code, name='test_code'),
]

View File

@@ -1,3 +1,34 @@
from django.shortcuts import render
import json
# Create your views here.
from django.http import HttpResponse, Http404, FileResponse
from django.template import loader, RequestContext
from django.contrib.auth.decorators import login_required
from .models import *
from django.conf import settings
from GeneralApp.funcs import get_inter_http_respose
def section_view(request, url):
try:
page = Section.objects.get(url=url)
# from ArticlesApp.models import ArticleModel
# arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4]
Dict = {
'page': page,
# 'articles': arts,
}
# breadcrumbs_Dict = {
# }
# Dict.update({'breadcrumbs': breadcrumbs_Dict})
t = loader.get_template('pages/p_section.html')
return get_inter_http_respose(t, Dict, request)
except Exception as e:
msg = f'section_view Error = {str(e)}'
print(msg)
return HttpResponse(msg, status=400)

0
SlidesApp/__init__.py Normal file
View File

3
SlidesApp/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
SlidesApp/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class SlidesappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'SlidesApp'

View File

32
SlidesApp/models.py Normal file
View File

@@ -0,0 +1,32 @@
from django.db import models
from BaseModels.base_models import BaseModelViewPage, BaseModel
from django.utils.translation import gettext_lazy as _
# from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField
# from colorfield.fields import ColorField
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.fields import GenericRelation
from colorfield.fields import ColorField
class Slide(BaseModel):
content_type = models.ForeignKey(ContentType, on_delete=models.SET_NULL, null=True)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
url = models.TextField(verbose_name=_('URL привязанной страницы'), blank=True, null=True)
title = models.TextField(verbose_name=_('Заголовок'), null=True, blank=True)
description = RichTextUploadingField(verbose_name=_('Краткое описание'), null=True, blank=True)
text = RichTextUploadingField(verbose_name=_('Полное описание'), null=True, blank=True, )
picture = models.ImageField(
upload_to='uploads/', verbose_name=_('Фоновое изображение'), null=True, blank=True)
bg_color = ColorField(verbose_name=_('Цвет фона'), default='#FFFFFF')
but_title = models.CharField(max_length=100, verbose_name=_('Текст на кнопке'), null=True, blank=True)
but_color = ColorField(verbose_name=_('Цвет кнопки'), default='#000000')
class Meta:
verbose_name = _('Слайд')
verbose_name_plural = _('Слайды')

3
SlidesApp/tests.py Normal file
View File

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

3
SlidesApp/views.py Normal file
View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

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