[backport] Updating sitemaps

remotes/origin/3.4.0rc
Jesús Espino 2017-10-02 10:39:02 +02:00
parent e9b9a962c6
commit f507cd0539
9 changed files with 66 additions and 104 deletions

View File

@ -21,11 +21,8 @@ from collections import OrderedDict
from .generics import GenericSitemap
from .projects import ProjectsSitemap
from .projects import ProjectEpicsSitemap
from .projects import ProjectBacklogsSitemap
from .projects import ProjectKanbansSitemap
from .projects import ProjectIssuesSitemap
from .projects import ProjectTeamsSitemap
from .epics import EpicsSitemap
@ -46,11 +43,8 @@ sitemaps = OrderedDict([
("generics", GenericSitemap),
("projects", ProjectsSitemap),
("project-epics-list", ProjectEpicsSitemap),
("project-backlogs", ProjectBacklogsSitemap),
("project-kanbans", ProjectKanbansSitemap),
("project-issues-list", ProjectIssuesSitemap),
("project-teams", ProjectTeamsSitemap),
("epics", EpicsSitemap),

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -33,6 +35,9 @@ class EpicsSitemap(Sitemap):
Q(project__is_private=True,
project__anon_permissions__contains=["view_epics"]))
queryset = queryset.exclude(description="")
queryset = queryset.exclude(description__isnull=True)
# Exclude blocked projects
queryset = queryset.filter(project__blocked_code__isnull=True)
@ -48,7 +53,9 @@ class EpicsSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.4
return 0.5

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -48,7 +50,9 @@ class IssuesSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6
return 0.5

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -35,6 +37,8 @@ class MilestonesSitemap(Sitemap):
"view_us",
"view_tasks"]))
queryset = queryset.exclude(name="")
# Exclude blocked projects
queryset = queryset.filter(project__blocked_code__isnull=True)
@ -50,7 +54,9 @@ class MilestonesSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6
return 0.1

View File

@ -20,6 +20,8 @@ from django.db.models import Q
from django.apps import apps
from taiga.front.templatetags.functions import resolve
from datetime import timedelta
from django.utils import timezone
from .base import Sitemap
@ -35,6 +37,9 @@ class ProjectsSitemap(Sitemap):
# Exclude blocked projects
queryset = queryset.filter(blocked_code__isnull=True)
queryset = queryset.exclude(description="")
queryset = queryset.exclude(description__isnull=True)
queryset = queryset.exclude(total_activity__gt=5)
return queryset
@ -45,38 +50,12 @@ class ProjectsSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "hourly"
def priority(self, obj):
return 0.9
class ProjectEpicsSitemap(Sitemap):
def items(self):
project_model = apps.get_model("projects", "Project")
# Get public projects OR private projects if anon user can view them and epics
queryset = project_model.objects.filter(Q(is_private=False) |
Q(is_private=True,
anon_permissions__contains=["view_project",
"view_epics"]))
# Exclude projects without epics enabled
queryset = queryset.exclude(is_epics_activated=False)
return queryset
def location(self, obj):
return resolve("epics", obj.slug)
def lastmod(self, obj):
return obj.modified_date
def changefreq(self, obj):
if (timezone.now() - obj.modified_date) > timedelta(days=30):
return "montly"
return "daily"
def priority(self, obj):
return 0.6
return 0.8
class ProjectBacklogsSitemap(Sitemap):
@ -89,6 +68,10 @@ class ProjectBacklogsSitemap(Sitemap):
anon_permissions__contains=["view_project",
"view_us"]))
queryset = queryset.exclude(description="")
queryset = queryset.exclude(description__isnull=True)
queryset = queryset.exclude(total_activity__gt=5)
# Exclude projects without backlog enabled
queryset = queryset.exclude(is_backlog_activated=False)
@ -101,10 +84,12 @@ class ProjectBacklogsSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6
return 0.1
class ProjectKanbansSitemap(Sitemap):
@ -117,6 +102,10 @@ class ProjectKanbansSitemap(Sitemap):
anon_permissions__contains=["view_project",
"view_us"]))
queryset = queryset.exclude(description="")
queryset = queryset.exclude(description__isnull=True)
queryset = queryset.exclude(total_activity__gt=5)
# Exclude projects without kanban enabled
queryset = queryset.exclude(is_kanban_activated=False)
@ -129,59 +118,9 @@ class ProjectKanbansSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6
class ProjectIssuesSitemap(Sitemap):
def items(self):
project_model = apps.get_model("projects", "Project")
# Get public projects OR private projects if anon user can view them and issues
queryset = project_model.objects.filter(Q(is_private=False) |
Q(is_private=True,
anon_permissions__contains=["view_project",
"view_issues"]))
# Exclude projects without issues enabled
queryset = queryset.exclude(is_issues_activated=False)
return queryset
def location(self, obj):
return resolve("issues", obj.slug)
def lastmod(self, obj):
return obj.modified_date
def changefreq(self, obj):
return "daily"
def priority(self, obj):
return 0.6
class ProjectTeamsSitemap(Sitemap):
def items(self):
project_model = apps.get_model("projects", "Project")
# Get public projects OR private projects if anon user can view them
queryset = project_model.objects.filter(Q(is_private=False) |
Q(is_private=True,
anon_permissions__contains=["view_project"]))
return queryset
def location(self, obj):
return resolve("team", obj.slug)
def lastmod(self, obj):
return obj.modified_date
def changefreq(self, obj):
return "daily"
def priority(self, obj):
return 0.6
return 0.1

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -48,7 +50,9 @@ class TasksSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.4
return 0.5

View File

@ -41,7 +41,7 @@ class UsersSitemap(Sitemap):
return None
def changefreq(self, obj):
return "daily"
return "weekly"
def priority(self, obj):
return 0.6
return 0.5

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -48,7 +50,9 @@ class UserStoriesSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6
return 0.5

View File

@ -18,6 +18,8 @@
from django.db.models import Q
from django.apps import apps
from datetime import timedelta
from django.utils import timezone
from taiga.front.templatetags.functions import resolve
@ -51,7 +53,9 @@ class WikiPagesSitemap(Sitemap):
return obj.modified_date
def changefreq(self, obj):
return "daily"
if (timezone.now() - obj.modified_date) > timedelta(days=90):
return "montly"
return "weekly"
def priority(self, obj):
return 0.6