2
0
Эх сурвалжийг харах

Merge branch 'dev' into release/1

Vince Salvino 2 жил өмнө
parent
commit
b51a37ba89

+ 0 - 1
coderedcms/blocks/html_blocks.py

@@ -244,7 +244,6 @@ class PageListBlock(BaseBlock):
         label = _("Latest Pages")
         label = _("Latest Pages")
 
 
     def get_context(self, value, parent_context=None):
     def get_context(self, value, parent_context=None):
-
         context = super().get_context(value, parent_context=parent_context)
         context = super().get_context(value, parent_context=parent_context)
 
 
         indexer = value["indexed_by"].specific
         indexer = value["indexed_by"].specific

+ 0 - 1
coderedcms/blocks/stream_form_blocks.py

@@ -15,7 +15,6 @@ from coderedcms.forms import (
 
 
 
 
 class CoderedFormAdvSettings(CoderedAdvSettings):
 class CoderedFormAdvSettings(CoderedAdvSettings):
-
     condition_trigger_id = blocks.CharBlock(
     condition_trigger_id = blocks.CharBlock(
         required=False,
         required=False,
         max_length=255,
         max_length=255,

+ 27 - 16
coderedcms/models/page_models.py

@@ -7,7 +7,7 @@ import logging
 import os
 import os
 import warnings
 import warnings
 from datetime import date, datetime
 from datetime import date, datetime
-from typing import Dict, List, Optional, TYPE_CHECKING, Union
+from typing import Dict, List, Optional, TYPE_CHECKING, Union, Tuple
 
 
 # This is a requirement for icalendar, even if django doesn't require it
 # This is a requirement for icalendar, even if django doesn't require it
 import pytz
 import pytz
@@ -798,7 +798,9 @@ class CoderedEventPage(CoderedWebPage, BaseEvent):
         return self.query_occurrences(num_of_instances_to_return=10)
         return self.query_occurrences(num_of_instances_to_return=10)
 
 
     @property
     @property
-    def most_recent_occurrence(self):
+    def most_recent_occurrence(
+        self,
+    ) -> Tuple[datetime, datetime, BaseOccurrence]:
         """
         """
         Gets the next upcoming, or last occurrence if the event has no more occurrences.
         Gets the next upcoming, or last occurrence if the event has no more occurrences.
         """
         """
@@ -807,23 +809,32 @@ class CoderedEventPage(CoderedWebPage, BaseEvent):
             noc = self.next_occurrence()
             noc = self.next_occurrence()
             if noc:
             if noc:
                 return noc
                 return noc
-            aoc = []
-            for occurrence in self.occurrences.all():
-                aoc += [instance for instance in occurrence.all_occurrences()]
-            if len(aoc) > 0:
-                return aoc[-1]  # last one in the list
 
 
         except AttributeError:
         except AttributeError:
             # Triggers when a preview is initiated on an
             # Triggers when a preview is initiated on an
             # EventPage because it uses a FakeQuerySet object.
             # EventPage because it uses a FakeQuerySet object.
             # Here we manually compute the next_occurrence
             # Here we manually compute the next_occurrence
             occurrences = [e.next_occurrence() for e in self.occurrences.all()]
             occurrences = [e.next_occurrence() for e in self.occurrences.all()]
-            if occurrences:
+            # If there are no more occurrences, we find the last one instead
+            if occurrences and None not in occurrences:
                 return sorted(occurrences, key=lambda tup: tup[0])[0]
                 return sorted(occurrences, key=lambda tup: tup[0])[0]
 
 
+        # If both of the above methods fail to find a future occurrence,
+        # instead return the last occurrence.
+        aoc = []
+        for occurrence in self.occurrences.all():
+            aoc += [instance for instance in occurrence.all_occurrences()]
+        if len(aoc) > 0:
+            return aoc[-1]  # last one in the list
+
     @property
     @property
     def seo_struct_event_dict(self) -> dict:
     def seo_struct_event_dict(self) -> dict:
         next_occ = self.most_recent_occurrence
         next_occ = self.most_recent_occurrence
+        if not next_occ:
+            return {}
+        # The method returns a tuple of the start, end, and object. We only care about
+        # the object, so take it out of the tuple.
+        next_occ = next_occ[2]
         sd_dict = {
         sd_dict = {
             "@context": "https://schema.org/",
             "@context": "https://schema.org/",
             "@type": "Event",
             "@type": "Event",
@@ -833,12 +844,18 @@ class CoderedEventPage(CoderedWebPage, BaseEvent):
             "endDate": next_occ.end,
             "endDate": next_occ.end,
             "mainEntityOfPage": {
             "mainEntityOfPage": {
                 "@type": "WebPage",
                 "@type": "WebPage",
-                "@id": self.get_full_url,
+                "@id": self.get_full_url(),
             },
             },
         }
         }
 
 
         if self.seo_image:
         if self.seo_image:
-            sd_dict.update({"image": get_struct_data_images(self.seo_image)})
+            sd_dict.update(
+                {
+                    "image": get_struct_data_images(
+                        self.get_site(), self.seo_image
+                    )
+                }
+            )
 
 
         if self.address:
         if self.address:
             sd_dict.update(
             sd_dict.update(
@@ -879,7 +896,6 @@ class CoderedEventPage(CoderedWebPage, BaseEvent):
 
 
         # For each occurrence rule in all of the occurrence rules for this event.
         # For each occurrence rule in all of the occurrence rules for this event.
         for occurrence in self.occurrences.all():
         for occurrence in self.occurrences.all():
-
             # Add the qualifying generated event instances to the list.
             # Add the qualifying generated event instances to the list.
             event_instances += [
             event_instances += [
                 instance
                 instance
@@ -1280,7 +1296,6 @@ class CoderedFormMixin(models.Model):
         processed_data = {}
         processed_data = {}
         # Handle file uploads
         # Handle file uploads
         for key, val in form.cleaned_data.items():
         for key, val in form.cleaned_data.items():
-
             if (
             if (
                 type(val) == InMemoryUploadedFile
                 type(val) == InMemoryUploadedFile
                 or type(val) == TemporaryUploadedFile
                 or type(val) == TemporaryUploadedFile
@@ -1318,7 +1333,6 @@ class CoderedFormMixin(models.Model):
     def process_form_submission(
     def process_form_submission(
         self, request, form, form_submission, processed_data
         self, request, form, form_submission, processed_data
     ):
     ):
-
         # Save to database
         # Save to database
         if self.save_to_database:
         if self.save_to_database:
             form_submission.save()
             form_submission.save()
@@ -1332,7 +1346,6 @@ class CoderedFormMixin(models.Model):
             context = Context(self.data_to_dict(processed_data, request))
             context = Context(self.data_to_dict(processed_data, request))
             # Render emails as if they are django templates.
             # Render emails as if they are django templates.
             for email in self.confirmation_emails.all():
             for email in self.confirmation_emails.all():
-
                 # Build email message parameters.
                 # Build email message parameters.
                 message_args = {}
                 message_args = {}
                 # From
                 # From
@@ -1437,7 +1450,6 @@ class CoderedFormMixin(models.Model):
         message.send()
         message.send()
 
 
     def render_landing_page(self, request, form_submission=None):
     def render_landing_page(self, request, form_submission=None):
-
         """
         """
         Renders the landing page.
         Renders the landing page.
 
 
@@ -1646,7 +1658,6 @@ class CoderedSubmissionRevision(SubmissionRevision, models.Model):
 
 
 
 
 class CoderedSessionFormSubmission(SessionFormSubmission):
 class CoderedSessionFormSubmission(SessionFormSubmission):
-
     INCOMPLETE = "incomplete"
     INCOMPLETE = "incomplete"
     COMPLETE = "complete"
     COMPLETE = "complete"
     REVIEWED = "reviewed"
     REVIEWED = "reviewed"

+ 15 - 0
coderedcms/models/tests/test_page_models.py

@@ -1,3 +1,4 @@
+from datetime import datetime, timedelta
 from django.test import Client
 from django.test import Client
 from wagtail.test.utils import WagtailPageTests
 from wagtail.test.utils import WagtailPageTests
 
 
@@ -20,6 +21,7 @@ from coderedcms.tests.testapp.models import (
     ArticlePage,
     ArticlePage,
     EventIndexPage,
     EventIndexPage,
     EventPage,
     EventPage,
+    EventOccurrence,
     FormPage,
     FormPage,
     IndexTestPage,
     IndexTestPage,
     LocationIndexPage,
     LocationIndexPage,
@@ -200,6 +202,19 @@ class EventIndexPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
 class EventPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
 class EventPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
     model = EventPage
     model = EventPage
 
 
+    def setUp(self):
+        super().setUp()
+        self.occurrence = EventOccurrence(
+            start=datetime.now(),
+            end=datetime.now() + timedelta(days=1),
+            event=self.basic_page,
+        )
+        self.occurrence.save()
+
+    def tearDown(self) -> None:
+        super().tearDown()
+        self.occurrence.delete()
+
 
 
 class LocationIndexPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
 class LocationIndexPageTestCase(ConcreteBasicPageTestCase, WagtailPageTests):
     model = LocationIndexPage
     model = LocationIndexPage

+ 0 - 1
coderedcms/settings.py

@@ -4,7 +4,6 @@ from django.conf import settings
 
 
 
 
 class _DefaultSettings:
 class _DefaultSettings:
-
     CRX_PROTECTED_MEDIA_URL = "/protected/"
     CRX_PROTECTED_MEDIA_URL = "/protected/"
     CRX_PROTECTED_MEDIA_ROOT = os.path.join(settings.BASE_DIR, "protected")
     CRX_PROTECTED_MEDIA_ROOT = os.path.join(settings.BASE_DIR, "protected")
     CRX_PROTECTED_MEDIA_UPLOAD_WHITELIST = []
     CRX_PROTECTED_MEDIA_UPLOAD_WHITELIST = []

+ 1 - 1
coderedcms/templates/coderedcms/blocks/accordion_block.html

@@ -4,7 +4,7 @@
 {% with a_id=self.accordion.id accordion=self.accordion %}
 {% with a_id=self.accordion.id accordion=self.accordion %}
 <div class="accordion" id="accordion-{{a_id}}">
 <div class="accordion" id="accordion-{{a_id}}">
   {% for panel in accordion.accordion_panels.all %}
   {% for panel in accordion.accordion_panels.all %}
-  <div class="accordion-item">
+  <div id="{{panel.custom_id}}" class="accordion-item {{panel.custom_css_class}}">
     <h2 class="accordion-header" id="accordion-heading-{{forloop.counter}}">
     <h2 class="accordion-header" id="accordion-heading-{{forloop.counter}}">
       <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
       <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
         data-bs-target="#collapse-{{a_id}}-{{forloop.counter}}" aria-expanded="false"
         data-bs-target="#collapse-{{a_id}}-{{forloop.counter}}" aria-expanded="false"

+ 3 - 5
coderedcms/templates/coderedcms/blocks/cardgrid_deck.html

@@ -2,10 +2,8 @@
 {% load wagtailcore_tags %}
 {% load wagtailcore_tags %}
 {% block grid_content %}
 {% block grid_content %}
 <div class="row {{self.settings.custom_css_class}}">
 <div class="row {{self.settings.custom_css_class}}">
-  <div class="col">
-    {% for block in self.content %}
-    {% include_block block %}
-    {% endfor %}
-  </div>
+  {% for block in self.content %}
+  <div class="col">{% include_block block %}</div>
+  {% endfor %}
 </div>
 </div>
 {% endblock %}
 {% endblock %}

+ 1 - 2
coderedcms/templates/coderedcms/includes/pagination.html

@@ -9,8 +9,7 @@
       </a>
       </a>
     </li>
     </li>
     <li class="page-item disabled">
     <li class="page-item disabled">
-      <span class="page-link">{% trans 'Page' %} {{ items.number }} {% trans 'of' %} {{ items.paginator.num_pages
-        }}</span>
+      <span class="page-link">{% trans 'Page' %} {{ items.number }} {% trans 'of' %} {{ items.paginator.num_pages }}</span>
     </li>
     </li>
     <li class="page-item {% if not items.has_next %}disabled{% endif %}">
     <li class="page-item {% if not items.has_next %}disabled{% endif %}">
       <a class="page-link" href="{% if items.has_next %}?{% query_update request.GET 'p' items.next_page_number as q %}{{q.urlencode}}{% else %}#{% endif %}" aria-label="Next">
       <a class="page-link" href="{% if items.has_next %}?{% query_update request.GET 'p' items.next_page_number as q %}{{q.urlencode}}{% else %}#{% endif %}" aria-label="Next">

+ 4 - 1
coderedcms/templates/coderedcms/pages/base.html

@@ -165,7 +165,10 @@
 
 
   {% block custom_scripts %}{% endblock %}
   {% block custom_scripts %}{% endblock %}
 
 
-  {% include "wagtailseo/struct_data.html" %}
+  {% block struct_seo %}
+    {% include "wagtailseo/struct_data.html" %}
+    {% block struct_seo_extra %}{% endblock %}
+  {% endblock %}
 
 
   {% block body_tracking_scripts %}
   {% block body_tracking_scripts %}
   {% if settings.coderedcms.AnalyticsSettings.gtm_id %}
   {% if settings.coderedcms.AnalyticsSettings.gtm_id %}

+ 0 - 1
coderedcms/tests/testapp/models.py

@@ -60,7 +60,6 @@ class FormPageField(CoderedFormField):
 
 
 
 
 class FormConfirmEmail(CoderedEmail):
 class FormConfirmEmail(CoderedEmail):
-
     page = ParentalKey("FormPage", related_name="confirmation_emails")
     page = ParentalKey("FormPage", related_name="confirmation_emails")
 
 
 
 

+ 0 - 1
coderedcms/wagtail_flexible_forms/models.py

@@ -293,7 +293,6 @@ class Steps(list):
 
 
 
 
 class SessionFormSubmission(AbstractFormSubmission):
 class SessionFormSubmission(AbstractFormSubmission):
-
     session_key = CharField(max_length=40, null=True, default=None)
     session_key = CharField(max_length=40, null=True, default=None)
     user = ForeignKey(
     user = ForeignKey(
         settings.AUTH_USER_MODEL,
         settings.AUTH_USER_MODEL,

+ 19 - 0
docs/contributing/index.rst

@@ -299,6 +299,25 @@ Or manually using sphinx:
 
 
 Output will be in ``docs/_build/html/`` directory.
 Output will be in ``docs/_build/html/`` directory.
 
 
+Updating Tutorial Documentation
+-------------------------------
+
+From time to time, the documentation for the tutorial will need to be updated. You can work directly in
+the tutorial site by loading the fixture file for its database (read more at :ref:`load-data`). 
+
+However, once you have worked in the tutorial site and gotten new screenshots for the **Getting Started** documentation,
+you will also need to update the fixture file, which is located in ``tutorial > mysite > website > fixtures``. 
+
+**These are the steps for updating the fixture:**
+
+1. From the command line, type ``python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4 > dumpdata.json``
+
+2. The dumped data file will show up in the ``website`` folder. Open it and copy/paste its contents into a new file called ``database.json``. This will fix the encoding issue you would run into otherwise. Save the new fixture file and delete the one that was dumped. Also delete the one that is currently in the ``fixtures`` folder.
+
+3. Move the ``database.json`` file into the ``fixtures`` folder. 
+
+4. For testing ``loaddata``, please review the steps at  :ref:`load-data`. 
+
 
 
 Publishing a New Release
 Publishing a New Release
 ------------------------
 ------------------------

+ 28 - 1
docs/getting_started/install.rst

@@ -50,7 +50,9 @@ Basic Installation
 
 
 ✨🎉 You now have Wagtail CRX up and running! 🎉✨
 ✨🎉 You now have Wagtail CRX up and running! 🎉✨
 
 
-Follow the tutorial to build :doc:`tutorial01`
+Follow the tutorial to build: :doc:`tutorial01`.
+
+You can also play around with our tutorial database. Learn more: :ref:`load-data`.
 
 
 
 
 Installing with Sass Support
 Installing with Sass Support
@@ -96,6 +98,31 @@ When working with Sass, you will want to look at the base.html file provided at:
 ``mysite/website/templates/coderedcms/pages/base.html`` to load in any custom
 ``mysite/website/templates/coderedcms/pages/base.html`` to load in any custom
 CSS or JavaScript as needed.
 CSS or JavaScript as needed.
 
 
+.. _load-data:
+
+Adding Our Tutorial Database
+----------------------------
+
+You can follow along with our tutorial and upload your own pictures and content; however,
+we have included our database data from our tutorial project so you can take a tour inside of
+the project and play around with it. The database is located in ``website > fixtures > database.json``.
+
+Follow these steps to upload it:
+
+1. Navigate to the tutorial project in the Command Line by going to ``coderedcms > tutorial > mysite``. 
+
+2. In a fresh virtual environment, type ``pip install -r requirements.txt`` to set up the requirements for the project.
+
+3. Set up your database like usual. If you want to use a database other than the default ``sqlite3``, you will need to set it up first. It will be an empty database for now.
+
+4. Do the initial migration for the tutorial site with ``python manage.py migrate``.
+
+5. Navigate to the ``database.json`` file in the Fixtures folder and copy the path to the file. 
+
+6. From the Command Line, type ``python manage.py loaddata "path/to/database.json"``, replacing that last part with the correct path to the file.
+
+7. Check to see if it worked by running ``python manage.py runserver``. You should now see our tutorial project with all of the content we have added to the site. It's ready for you to play around with it!
+
 
 
 Starter Templates
 Starter Templates
 -----------------
 -----------------

+ 1 - 0
docs/releases/index.rst

@@ -15,6 +15,7 @@ Wagtail CRX (previously CodeRed CMS) follows the
 .. toctree::
 .. toctree::
     :maxdepth: 1
     :maxdepth: 1
 
 
+    v1.0.2
     v1.0.1
     v1.0.1
     v1.0.0
     v1.0.0
     v0.25.2
     v0.25.2

+ 24 - 0
docs/releases/v1.0.2.rst

@@ -0,0 +1,24 @@
+v1.0.2 release notes
+====================
+
+
+Bug fixes
+---------
+
+* Fix pagination display issues.
+
+* Fix card grid "deck" display issues.
+
+* Correctly insert custom ``id`` and ``class`` in accordion panels.
+
+* Fix errors when previewing Event pages from the Wagtail Admin.
+
+* Correctly insert structured data on Event pages.
+
+* Add blocks ``struct_seo`` and ``struct_seo_extra`` to ``base.html`` template, to enable easier overriding.
+
+
+Thank you!
+----------
+
+Thanks to everyone who contributed to `1.0.2 on GitHub <https://github.com/coderedcorp/coderedcms/milestone/43?closed=1>`_.

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 318 - 0
tutorial/mysite/website/fixtures/database.json


+ 7 - 0
tutorial/mysite/website/static/website/css/custom.css

@@ -13,6 +13,13 @@
     color: #f75990;
     color: #f75990;
 }
 }
 
 
+.cherry-headers h1, 
+.cherry-headers h2,
+.cherry-headers h3,
+.cherry-headers h4 {
+    color: #f75990;
+}
+
 .border-cherry {
 .border-cherry {
     border: 10px solid #f75990;
     border: 10px solid #f75990;
 }
 }

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно