1.4.0 sitemap
This commit is contained in:
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