diff --git a/kitsune/postcrash/admin.py b/kitsune/postcrash/admin.py deleted file mode 100644 index 6a6b390b8f5..00000000000 --- a/kitsune/postcrash/admin.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.contrib import admin - -from kitsune.postcrash.models import Signature - - -class SignatureAdmin(admin.ModelAdmin): - list_display = ["__str__", "signature", "document"] - list_editable = ["signature", "document"] - raw_id_fields = ["document"] - - -admin.site.register(Signature, SignatureAdmin) diff --git a/kitsune/postcrash/migrations/0002_delete_signature.py b/kitsune/postcrash/migrations/0002_delete_signature.py new file mode 100644 index 00000000000..7f6bf23d75a --- /dev/null +++ b/kitsune/postcrash/migrations/0002_delete_signature.py @@ -0,0 +1,14 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("postcrash", "0001_initial"), + ] + + operations = [ + migrations.DeleteModel( + name="Signature", + ), + ] diff --git a/kitsune/postcrash/models.py b/kitsune/postcrash/models.py index 3857c2bed52..e69de29bb2d 100644 --- a/kitsune/postcrash/models.py +++ b/kitsune/postcrash/models.py @@ -1,17 +0,0 @@ -from django.db import models - -from kitsune.sumo.models import ModelBase -from kitsune.wiki.models import Document - - -class Signature(ModelBase): - signature = models.CharField(max_length=255, db_index=True, unique=True) - document = models.ForeignKey(Document, on_delete=models.CASCADE) - - def __str__(self): - return "<{}> {}".format(self.signature, self.document.title) - - def get_absolute_url(self): - doc = self.document.get_absolute_url().lstrip("/") - _, _, url = doc.partition("/") - return "/" + url diff --git a/kitsune/postcrash/tests/__init__.py b/kitsune/postcrash/tests/__init__.py deleted file mode 100644 index cca5556092e..00000000000 --- a/kitsune/postcrash/tests/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -import factory - -from kitsune.postcrash.models import Signature -from kitsune.sumo.tests import FuzzyUnicode -from kitsune.wiki.tests import DocumentFactory - - -class SignatureFactory(factory.django.DjangoModelFactory): - class Meta: - model = Signature - - document = factory.SubFactory(DocumentFactory) - signature = FuzzyUnicode() diff --git a/kitsune/postcrash/tests/test_models.py b/kitsune/postcrash/tests/test_models.py deleted file mode 100644 index 87a3f9fcfcb..00000000000 --- a/kitsune/postcrash/tests/test_models.py +++ /dev/null @@ -1,8 +0,0 @@ -from kitsune.postcrash.tests import SignatureFactory -from kitsune.sumo.tests import TestCase - - -class SignatureTests(TestCase): - def test_get_absolute_url(self): - sig = SignatureFactory(document__slug="foo-bar") - self.assertEqual("/kb/foo-bar", sig.get_absolute_url()) diff --git a/kitsune/postcrash/tests/test_views.py b/kitsune/postcrash/tests/test_views.py deleted file mode 100644 index e8616b451c8..00000000000 --- a/kitsune/postcrash/tests/test_views.py +++ /dev/null @@ -1,29 +0,0 @@ -from kitsune.postcrash.tests import SignatureFactory -from kitsune.sumo.templatetags.jinja_helpers import urlparams -from kitsune.sumo.tests import TestCase -from kitsune.sumo.urlresolvers import reverse - - -class ApiTests(TestCase): - def test_no_signature(self): - response = self.client.get(reverse("postcrash.api")) - self.assertEqual(400, response.status_code) - self.assertEqual(b"", response.content) - self.assertEqual("text/plain", response["content-type"]) - - def test_unknown_signature(self): - url = urlparams(reverse("postcrash.api"), s="foo") - response = self.client.get(url) - self.assertEqual(404, response.status_code) - self.assertEqual(b"", response.content) - self.assertEqual("text/plain", response["content-type"]) - - def test_known_signature(self): - sig = SignatureFactory() - url = urlparams(reverse("postcrash.api"), s=sig.signature) - response = self.client.get(url) - self.assertEqual(200, response.status_code) - self.assertEqual( - "https://example.com/kb/{}".format(sig.document.slug), response.content.decode() - ) - self.assertEqual("text/plain", response["content-type"]) diff --git a/kitsune/postcrash/urls.py b/kitsune/postcrash/urls.py deleted file mode 100644 index e88a3d61a2a..00000000000 --- a/kitsune/postcrash/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.urls import re_path - -from kitsune.postcrash import views - -urlpatterns = [ - re_path("^$", views.api, name="postcrash.api"), -] diff --git a/kitsune/postcrash/views.py b/kitsune/postcrash/views.py deleted file mode 100644 index 371406ae041..00000000000 --- a/kitsune/postcrash/views.py +++ /dev/null @@ -1,22 +0,0 @@ -from django.contrib.sites.models import Site -from django.http import HttpResponse, HttpResponseBadRequest -from django.views.decorators.cache import cache_page - -from kitsune.postcrash.models import Signature - - -@cache_page(60 * 60 * 24) # One day. -def api(request): - s = request.GET.get("s", None) - if not s: - return HttpResponseBadRequest(content_type="text/plain") - - # Don't use get_object_or_404 so we can return a 404 with no content. - try: - sig = Signature.objects.get(signature=s) - except Signature.DoesNotExist: - return HttpResponse("", status=404, content_type="text/plain") - - host = Site.objects.get_current() - path = sig.get_absolute_url() - return HttpResponse("https://{}{}".format(host, path), content_type="text/plain") diff --git a/kitsune/urls.py b/kitsune/urls.py index 8f646168e20..d39a2740a9b 100644 --- a/kitsune/urls.py +++ b/kitsune/urls.py @@ -53,7 +53,6 @@ urlpatterns += [ path("1/", include("kitsune.inproduct.urls")), - path("postcrash", include("kitsune.postcrash.urls")), path("wafflejs", wafflejs, name="wafflejs"), path("", include("kitsune.kpi.urls_api")), path("", include("kitsune.sumo.urls")),