1.4.0 sitemap
This commit is contained in:
0
SitemapApp/__init__.py
Normal file
0
SitemapApp/__init__.py
Normal file
3
SitemapApp/models.py
Normal file
3
SitemapApp/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
16
SitemapApp/tests.py
Normal file
16
SitemapApp/tests.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
||||
11
SitemapApp/urls.py
Normal file
11
SitemapApp/urls.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.urls import include, path
|
||||
from django.contrib.sitemaps import views as sitemaps_views
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from django.contrib.sitemaps.views import sitemap
|
||||
from SitemapApp.views import sitemaps
|
||||
|
||||
urlpatterns = [
|
||||
path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
|
||||
name='django.contrib.sitemaps.views.sitemap')
|
||||
]
|
||||
149
SitemapApp/views.py
Normal file
149
SitemapApp/views.py
Normal file
@@ -0,0 +1,149 @@
|
||||
# coding=utf-8
|
||||
from django.contrib.sitemaps import Sitemap
|
||||
from django.urls import reverse
|
||||
|
||||
from BaseModels.mailSender import techSendMail
|
||||
import json
|
||||
from datetime import datetime, time, timezone
|
||||
# from PageSetsApp.models import *
|
||||
# from ArticlesApp.models import *
|
||||
# from BaseModels.base_api_requests import base_api_request
|
||||
# from tEsiteProj.settings import API_URL
|
||||
from django.db.models import Q
|
||||
|
||||
|
||||
limit_records = 1000
|
||||
|
||||
|
||||
|
||||
sitemaps = {
|
||||
|
||||
}
|
||||
|
||||
protocol = 'https'
|
||||
|
||||
class sm_StaticPage(Sitemap):
|
||||
changefreq = 'monthly'
|
||||
priority = 1
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
from GeneralApp.models import StaticPage
|
||||
return StaticPage.objects.filter(enable=True)
|
||||
|
||||
def location(self, item):
|
||||
if item.url == 'main':
|
||||
return reverse('main')
|
||||
else:
|
||||
return reverse('static_page', args=[item.url])
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.modifiedDT
|
||||
|
||||
sitemaps.update({'static_pages': sm_StaticPage})
|
||||
|
||||
|
||||
|
||||
class sm_ArticlesPage(Sitemap):
|
||||
changefreq = 'daily'
|
||||
priority = 2
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
return ['']
|
||||
|
||||
def location(self, item):
|
||||
return reverse('articles')
|
||||
|
||||
def lastmod(self, obj):
|
||||
from ArticlesApp.models import ArticleModel
|
||||
article = ArticleModel.objects.filter(enable=True).order_by('-modifiedDT').first()
|
||||
if article:
|
||||
return article.modifiedDT
|
||||
else:
|
||||
return datetime.now()
|
||||
|
||||
sitemaps.update({'articles_page': sm_ArticlesPage})
|
||||
|
||||
|
||||
|
||||
class sm_Article(Sitemap):
|
||||
changefreq = 'yearly'
|
||||
priority = 2
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
from ArticlesApp.views import ArticleModel
|
||||
objs = ArticleModel.objects.filter(enable=True)
|
||||
|
||||
return objs
|
||||
|
||||
def location(self, item):
|
||||
return reverse('article_one', args=[item.url])
|
||||
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.modifiedDT
|
||||
|
||||
sitemaps.update({'article': sm_Article})
|
||||
|
||||
|
||||
class sm_UserPage(Sitemap):
|
||||
changefreq = 'yearly'
|
||||
priority = 2
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
from ArticlesApp.views import UserPageModel
|
||||
objs = UserPageModel.objects.filter(enable=True)
|
||||
|
||||
return objs
|
||||
|
||||
def location(self, item):
|
||||
return reverse('user_page', args=[item.url])
|
||||
|
||||
|
||||
def lastmod(self, obj):
|
||||
return obj.modifiedDT
|
||||
|
||||
sitemaps.update({'user_page': sm_UserPage})
|
||||
|
||||
|
||||
class sm_Registration(Sitemap):
|
||||
changefreq = 'never'
|
||||
priority = 1
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
return ['']
|
||||
|
||||
def location(self, item):
|
||||
return reverse('registration_page')
|
||||
|
||||
def lastmod(self, obj):
|
||||
return datetime(2024, 6, 1)
|
||||
|
||||
sitemaps.update({'registration': sm_Registration})
|
||||
|
||||
|
||||
class sm_Login(Sitemap):
|
||||
changefreq = 'never'
|
||||
priority = 1
|
||||
i18n = True
|
||||
protocol = protocol
|
||||
|
||||
def items(self):
|
||||
return ['']
|
||||
|
||||
def location(self, item):
|
||||
return reverse('login_profile')
|
||||
|
||||
def lastmod(self, obj):
|
||||
return datetime(2024, 6, 1)
|
||||
|
||||
sitemaps.update({'login': sm_Login})
|
||||
Reference in New Issue
Block a user