From 8ba3e17c9310c0833f496ed32f85db4bf7f65821 Mon Sep 17 00:00:00 2001 From: jordan Date: Mon, 11 Apr 2011 14:19:12 +0000 Subject: [PATCH] Creating a new Setting Set for the Sitemap settings. Making the Questions Sitemap limit and changefreq properties configurable through administration. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@964 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/settings/__init__.py | 1 + forum/settings/sitemaps.py | 13 +++++++++++++ forum/sitemap.py | 5 +++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 forum/settings/sitemaps.py diff --git a/forum/settings/__init__.py b/forum/settings/__init__.py index e10fc76..d8d5aa0 100644 --- a/forum/settings/__init__.py +++ b/forum/settings/__init__.py @@ -41,6 +41,7 @@ from users import * from static import * from urls import * from accept import * +from sitemaps import * BADGES_SET = SettingSet('badges', _('Badges config'), _("Configure badges on your OSQA site."), 500) diff --git a/forum/settings/sitemaps.py b/forum/settings/sitemaps.py new file mode 100644 index 0000000..65d5d17 --- /dev/null +++ b/forum/settings/sitemaps.py @@ -0,0 +1,13 @@ +from base import Setting, SettingSet +from django.forms.widgets import Textarea, RadioSelect, Select +from django.utils.translation import ugettext_lazy as _ + +SITEMAP_SET = SettingSet('sitemap', _('Sitemap settings'), _("Some settings connected with the Sitemaps."), 2000) + +QUESTIONS_SITEMAP_LIMIT = Setting('QUESTIONS_SITEMAP_LIMIT', 2500, SITEMAP_SET, dict( +label = _("Questions Sitemap Limit"), +help_text = _("The questions limit per page for the Questions Sitemap."))) + +QUESTIONS_SITEMAP_CHANGEFREQ = Setting('QUESTIONS_SITEMAP_CHANGEFREQ', 'daily', SITEMAP_SET, dict( +label = _("Questions Sitemap Change Fraquence"), +help_text = _("Used in the Questions Sitemap tag and specifies the content change frequency."))) diff --git a/forum/sitemap.py b/forum/sitemap.py index 4478176..293d5e5 100644 --- a/forum/sitemap.py +++ b/forum/sitemap.py @@ -1,5 +1,6 @@ from django.contrib.sitemaps import Sitemap from forum.models import Question +from forum.settings import QUESTIONS_SITEMAP_LIMIT, QUESTIONS_SITEMAP_CHANGEFREQ from django.conf import settings from django.http import HttpResponse, Http404 from django.template import loader @@ -61,8 +62,8 @@ def sitemap(request, sitemaps, section=None, page=1): return HttpResponse(xml, mimetype='application/xml') class OsqaSitemap(Sitemap): - limit = 2500 - changefreq = 'daily' + limit = QUESTIONS_SITEMAP_LIMIT + changefreq = QUESTIONS_SITEMAP_CHANGEFREQ priority = 0.5 def items(self): return Question.objects.filter_state(deleted=False).order_by('id') -- 2.39.5