Skip to content

Commit

Permalink
fix some wrong urls in sitemap.xml, chg null=True to False for CharFi…
Browse files Browse the repository at this point in the history
…elds
  • Loading branch information
l-dfa committed Sep 15, 2018
1 parent 4b91749 commit 9f15c81
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
18 changes: 12 additions & 6 deletions rstsite/rstblog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class Article(models.Model):
image = models.CharField(
'image',
max_length=MEDIUM_LEN,
null=True,
blank=False,
null=False,
blank=True,
unique=False,
default=None, )
default='', )
language = models.CharField(
'language',
max_length = 2,
Expand All @@ -163,8 +163,8 @@ class Article(models.Model):
summary = models.CharField(
'summary',
max_length=LONG_LEN,
null=True,
blank=False,
null=False,
blank=True,
default='', )
slug = models.SlugField(
'slug',
Expand Down Expand Up @@ -204,6 +204,7 @@ class Article(models.Model):
Author,
related_name='wrote',
verbose_name='authors',
blank=True,
default=None, )
category = models.ForeignKey( # link to category
Category,
Expand All @@ -226,7 +227,12 @@ def __str__(self):
return self.title

def get_absolute_url(self):
return reverse('rstblog:show', args=[self.slug])
if self.atype == 'article':
return reverse('rstblog:show', args=[self.slug])
elif self.atype == 'page':
return reverse('show', args=[self.slug])
else:
raise ValueError(f'type {self.atype} not handled')

def get_translations(self):
#pdb.set_trace()
Expand Down
20 changes: 10 additions & 10 deletions rstsite/rstsite/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ def location(self, obj):
else:
return reverse(obj)

class PagesSitemap(sitemaps.Sitemap):
protocol = 'https'
priority = 0.5
# no more needed, see urls.py #46,47 comment
# class PagesSitemap(sitemaps.Sitemap):
# protocol = 'https'
# priority = 0.5

def __init__(self, names):
self.names = names
# def __init__(self, names):
# self.names = names

def items(self):
return self.names
# def items(self):
# return self.names

def location(self, obj):
return reverse('show', args=[obj])
# def location(self, obj):
# return reverse('show', args=[obj])


class MediaSitemap(sitemaps.Sitemap):
Expand Down
9 changes: 5 additions & 4 deletions rstsite/rstsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from . import views
from .sitemap import IndexSitemap
from .sitemap import PagesSitemap
#from .sitemap import PagesSitemap
from .sitemap import MediaSitemap
from .sitemap import PlainSitemap
from rstblog.models import Article
Expand All @@ -42,7 +42,8 @@


articles_dict = {
#'queryset': Article.objects.filter(translation_of__isnull=True),
# the next line is valid for articles AND pages
# so PageSitemap is no more needed
'queryset': Article.objects.filter(published=True).order_by('-created'),
'date_field': 'modified',
}
Expand All @@ -54,8 +55,8 @@
['rstblog:index_all_categories', 'article',],
*search_by_category,
]),
'pages': PagesSitemap(['author.rst',
'formazione.rst',]),
#'pages': PagesSitemap(['author.rst',
# 'formazione.rst',]),
'media': MediaSitemap(['pdfs/CV_luciano_de_falco_alfano-public-20180227.pdf',]),
'plain': PlainSitemap(['robots.txt',
'sitemap.xml',]),
Expand Down

0 comments on commit 9f15c81

Please sign in to comment.