From 670e3784eeb5f3bb193b35e71e46923dbbcf0058 Mon Sep 17 00:00:00 2001 From: Tadhg O'Higgins <2626258+tadhg-ohiggins@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:24:47 -0700 Subject: [PATCH] Remove cms, move fac_tags.py to audit/templatetags. --- .../{cms => audit}/templatetags/fac_tags.py | 0 backend/cms/__init__.py | 0 backend/cms/admin.py | 11 ----- backend/cms/apps.py | 6 --- .../migrations/0001_Create_content_model.py | 46 ------------------- backend/cms/migrations/__init__.py | 0 backend/cms/models.py | 30 ------------ backend/cms/templatetags/__init__.py | 0 backend/cms/tests.py | 4 -- backend/cms/urls.py | 11 ----- backend/cms/views.py | 30 ------------ backend/config/settings.py | 1 - backend/config/urls.py | 2 - 13 files changed, 141 deletions(-) rename backend/{cms => audit}/templatetags/fac_tags.py (100%) delete mode 100644 backend/cms/__init__.py delete mode 100644 backend/cms/admin.py delete mode 100644 backend/cms/apps.py delete mode 100644 backend/cms/migrations/0001_Create_content_model.py delete mode 100644 backend/cms/migrations/__init__.py delete mode 100644 backend/cms/models.py delete mode 100644 backend/cms/templatetags/__init__.py delete mode 100644 backend/cms/tests.py delete mode 100644 backend/cms/urls.py delete mode 100644 backend/cms/views.py diff --git a/backend/cms/templatetags/fac_tags.py b/backend/audit/templatetags/fac_tags.py similarity index 100% rename from backend/cms/templatetags/fac_tags.py rename to backend/audit/templatetags/fac_tags.py diff --git a/backend/cms/__init__.py b/backend/cms/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/backend/cms/admin.py b/backend/cms/admin.py deleted file mode 100644 index 78a3e1fb16..0000000000 --- a/backend/cms/admin.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.contrib import admin -from .models import Posts - - -class PostAdmin(admin.ModelAdmin): - """Fields for admin view""" - - fields = ["title", "slug", "author", "meta_description", "content"] - - -admin.site.register(Posts, PostAdmin) diff --git a/backend/cms/apps.py b/backend/cms/apps.py deleted file mode 100644 index 80bf9e5cb6..0000000000 --- a/backend/cms/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class CmsConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" - name = "cms" diff --git a/backend/cms/migrations/0001_Create_content_model.py b/backend/cms/migrations/0001_Create_content_model.py deleted file mode 100644 index 596e8bfdca..0000000000 --- a/backend/cms/migrations/0001_Create_content_model.py +++ /dev/null @@ -1,46 +0,0 @@ -# Generated by Django 4.1.2 on 2022-11-02 14:19 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name="Posts", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("title", models.CharField(max_length=200, unique=True)), - ("slug", models.SlugField(max_length=200, unique=True)), - ("updated_on", models.DateTimeField(auto_now=True)), - ("created_on", models.DateTimeField(auto_now_add=True)), - ("meta_description", models.CharField(max_length=300, null=True)), - ("content", models.TextField()), - ( - "author", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to=settings.AUTH_USER_MODEL, - ), - ), - ], - options={ - "ordering": ["-created_on"], - }, - ), - ] diff --git a/backend/cms/migrations/__init__.py b/backend/cms/migrations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/backend/cms/models.py b/backend/cms/models.py deleted file mode 100644 index 03eea9f1c7..0000000000 --- a/backend/cms/models.py +++ /dev/null @@ -1,30 +0,0 @@ -# importing django models and users -from django.db import models -from django.contrib.auth.models import User - - -class Posts(models.Model): - """Basic model for posts.""" - - # title field using charfield constraint with unique constraint - title = models.CharField(max_length=200, unique=True) - # slug field auto populated using title with unique constraint - slug = models.SlugField(max_length=200, unique=True) - # author field populated using users database - author = models.ForeignKey(User, on_delete=models.CASCADE) - # and date time fields automatically populated using system time - updated_on = models.DateTimeField(auto_now=True) - created_on = models.DateTimeField(auto_now_add=True) - # content field to store our post - content = models.TextField() - # meta description for SEO benefits and accessibility - meta_description = models.CharField(max_length=300, null=True) - - class Meta: - """Meta information""" - - ordering = ["-created_on"] - - # used while managing models from terminal - def __str__(self): # pragma: no cover - return str(self.title) diff --git a/backend/cms/templatetags/__init__.py b/backend/cms/templatetags/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/backend/cms/tests.py b/backend/cms/tests.py deleted file mode 100644 index d2b618f3fb..0000000000 --- a/backend/cms/tests.py +++ /dev/null @@ -1,4 +0,0 @@ -# from django.test import TestCase - - -# Create your tests here. diff --git a/backend/cms/urls.py b/backend/cms/urls.py deleted file mode 100644 index ea01786eda..0000000000 --- a/backend/cms/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.urls import path -from . import views - - -urlpatterns = [ - # home page - path("", views.Home.as_view(), name="Home"), - # route for posts - # path("/", views.postdetail.as_view(), name="post_detail"), - path("robots.txt", views.NoRobots, name="no_robots"), -] diff --git a/backend/cms/views.py b/backend/cms/views.py deleted file mode 100644 index 5810372f03..0000000000 --- a/backend/cms/views.py +++ /dev/null @@ -1,30 +0,0 @@ -from .models import Posts -from django.views import generic -from django.shortcuts import render, redirect -from django.urls import reverse -from django.http import HttpResponse - - -# class based views for posts -class Home(generic.View): - def get(self, request, *args, **kwargs): - if request.user.is_authenticated: - url = reverse("audit:MySubmissions") - return redirect(url) - template_name = "home.html" - extra_context = {} - return render(request, template_name, extra_context) - - -# class based view for each post -class postdetail(generic.DetailView): - """Basic details class""" - - model = Posts - template_name = "post.html" - - -# robots.txt -def NoRobots(context): - content = "User-agent: *\nDisallow: /" - return HttpResponse(content, content_type="text/plain") diff --git a/backend/config/settings.py b/backend/config/settings.py index 9ef51f7f8b..16826a310d 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -120,7 +120,6 @@ "api", "users", "report_submission", - "cms", # "data_distro", "dissemination", "support", diff --git a/backend/config/urls.py b/backend/config/urls.py index f7ffc17b70..f084746212 100644 --- a/backend/config/urls.py +++ b/backend/config/urls.py @@ -73,8 +73,6 @@ ), path("audit/", include("audit.urls")), path("dissemination/", include("dissemination.urls")), - # Keep last so we can use short urls for content pages like home page etc. - path("", include("cms.urls")), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) if settings.ENABLE_DEBUG_TOOLBAR: