• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

liqd / adhocracy-plus / 18908688697

29 Oct 2025 12:59PM UTC coverage: 44.622% (-44.5%) from 89.135%
18908688697

Pull #2986

github

web-flow
Merge 1dfde8ee7 into 445e1d498
Pull Request #2986: Draft: Speed up Github Ci Tests

3012 of 6750 relevant lines covered (44.62%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/organisations/sitemaps.py
1
from django.contrib.sitemaps.views import x_robots_tag
×
2
from django.contrib.sites.shortcuts import get_current_site
×
3
from django.http import Http404
×
4
from django.template.response import TemplateResponse
×
5
from django.urls import reverse
×
6

7
from adhocracy4.projects.enums import Access
×
8
from adhocracy4.projects.models import Project
×
9

10
from .models import Organisation
×
11

12

13
@x_robots_tag
×
14
def organisations_sitemap_index(request):
×
15

16
    content_type = "application/xml"
×
17
    template_name = "sitemap_index.xml"
×
18

19
    urls = []
×
20
    organisations = Organisation.objects.all().order_by("id")
×
21

22
    for organisation in organisations:
×
23
        if not organisation.site or organisation.site is get_current_site(request):
×
24
            urls.append(
×
25
                request.build_absolute_uri(
26
                    reverse(
27
                        "organisation-sitemap-index",
28
                        kwargs=dict(organisation_slug=organisation.slug),
29
                    )
30
                )
31
            )
32

33
    return TemplateResponse(
×
34
        request, template_name, {"sitemaps": urls}, content_type=content_type
35
    )
36

37

38
@x_robots_tag
×
39
def organisation_sitemap_index(request, organisation_slug):
×
40

41
    content_type = "application/xml"
×
42
    template_name = "sitemap_index.xml"
×
43

44
    urls = []
×
45
    sitemaps = ["organisation-sitemap-static", "organisation-sitemap-projects"]
×
46

47
    for sitemap in sitemaps:
×
48
        urls.append(
×
49
            request.build_absolute_uri(
50
                reverse(sitemap, kwargs=dict(organisation_slug=organisation_slug))
51
            )
52
        )
53

54
    return TemplateResponse(
×
55
        request, template_name, {"sitemaps": urls}, content_type=content_type
56
    )
57

58

59
@x_robots_tag
×
60
def organisation_sitemap_static(request, organisation_slug):
×
61

62
    changefreq = "weekly"
×
63
    priority = 0.8
×
64
    content_type = "application/xml"
×
65
    template_name = "sitemap.xml"
×
66

67
    urls = []
×
68
    sites = ["organisation", "organisation-information", "organisation-imprint"]
×
69

70
    for site in sites:
×
71
        urls.append(
×
72
            {
73
                "location": request.build_absolute_uri(
74
                    reverse(site, kwargs=dict(organisation_slug=organisation_slug))
75
                ),
76
                "changefreq": changefreq,
77
                "priority": priority,
78
            }
79
        )
80

81
    return TemplateResponse(
×
82
        request, template_name, {"urlset": urls}, content_type=content_type
83
    )
84

85

86
@x_robots_tag
×
87
def organisation_sitemap_projects(request, organisation_slug):
×
88

89
    changefreq = "weekly"
×
90
    priority = 0.8
×
91
    content_type = "application/xml"
×
92
    template_name = "sitemap.xml"
×
93
    organisation = None
×
94

95
    try:
×
96
        organisation = Organisation.objects.get(slug=organisation_slug)
×
97
    except Organisation.DoesNotExist:
×
98
        raise Http404("Organisation does not exist")
×
99

100
    projects = Project.objects.filter(
×
101
        organisation=organisation,
102
        is_archived=False,
103
        is_draft=False,
104
        access=Access.PUBLIC,
105
    )
106

107
    urls = []
×
108
    for project in projects:
×
109
        url = {
×
110
            "location": request.build_absolute_uri(project.get_absolute_url()),
111
            "changefreq": changefreq,
112
            "priority": priority,
113
        }
114
        urls.append(url)
×
115

116
    return TemplateResponse(
×
117
        request, template_name, {"urlset": urls}, content_type=content_type
118
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc