0.0.5 init, rm db
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -494,3 +494,4 @@ cython_debug/
|
|||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
|
|
||||||
|
!/db.sqlite3
|
||||||
|
|||||||
@@ -15,24 +15,24 @@ def test_code(request):
|
|||||||
|
|
||||||
def MainPage(request):
|
def MainPage(request):
|
||||||
|
|
||||||
print(f'LOCALE_PATHS = {str(settings.LOCALE_PATHS)}')
|
# print(f'LOCALE_PATHS = {str(settings.LOCALE_PATHS)}')
|
||||||
|
|
||||||
page = StaticPage.objects.get(url='main')
|
page = StaticPage.objects.get(url='main')
|
||||||
|
|
||||||
|
from ServicesApp.funcs import get_sections
|
||||||
|
sections = get_sections()
|
||||||
# from ArticlesApp.models import ArticleModel
|
# from ArticlesApp.models import ArticleModel
|
||||||
# arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4]
|
# arts = ArticleModel.objects.filter(enable=True).order_by('-createDT')[:4]
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
'page': page,
|
'page': page,
|
||||||
'FAQ': page.FAQ_items.filter(enable=True),
|
'sections': sections
|
||||||
# 'route_form': RouteForm(),
|
|
||||||
# 'articles': arts,
|
# 'articles': arts,
|
||||||
'owner_type': 'mover'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
breadcrumbs_Dict = {
|
# breadcrumbs_Dict = {
|
||||||
}
|
# }
|
||||||
Dict.update({'breadcrumbs': breadcrumbs_Dict})
|
# Dict.update({'breadcrumbs': breadcrumbs_Dict})
|
||||||
|
|
||||||
t = loader.get_template('pages/p_main.html')
|
t = loader.get_template('pages/p_main.html')
|
||||||
return get_inter_http_respose(t, Dict, request)
|
return get_inter_http_respose(t, Dict, request)
|
||||||
|
|||||||
@@ -1,3 +1,66 @@
|
|||||||
|
from sets.admin import *
|
||||||
|
from .models import *
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.forms import widgets
|
||||||
|
# from nested_inline.admin import NestedStackedInline, NestedTabularInline, NestedModelAdmin, NestedInline
|
||||||
|
from super_inlines.admin import SuperInlineModelAdmin, SuperModelAdmin
|
||||||
|
from GeneralApp.admin import Admin_StackedInline_Block
|
||||||
|
|
||||||
|
def sets_for_formfield_for_dbfield(field, db_field):
|
||||||
|
if db_field.name == 'url' or db_field.name == 'name' or db_field.name == 'title' or db_field.name == 'name_plural':
|
||||||
|
field.widget = widgets.TextInput(attrs={'style': 'width: 30%; height: 20px;'})
|
||||||
|
if db_field.name == 'description':
|
||||||
|
field.widget = widgets.Textarea(attrs={'style': 'width: 30%; height: 100px;'})
|
||||||
|
return field
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# class Admin_StaticPage(NestedModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||||
|
class Admin_Section(SuperModelAdmin, Admin_Trans_BaseModelViewPage):
|
||||||
|
|
||||||
|
|
||||||
|
fieldsets = [
|
||||||
|
(None, {
|
||||||
|
'classes': ['wide'],
|
||||||
|
'fields': ('name',
|
||||||
|
'url',
|
||||||
|
'title', 'description', 'text',
|
||||||
|
'picture',
|
||||||
|
'order',
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
('SEO', {
|
||||||
|
'classes': ['wide', 'collapse'],
|
||||||
|
'fields': (
|
||||||
|
'seo_title', 'seo_description', 'seo_keywords', 'seo_text',
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
list_display = [
|
||||||
|
'id',
|
||||||
|
'name', 'url', 'title',
|
||||||
|
'order', 'modifiedDT', 'createDT'
|
||||||
|
]
|
||||||
|
|
||||||
|
list_display_links = ['id']
|
||||||
|
list_editable = ['order']
|
||||||
|
|
||||||
|
list_filter = ['modifiedDT', 'createDT']
|
||||||
|
search_fields = ['name', 'title']
|
||||||
|
# filter_horizontal = ['options']
|
||||||
|
|
||||||
|
inlines = [Admin_StackedInline_Block]
|
||||||
|
|
||||||
|
def has_delete_permission(self, request, obj=None):
|
||||||
|
if request.user.is_superuser:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if obj.url in ('main', 'spec_technics', 'works'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
admin.site.register(Section,Admin_Section)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
|
|||||||
6
ServicesApp/funcs.py
Normal file
6
ServicesApp/funcs.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from .models import *
|
||||||
|
|
||||||
|
def get_sections():
|
||||||
|
|
||||||
|
sections = Section.objects.filter(enable=True)
|
||||||
|
return sections
|
||||||
11
ServicesApp/js_urls.py
Normal file
11
ServicesApp/js_urls.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.conf import settings
|
||||||
|
from .js_views import *
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('get_content_for_section', get_content_for_section_ajax, name='main'),
|
||||||
|
# path('page/<str:url>/', StaticPageView, name='static_page'),
|
||||||
|
# path('test_code', test_code, name='test_code'),
|
||||||
|
]
|
||||||
56
ServicesApp/js_views.py
Normal file
56
ServicesApp/js_views.py
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from uuid import uuid1
|
||||||
|
from .models import *
|
||||||
|
from django.contrib import auth
|
||||||
|
from django.http import HttpResponse, Http404, JsonResponse
|
||||||
|
from django.template import loader, RequestContext
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from BaseModels.mailSender import techSendMail
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
from datetime import datetime
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
from django.urls import reverse
|
||||||
|
from .funcs import *
|
||||||
|
|
||||||
|
def get_content_for_section_ajax(request):
|
||||||
|
if request.method != 'POST':
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
|
||||||
|
data = request.POST.dict()
|
||||||
|
if not data and request.body:
|
||||||
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
if not 'section_url' in data or not data['section_url']:
|
||||||
|
msg = _("Не найден section_url в data")
|
||||||
|
err_Dict = {
|
||||||
|
'error': msg
|
||||||
|
}
|
||||||
|
return JsonResponse(err_Dict, status=400)
|
||||||
|
|
||||||
|
section = Section.objects.get(url=data['section_url'])
|
||||||
|
|
||||||
|
|
||||||
|
html = render_to_string('blocks/b_search_routes.html', routes_Dict, request=request)
|
||||||
|
|
||||||
|
res_Dict = {
|
||||||
|
'html': html,
|
||||||
|
'last_block': routes_Dict['last_block']
|
||||||
|
# 'form': RouteForm(initial=data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonResponse(res_Dict)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
|
errors_Dict = {
|
||||||
|
'errors': {
|
||||||
|
'all__': f'ошибка в запросе = {str(e)}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JsonResponse(errors_Dict, status=400)
|
||||||
11
ServicesApp/urls.py
Normal file
11
ServicesApp/urls.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.conf import settings
|
||||||
|
from .views import *
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
# path('', MainPage, name='main'),
|
||||||
|
# path('page/<str:url>/', StaticPageView, name='static_page'),
|
||||||
|
# path('test_code', test_code, name='test_code'),
|
||||||
|
]
|
||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
@@ -5,10 +5,10 @@ from django.conf.urls.static import static
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('admin/', admin.site.urls),
|
|
||||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
# path('_nested_admin/', include('nested_admin.urls')),
|
|
||||||
|
path('', include('ServicesApp.js_urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
from django.conf.urls.i18n import i18n_patterns
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
@@ -17,6 +17,7 @@ urlpatterns += i18n_patterns(
|
|||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
path('', include('GeneralApp.urls')),
|
path('', include('GeneralApp.urls')),
|
||||||
|
path('', include('ServicesApp.urls')),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user