Implement basic robots.txt #264
@ -18,7 +18,7 @@ from django.contrib import admin
|
|||||||
from django.contrib.flatpages import views as flatpages_views
|
from django.contrib.flatpages import views as flatpages_views
|
||||||
from django.urls import path, include, re_path
|
from django.urls import path, include, re_path
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
from django.views.generic.base import RedirectView
|
from django.views.generic.base import RedirectView, TemplateView
|
||||||
|
|
||||||
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ urlpatterns = [
|
|||||||
path('api/swagger/', RedirectView.as_view(url='/api/v1/swagger/')),
|
path('api/swagger/', RedirectView.as_view(url='/api/v1/swagger/')),
|
||||||
path('api/v1/', SpectacularAPIView.as_view(), name='schema_v1'),
|
path('api/v1/', SpectacularAPIView.as_view(), name='schema_v1'),
|
||||||
path('api/v1/swagger/', SpectacularSwaggerView.as_view(url_name='schema_v1'), name='swagger'),
|
path('api/v1/swagger/', SpectacularSwaggerView.as_view(url_name='schema_v1'), name='swagger'),
|
||||||
|
path('robots.txt', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
|
||||||
# Flatpages
|
# Flatpages
|
||||||
path('about/', flatpages_views.flatpage, {'url': '/about/'}, name='flatpage-about'),
|
path('about/', flatpages_views.flatpage, {'url': '/about/'}, name='flatpage-about'),
|
||||||
re_path(r'^(?P<url>.*/)$', flatpages_views.flatpage),
|
re_path(r'^(?P<url>.*/)$', flatpages_views.flatpage),
|
||||||
|
5
extensions/templates/robots.txt
Normal file
5
extensions/templates/robots.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
User-Agent: *
|
||||||
|
Disallow: /approval-queue/
|
||||||
|
|
||||||
|
User-agent: GPTBot
|
||||||
|
Disallow: /
|
@ -309,3 +309,11 @@ class MyExtensionsTest(_BaseTestCase):
|
|||||||
self.client.force_login(user)
|
self.client.force_login(user)
|
||||||
response = self.client.get(reverse('extensions:manage-list'))
|
response = self.client.get(reverse('extensions:manage-list'))
|
||||||
self.assertContains(response, extension.name)
|
self.assertContains(response, extension.name)
|
||||||
|
|
||||||
|
|
||||||
|
class RobotsTxtTests(_BaseTestCase):
|
||||||
|
def test_get(self):
|
||||||
|
response = self.client.get("/robots.txt")
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual(response["content-type"], "text/plain")
|
||||||
|
Loading…
Reference in New Issue
Block a user