Browse Source

Rename urls from codered_ to crx_; other renaming and doc cleanup (#521)

Vince Salvino 2 years ago
parent
commit
d4746ef87c

+ 2 - 2
coderedcms/bin/coderedcms.py

@@ -60,11 +60,11 @@ class CreateProject(TemplateCommand):
         # Handle custom template logic
         import coderedcms
 
-        codered_path = os.path.dirname(coderedcms.__file__)
+        crx_path = os.path.dirname(coderedcms.__file__)
         if not options["template"]:
             options["template"] = "basic"
         template_path = os.path.join(
-            os.path.join(codered_path, "project_template"), options["template"]
+            os.path.join(crx_path, "project_template"), options["template"]
         )
 
         # Check if provided template is built-in to coderedcms,

+ 1 - 1
coderedcms/fields.py

@@ -12,7 +12,7 @@ class CoderedStreamField(StreamField):
 
     Since our StreamFields are generally huge, and we also let sites override
     the blocks in our concrete models dynamically, this creates a slew of
-    migration problems (most commonly: a client overrides CODERED_FRONTEND_*,
+    migration problems (most commonly: a client overrides CRX_FRONTEND_*,
     which changes a string used in a concrete model, which triggers a migration
     back in coderedcms). Eliminiating the blocks from the deconstructed
     StreamField allows us to have dynamic streamfields without breaking

+ 3 - 3
coderedcms/models/page_models.py

@@ -104,18 +104,18 @@ if TYPE_CHECKING:
 logger = logging.getLogger("coderedcms")
 
 
-CODERED_PAGE_MODELS = []
+CRX_PAGE_MODELS = []
 
 
 def get_page_models():
-    return CODERED_PAGE_MODELS
+    return CRX_PAGE_MODELS
 
 
 class CoderedPageMeta(PageBase):
     def __init__(cls, name, bases, dct):
         super().__init__(name, bases, dct)
         if not cls._meta.abstract:
-            CODERED_PAGE_MODELS.append(cls)
+            CRX_PAGE_MODELS.append(cls)
 
 
 class CoderedTag(TaggedItemBase):

+ 8 - 8
coderedcms/project_template/basic/project_name/urls.py

@@ -2,25 +2,25 @@ from django.conf import settings
 from django.urls import include, path
 from django.contrib import admin
 from wagtail.documents import urls as wagtaildocs_urls
-from coderedcms import admin_urls as coderedadmin_urls
-from coderedcms import search_urls as coderedsearch_urls
-from coderedcms import urls as codered_urls
+from coderedcms import admin_urls as crx_admin_urls
+from coderedcms import search_urls as crx_search_urls
+from coderedcms import urls as crx_urls
 
 urlpatterns = [
     # Admin
     path("django-admin/", admin.site.urls),
-    path("admin/", include(coderedadmin_urls)),
+    path("admin/", include(crx_admin_urls)),
     # Documents
     path("docs/", include(wagtaildocs_urls)),
     # Search
-    path("search/", include(coderedsearch_urls)),
+    path("search/", include(crx_search_urls)),
     # For anything not caught by a more specific rule above, hand over to
     # the page serving mechanism. This should be the last pattern in
     # the list:
-    path("", include(codered_urls)),
-    # Alternatively, if you want CMS pages to be served from a subpath
+    path("", include(crx_urls)),
+    # Alternatively, if you want pages to be served from a subpath
     # of your site, rather than the site root:
-    #    path("pages/", include(codered_urls)),
+    #    path("pages/", include(crx_urls)),
 ]
 
 

+ 8 - 8
coderedcms/project_template/sass/project_name/urls.py

@@ -2,25 +2,25 @@ from django.conf import settings
 from django.urls import include, path
 from django.contrib import admin
 from wagtail.documents import urls as wagtaildocs_urls
-from coderedcms import admin_urls as coderedadmin_urls
-from coderedcms import search_urls as coderedsearch_urls
-from coderedcms import urls as codered_urls
+from coderedcms import admin_urls as crx_admin_urls
+from coderedcms import search_urls as crx_search_urls
+from coderedcms import urls as crx_urls
 
 urlpatterns = [
     # Admin
     path("django-admin/", admin.site.urls),
-    path("admin/", include(coderedadmin_urls)),
+    path("admin/", include(crx_admin_urls)),
     # Documents
     path("docs/", include(wagtaildocs_urls)),
     # Search
-    path("search/", include(coderedsearch_urls)),
+    path("search/", include(crx_search_urls)),
     # For anything not caught by a more specific rule above, hand over to
     # the page serving mechanism. This should be the last pattern in
     # the list:
-    path("", include(codered_urls)),
-    # Alternatively, if you want CMS pages to be served from a subpath
+    path("", include(crx_urls)),
+    # Alternatively, if you want pages to be served from a subpath
     # of your site, rather than the site root:
-    #    path("pages/", include(codered_urls)),
+    #    path("pages/", include(crx_urls)),
 ]
 
 

+ 1 - 1
coderedcms/search_urls.py

@@ -2,5 +2,5 @@ from django.urls import path
 from coderedcms.views import search
 
 urlpatterns = [
-    path("", search, name="codered_search"),
+    path("", search, name="crx_search"),
 ]

+ 1 - 1
coderedcms/templates/coderedcms/pages/search.html

@@ -22,7 +22,7 @@
 <div class="container">
   {% block search_form %}
   {% if not settings.coderedcms.LayoutSettings.navbar_search %}
-  <form class="mt-5" action="{% url 'codered_search' %}" method="GET">
+  <form class="mt-5" action="{% url 'crx_search' %}" method="GET">
     <div class="row">
       <div class="col-8 col-sm-9">
         {% bootstrap_form form size="lg" layout="inline" server_side_validation=False %}

+ 1 - 1
coderedcms/templates/coderedcms/snippets/navbar.html

@@ -26,7 +26,7 @@
       {% endfor %}
       {% endif %}
       {% if settings.coderedcms.LayoutSettings.navbar_search %}
-      <form class="d-flex ms-auto" role="search" action="{% url 'codered_search' %}" method="GET">
+      <form class="d-flex ms-auto" role="search" action="{% url 'crx_search' %}" method="GET">
         {% load django_bootstrap5 %}
         {% get_searchform request as form %}
         {% for field in form %}

+ 2 - 2
coderedcms/tests/test_urls.py

@@ -45,14 +45,14 @@ class TestSiteURLs(unittest.TestCase):
 
     def test_search(self):
         response = self.client.get(
-            reverse("codered_search"), {"s": "Test Search Query"}, follow=True
+            reverse("crx_search"), {"s": "Test Search Query"}, follow=True
         )
 
         self.assertEqual(response.status_code, 200)
         self.assertNotEqual(response.context["results"], None)
 
         response = self.client.get(
-            reverse("codered_search"),
+            reverse("crx_search"),
             {
                 "s": "keyword",
                 "t": "t",

+ 6 - 15
coderedcms/tests/urls.py

@@ -1,23 +1,14 @@
 from django.urls import include, path, re_path
 from django.contrib import admin
 from wagtail.documents import urls as wagtaildocs_urls
-from coderedcms import admin_urls as coderedadmin_urls
-from coderedcms import search_urls as coderedsearch_urls
-from coderedcms import urls as codered_urls
+from coderedcms import admin_urls as crx_admin_urls
+from coderedcms import search_urls as crx_search_urls
+from coderedcms import urls as crx_urls
 
 urlpatterns = [
-    # Admin
     path("django-admin/", admin.site.urls),
-    path("admin/", include(coderedadmin_urls)),
-    # Documents
+    path("admin/", include(crx_admin_urls)),
     path("docs/", include(wagtaildocs_urls)),
-    # Search
-    path("search/", include(coderedsearch_urls)),
-    # For anything not caught by a more specific rule above, hand over to
-    # the page serving mechanism. This should be the last pattern in
-    # the list:
-    re_path(r"", include(codered_urls)),
-    # Alternatively, if you want CMS pages to be served from a subpath
-    # of your site, rather than the site root:
-    #    re_path(r'^pages/', include(codered_urls)),
+    path("search/", include(crx_search_urls)),
+    re_path(r"", include(crx_urls)),
 ]

+ 3 - 3
coderedcms/urls.py

@@ -15,9 +15,9 @@ from coderedcms.views import (
 
 urlpatterns = [
     # CodeRed custom URLs
-    path(r"favicon.ico", favicon, name="codered_favicon"),
-    path(r"robots.txt", robots, name="codered_robots"),
-    path(r"sitemap.xml", sitemap, name="codered_sitemap"),
+    path(r"favicon.ico", favicon, name="crx_favicon"),
+    path(r"robots.txt", robots, name="crx_robots"),
+    path(r"sitemap.xml", sitemap, name="crx_sitemap"),
     re_path(
         r"^{0}(?P<path>.*)$".format(
             crx_settings.CRX_PROTECTED_MEDIA_URL.lstrip("/")

+ 1 - 1
coderedcms/wagtail_hooks.py

@@ -89,7 +89,7 @@ hooks.register("after_delete_snippet", clear_wagtailcache)
 
 
 @hooks.register("filter_form_submissions_for_user")
-def codered_forms(user, editable_forms):
+def crx_forms(user, editable_forms):
     """
     Add our own CoderedFormPage to editable_forms, since wagtail is unaware
     of its existence. Essentially this is a fork of wagtail.contrib.forms.get_forms_for_user()

+ 1 - 1
docs/advanced/advanced01.rst

@@ -154,7 +154,7 @@ the ``snippets`` folder and create a ``navbar.html`` file inside of that folder.
          </ul>
          {% endfor %}
          {% if settings.coderedcms.LayoutSettings.navbar_search %}
-         <form class="ml-auto form-inline" action="{% url 'codered_search' %}" method="GET">
+         <form class="ml-auto form-inline" action="{% url 'crx_search' %}" method="GET">
                {% load django_bootstrap5 %}
                {% get_searchform request as form %}
                {% bootstrap_form form layout='inline' %}

+ 2 - 2
docs/features/blocks/contentblocks/button.rst

@@ -16,9 +16,9 @@ Fields and purposes:
   here as well, such as ``Learn <b>More</b>``.
 
 * **Button Style** - The appearance of the button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
+  ``CRX_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
   CSS class in the HTML.
 
 * **Button Size** - The size of button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
+  ``CRX_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
   class in the HTML.

+ 6 - 6
docs/features/blocks/contentblocks/download.rst

@@ -1,7 +1,7 @@
 Download Block
 ==============
 
-The download block enables users to add documents to the CMS which website 
+The download block enables users to add documents to the CMS which website
 visitors can download from the site.
 
 Field Reference
@@ -11,18 +11,18 @@ Field Reference
   here as well, such as ``Learn <b>More</b>``.
 
 * **Button Style** - The appearance of the button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
+  ``CRX_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
   CSS class in the HTML.
 
 * **Button Size** - The size of button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
+  ``CRX_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
   class in the HTML.
 
 * **Auto Download** - Enables automatic download upon click of the button
 
 * **Document Link** - Link to the document, which you will need to upload into the CMS
 
-* **Advanced Settings** - Add custom CSS classes or a CSS ID to style the block with your custom CSS 
+* **Advanced Settings** - Add custom CSS classes or a CSS ID to style the block with your custom CSS
 
 .. figure:: img/blocks_download.png
     :alt: A download block and its settings.
@@ -30,8 +30,8 @@ Field Reference
     A download block and its settings.
 
 .. figure:: img/blocks_choose_doc.png
-    :alt: Choosing the document 
+    :alt: Choosing the document
 
     The popup for choosing which document you want to upload to the block for download by users
 
-When a website visitor clicks the button, the document is available for download in a new window. 
+When a website visitor clicks the button, the document is available for download in a new window.

+ 5 - 5
docs/features/blocks/contentblocks/modal.rst

@@ -1,7 +1,7 @@
 Modal Block
 ===========
 
-Creates a popup box with a header, footer, and the ability to display the body as a block. 
+Creates a popup box with a header, footer, and the ability to display the body as a block.
 
 Field Reference
 ---------------
@@ -12,11 +12,11 @@ Fields and purposes:
   here as well, such as ``Learn <b>More</b>``.
 
 * **Button Style** - The appearance of the button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
+  ``CRX_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
   CSS class in the HTML.
 
 * **Button Size** - The size of button. This is a choice loaded from
-  ``CODERED_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
+  ``CRX_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
   class in the HTML.
 
 * **Modal Heading** - The heading, or title, that will display on the modal
@@ -25,9 +25,9 @@ Fields and purposes:
 
 * **Modal Footer** - Choose a Simple Text footer or a button link
 
-Once it is published, website visitors can click the button to see the popup message. 
+Once it is published, website visitors can click the button to see the popup message.
 
 .. figure:: img/cupcake_modal_sample.png
     :alt: Our cupcake modal
 
-    Our cupcake modal as it appears on the page
+    Our cupcake modal as it appears on the page

+ 7 - 0
docs/releases/v1.0.0.rst

@@ -91,6 +91,13 @@ Updating Python code & Django templates
 #. Find and replace ``codered_banner.html`` with ``crx_banner.html`` in your
    Python and HTML code.
 
+#. Find and replace the following URL names in your Python and HTML code:
+
+   * ``codered_favicon`` with ``crx_favicon``
+   * ``codered_robots`` with ``crx_robots``
+   * ``codered_search`` with ``crx_search``
+   * ``codered_sitemap`` with ``crx_sitemap``
+
 #. Make and run migrations:
 
    .. code-block:: text

+ 8 - 8
tutorial/mysite/mysite/urls.py

@@ -2,25 +2,25 @@ from django.conf import settings
 from django.urls import include, path, re_path
 from django.contrib import admin
 from wagtail.documents import urls as wagtaildocs_urls
-from coderedcms import admin_urls as coderedadmin_urls
-from coderedcms import search_urls as coderedsearch_urls
-from coderedcms import urls as codered_urls
+from coderedcms import admin_urls as crx_admin_urls
+from coderedcms import search_urls as crx_search_urls
+from coderedcms import urls as crx_urls
 
 urlpatterns = [
     # Admin
     path("django-admin/", admin.site.urls),
-    path("admin/", include(coderedadmin_urls)),
+    path("admin/", include(crx_admin_urls)),
     # Documents
     path("docs/", include(wagtaildocs_urls)),
     # Search
-    path("search/", include(coderedsearch_urls)),
+    path("search/", include(crx_search_urls)),
     # For anything not caught by a more specific rule above, hand over to
     # the page serving mechanism. This should be the last pattern in
     # the list:
-    re_path(r"", include(codered_urls)),
-    # Alternatively, if you want CMS pages to be served from a subpath
+    re_path(r"", include(crx_urls)),
+    # Alternatively, if you want pages to be served from a subpath
     # of your site, rather than the site root:
-    #    re_path(r"^pages/", include(codered_urls)),
+    #    re_path(r"^pages/", include(crx_urls)),
 ]
 
 

+ 1 - 1
tutorial/mysite/website/templates/coderedcms/snippets/navbar.html

@@ -47,7 +47,7 @@
       </ul>
       {% endfor %}
       {% if settings.coderedcms.LayoutSettings.navbar_search %}
-      <form class="d-flex ms-auto" action="{% url 'codered_search' %}" method="GET">
+      <form class="d-flex ms-auto" action="{% url 'crx_search' %}" method="GET">
           {% load django_bootstrap5 %}
           {% get_searchform request as form %}
           {% bootstrap_form form layout='inline' %}