Skip to content

Commit

Permalink
Merge development to main (release from Dec 2023) (#1537)
Browse files Browse the repository at this point in the history
* Wagtail 4.1.9 upgrade (#1522)

* Updated to wagtail 4.1.9 and replaced WagtailPageTests with WagtailPageTestCase

* Fixes migration conflict

* Added source field to Thank You Note (#1529)

* Update admin.py (#1532)

Co-authored-by: Staxly <[email protected]>

* updating book filter to exclude (#1530)

Co-authored-by: Staxly <[email protected]>
Co-authored-by: Michael Volo <[email protected]>

---------

Co-authored-by: Ed Woodward <[email protected]>
Co-authored-by: Colby <[email protected]>
Co-authored-by: Staxly <[email protected]>
  • Loading branch information
4 people authored Dec 20, 2023
1 parent 6c4e117 commit 4e66d25
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 33 deletions.
7 changes: 2 additions & 5 deletions allies/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from allies.models import AllySubject, Ally
from snippets.models import Subject

from wagtail.test.utils import WagtailTestUtils, WagtailPageTests
from wagtail.test.utils import WagtailTestUtils, WagtailPageTestCase


class AlliesTests(WagtailPageTests):
class AlliesTests(WagtailPageTestCase):
def setUp(self):
self.math = Subject(name="Math", page_content="Math page content.", seo_title="Math SEO Title",
search_description="Math page description.")
Expand Down Expand Up @@ -42,8 +42,5 @@ def test_can_create_ally_subject(self):
self.assertEquals('Math', result.get_subject_name())

def test_can_create_ally(self):
#ally_subject = AllySubject(subject=self.math, ally=self.ally)
#ally_subject.save()
result = Ally.objects.all()[0]
#print('ally subject: ' + str(result))
self.assertEquals('Ally Heading', result.heading)
2 changes: 1 addition & 1 deletion books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ class BookIndex(Page):

@property
def books(self):
books = Book.objects.live().filter(locale=self.locale).filter(self.book_state is not 'unlisted').order_by('title')
books = Book.objects.live().filter(locale=self.locale).exclude(book_state='unlisted').order_by('title')
book_data = []
for book in books:
has_faculty_resources = BookFacultyResources.objects.filter(book_faculty_resource=book).exists()
Expand Down
4 changes: 2 additions & 2 deletions books/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import vcr

from wagtail.test.utils import WagtailPageTests
from wagtail.test.utils import WagtailPageTestCase
from wagtail.models import Page

import snippets.models
Expand All @@ -14,7 +14,7 @@
import datetime


class BookTests(WagtailPageTests):
class BookTests(WagtailPageTestCase):

def setUp(self):
self.client = Client()
Expand Down
18 changes: 18 additions & 0 deletions donations/migrations/0008_thankyounote_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-11-17 14:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('donations', '0007_auto_20220516_2113'),
]

operations = [
migrations.AddField(
model_name='thankyounote',
name='source',
field=models.CharField(blank=True, default='', max_length=255),
),
]
1 change: 1 addition & 0 deletions donations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ThankYouNote(models.Model):
created = models.DateField(auto_now_add=True)
consent_to_share_or_contact = models.BooleanField(default=False)
contact_email_address = models.EmailField(blank=True, null=True)
source = models.CharField(max_length=255, default="", blank=True)

class DonationPopup(models.Model):
download_image = models.ImageField(null=True, blank=True)
Expand Down
6 changes: 4 additions & 2 deletions donations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ class Meta:
'institution',
'created',
'consent_to_share_or_contact',
'contact_email_address')
'contact_email_address',
'source')
read_only_fields = ('thank_you_note',
'first_name',
'last_name',
'institution',
'created',
'consent_to_share_or_contact',
'contact_email_address')
'contact_email_address',
'source')


class DonationPopupSerializer(serializers.ModelSerializer):
Expand Down
2 changes: 1 addition & 1 deletion donations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_donation_api_get(self):
class ThankYouNoteTest(APITestCase, TestCase):

def test_thank_you_note_api_post(self):
data = {"thank_you_note":"OpenStax is the best! Loved not paying for a book", "last_name": "Drew", "first_name": "Jessica", "institution": "Rice University", "consent_to_share_or_contact": "True", "contact_email_address": "[email protected]"}
data = {"thank_you_note":"OpenStax is the best! Loved not paying for a book", "last_name": "Drew", "first_name": "Jessica", "institution": "Rice University", "consent_to_share_or_contact": "True", "contact_email_address": "[email protected]", "source": "PDF download"}
response = self.client.post('/apps/cms/api/donations/thankyounote/', data, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
tyn = ThankYouNote.objects.filter(last_name='Drew').values()
Expand Down
4 changes: 3 additions & 1 deletion donations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ def post(self, request):
institution = request.data['institution']
consent_to_share_or_contact = request.data.get('consent_to_share_or_contact', False)
contact_email_address = request.data.get('contact_email_address', '')
source = request.data.get('source', '')

ty_note = ThankYouNote.objects.create(thank_you_note=thank_you_note,
first_name=first_name,
last_name=last_name,
institution=institution,
consent_to_share_or_contact=consent_to_share_or_contact,
contact_email_address=contact_email_address)
contact_email_address=contact_email_address,
source=source)

serializer = ThankYouNoteSerializer(data=request.data)
if serializer.is_valid():
Expand Down
6 changes: 3 additions & 3 deletions errata/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class Meta:
class CustomExportResource(resources.ModelResource):
location = Field(attribute='location', column_name='Location')
detail = Field(attribute='detail', column_name='Detail')
resolution = Field(attribute='resolution', column_name='Resolution')
resolution_notes = Field(attribute='resolution_notes', column_name='Resolution Notes')
error_type = Field(attribute='error_type', column_name='Error Type')

class Meta:
model = Errata
fields = ('location', 'detail', 'resolution', 'error_type')
export_order = ('location', 'detail', 'resolution', 'error_type')
fields = ('location', 'detail', 'resolution_notes', 'error_type')
export_order = ('location', 'detail', 'resolution_notes', 'error_type')

def custom_export_action(modeladmin, request, queryset):
resource = CustomExportResource()
Expand Down
17 changes: 17 additions & 0 deletions errata/migrations/0056_alter_errata_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.7 on 2023-11-17 14:37

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('errata', '0055_remove_errata_accounts_user_email_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='errata',
options={'verbose_name': 'erratum list', 'verbose_name_plural': 'errata list'},
),
]
6 changes: 3 additions & 3 deletions news/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.utils import timezone
from django.test import TestCase
from wagtail.test.utils import WagtailPageTests
from wagtail.test.utils import WagtailPageTestCase
from wagtail.models import Page
from pages.models import HomePage
from shared.test_utilities import assertPathDoesNotRedirectToTrailingSlash
Expand All @@ -12,7 +12,7 @@
from snippets.models import Subject, BlogContentType, BlogCollection


class NewsTests(WagtailPageTests, TestCase):
class NewsTests(WagtailPageTestCase, TestCase):
def setUp(self):
# create collections
self.learning = BlogCollection(name='Teaching and Learning', description='this is a collection')
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_search_blog_collection_and_two_subjects(self):
self.assertContains(response, 'Math')


class PressTests(WagtailPageTests):
class PressTests(WagtailPageTestCase):
def setUp(self):
press_index = PressIndex.objects.all()[0]
self.press_release = PressRelease(title='Press release',
Expand Down
4 changes: 2 additions & 2 deletions oxmenus/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json

from django.test import TestCase
from wagtail.test.utils import WagtailPageTests
from wagtail.test.utils import WagtailPageTestCase
from oxmenus.models import Menus


class OXMenuTests(WagtailPageTests, TestCase):
class OXMenuTests(WagtailPageTestCase, TestCase):
def setUp(self):
oxmenu = Menus(name="What we do",
menu=json.dumps(
Expand Down
12 changes: 6 additions & 6 deletions pages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.test import TestCase, Client
from django.core.management import call_command
from wagtail.test.utils import WagtailTestUtils, WagtailPageTests
from wagtail.test.utils import WagtailTestUtils, WagtailPageTestCase
from wagtail.models import Page
from pages.models import (HomePage,
ContactUs,
Expand Down Expand Up @@ -45,7 +45,7 @@
from shared.test_utilities import assertPathDoesNotRedirectToTrailingSlash, mock_user_login
from http import cookies

class HomePageTests(WagtailPageTests):
class HomePageTests(WagtailPageTestCase):

def setUp(self):
mock_user_login()
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_allowed_subpages(self):
Assignable,
})

class PageTests(WagtailPageTests):
class PageTests(WagtailPageTestCase):
def setUp(self):
mock_user_login()
root_page = Page.objects.get(title="Root")
Expand Down Expand Up @@ -497,7 +497,7 @@ def test_can_create_assignable_page(self):
self.assertEqual(retrieved_page.title, "Assignable Page")


class ErrataListTest(WagtailPageTests):
class ErrataListTest(WagtailPageTestCase):

def setUp(self):
mock_user_login()
Expand All @@ -522,7 +522,7 @@ def test_can_create_errata_list_page(self):
self.assertEqual(retrieved_page.title, "Errata List Template")


class SubjectsPageTest(WagtailPageTests):
class SubjectsPageTest(WagtailPageTestCase):

def setUp(self):
mock_user_login()
Expand All @@ -544,7 +544,7 @@ def test_can_create_subjects_page(self):
self.assertEqual(retrieved_page.title, "Subjects")


class SubjectPageTest(WagtailPageTests):
class SubjectPageTest(WagtailPageTestCase):

def setUp(self):
mock_user_login()
Expand Down
7 changes: 4 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ django-import-export==2.8.0
django-libsass==0.9
django-rest-auth==0.9.5
django-reversion==5.0.0
djangorestframework==3.14.0
django-ses==3.0.1
django-storages==1.12.3
django-taggit>=3.0.0
django-taggit>=3.1.0
future==0.18.2
html2text==2020.1.16 # used in news feed
jsonfield==3.1.0
mapbox==0.18.1
MarkupPy==1.14
odfpy==1.4.1
openpyxl==3.0.10
psycopg2>=2.9.5
psycopg2>=2.9.9
pycryptodome==3.14.1 # for using the SSO cookie from accounts
PyJWE==1.0.0
sentry-sdk
Expand All @@ -30,7 +31,7 @@ ua_parser==0.16.1
unicodecsv==0.14.1
Unidecode==1.3.4
vcrpy==4.1.1 # for recording test interactions with third-party APIs
wagtail==4.0.4
wagtail==4.1.9
Wand==0.6.7 # for supporting animated gifs
whitenoise==6.1.0
xlrd==2.0.1
Expand Down
4 changes: 2 additions & 2 deletions salesforce/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from rest_framework.test import APITestCase
from rest_framework.test import APIRequestFactory

from wagtail.test.utils import WagtailPageTests
from wagtail.test.utils import WagtailPageTestCase
from wagtail.models import Page
from wagtail.documents.models import Document

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_all_partners_no_reviews(self):
# self.assertEqual(response.data['status'], 'Deleted')


class SalesforceTest(LiveServerTestCase, WagtailPageTests):
class SalesforceTest(LiveServerTestCase, WagtailPageTestCase):

def setUp(self):
mock_user_login()
Expand Down
14 changes: 14 additions & 0 deletions snippets/migrations/0031_merge_20231101_1313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.1.7 on 2023-11-01 18:13

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('snippets', '0030_alter_erratacontent_book_state'),
('snippets', '0030_amazonbookblurb'),
]

operations = [
]
14 changes: 14 additions & 0 deletions snippets/migrations/0032_merge_20231117_0830.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.1.7 on 2023-11-17 14:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('snippets', '0031_merge_20231101_1313'),
('snippets', '0031_merge_20231101_1438'),
]

operations = [
]
4 changes: 2 additions & 2 deletions webinars/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from django.test import TestCase
from django.utils import timezone
from wagtail.test.utils import WagtailPageTests
from wagtail.test.utils import WagtailPageTestCase

from snippets.models import Subject, WebinarCollection
from webinars.models import Webinar


class WebinarTests(WagtailPageTests, TestCase):
class WebinarTests(WagtailPageTestCase, TestCase):
def setUp(self):
# create subjects
self.math = Subject(name="Math", page_content="Math page content.", seo_title="Math SEO Title",
Expand Down

0 comments on commit 4e66d25

Please sign in to comment.