issues.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2015 David Barragán <bameda@dbarragan.com>
  2. # Copyright (C) 2015 Taiga Agile LLC <support@taiga.io>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from django.db.models import Q
  17. from django.apps import apps
  18. from taiga.front.templatetags.functions import resolve
  19. from .base import Sitemap
  20. class IssuesSitemap(Sitemap):
  21. def items(self):
  22. issue_model = apps.get_model("issues", "Issue")
  23. # Get issues of public projects OR private projects if anon user can view them
  24. queryset = issue_model.objects.filter(Q(project__is_private=False) |
  25. Q(project__is_private=True,
  26. project__anon_permissions__contains=["view_issues"]))
  27. # Project data is needed
  28. queryset = queryset.select_related("project")
  29. return queryset
  30. def location(self, obj):
  31. return resolve("issue", obj.project.slug, obj.ref)
  32. def lastmod(self, obj):
  33. return obj.modified_date
  34. def changefreq(self, obj):
  35. return "daily"
  36. def priority(self, obj):
  37. return 0.6