Skip to content

Commit

Permalink
Merge Release v6.15.0 into main (#1498)
Browse files Browse the repository at this point in the history
* Added Ally Logo page (#1354)

* Removed dbbackup because it does not solve to intended problem (#1355)

* Removed ScoutAPM since it is no longer used (#1360)

* only upload book data if the resource has a salesforce abbr (#1364)

* Added cache clearing for general pages and fixed sticky note (#1365)

* Changed query to sort by title instead of path (#1368)

* Updated Partner query, removed reviews and updated tests (#1371)

* Updated partner query, removed review sync and made all visible on website

* Removed reviews and updated tests

* Bump pillow from 9.1.1 to 9.3.0 in /requirements (#1366)

Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.1.1 to 9.3.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](python-pillow/Pillow@9.1.1...9.3.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Volo <[email protected]>

* adding k12 pages, subjects

* Add check on queryset for Resources (#1375)

* Add check on queryset for Resources

* Added test for bad slug

* Removed Testimonial fields from School listing (#1377)

* Clear resources on page save (#1381)

* Added checks for book before creating resource download or sending to Salesforce (#1384)

* Added checks for book before creating or sending to Salesforce

* Edited if statement

* Model and migration for new learning research page

* Add new research page to home subpages

* Add page to test

* Python spacing

* Update help text for some fields

* fix class naming convention

* added student and instructor resources to k12 subject pages

* Tidy pages/model.py

* Remove old research page in favor of new learning-research page

* Remove unused field

* remove seo title and search description from snippets/models

* reverted update_partners.py

* Added Ally Logo page (#1354)

* Added cache clearing for general pages and fixed sticky note (#1365)

* Ne wmigration for learningresearch page

* Upgrade to Wagtail 3 (#1398)

* Added Ally Logo page (#1354)

* Changed wagtail.core to wagtail

* Changed wagtail.tests to wagtail.test

* Set StreamField to have use_json_field parameter

* FieldPanel changes

* Update to Wagtail 3.0.3

* merge migrations after rebase

* Updated merged code for Wagtail 3

* Updated base.txt and locked-requirements.txt

* Updated mapbox to 0.18.1 (#1403)

* change schools/mapbox to sync monthly instead of daily (#1404)

* Merge migration per wagtail

* Remove all geneeral pages from sitemap except kinetic (#1402)

* adjusting k12 data for frontend needs (#1405)

* adjusting data for frontend needs

- add label to subject dropdown
- split name field in testimonials
- fix images coming from snippets
- modify subject category labels
- add titles and icons to resources
- move resources to book level

* fix resource icons for k12 pages

* add link_document_url to k12 subject pages

* Added links to documentation in Confluence, Added Contributing file (#1414)

* Fix import export (#1415)

* Fixed translation and locale in export

* More improvements

* Lookup documents by title when importing

* Uncommented save of a page

* All documents now included

* sort by book and git ignore icloud files (#1418)

* subject sort in release added to development (#1420)

* Errata form hotfix (#1423)

* Removed /general/ from kinetic page sitemap entry (#1421)

* Link preview fix (#1416)

* Added page template to blog posts

* Added page template to news app

* Moved page template to blog folder

* Folder to match FE URL with page template

* Removed folders that did not work and put page template under news

* middleware to create link preview

* All bots working now

* Added ua_parser to base.txt

* Looked up correct object based on url path

* Home page working and wrote tests

* Removed NewsArticle use of template since it is not needed

* Cleaned up template HTML

* Improved HTML formatting

* Remove all isbn 10 fields from books (#1428)

* K12 tags fix into development (#1429)

* Assignable page added to CMS (#1430)

* First pass at assignables page

* Assignable page added

* Tweaked Assignable fields based on new text document (#1431)

* Tweaked fields based on new text document

* Latest round of changes

* renamed book columns

* Remove reference to assignable_book_link

* Errata Export hotfix in development branch (#1440)

* add resource_unlocked to k12 faculty resource lists (#1436)

* Remove one page limitation on FAQ (#1441)

* Replaced heading with heading_title_image (#1442)

* Added add assignable cta fields (#1443)

* Added add assignable cta fields

* Added FAQ section

* update readme versions and docker configs (#1447)

* add cnx_id to book data (#1446)

* Added field to resource API to match old Book API resource field (#1445)

* Added resource_category field to resource snippets (#1448)

* Added resource_category field to resource snippets

* Added missing resource category on FacultyResource model for books

* adding assignable resource (#1452)

* adding assignable resource

* Update 0053_alter_errata_resource.py

* Update query for Opps to fetch UUID through the contact (#1453)

* Added image carousel for Assignable (#1454)

* Snippet for no webinar message (#1455)

* update Book relationship query (#1459)

* Fixed object structure from Salesforce (#1460)

* remove student numbers from opp query (#1461)

* Menus (#1462)

* Code for adding menus for site to CMS

* Menus working, but improvements needed

* Made cleaner json

* Added tests

* Added new fields to Press page (#1463)

* Resource external link no longer required (#1464)

* Resource external link no longer required

* Made link text not required

* Improve handling pf privacy policy and encoded slugs (#1466)

* Fixed resource link still being required (#1467)

* Fixed resource link still being required

* Fixed menu change

* Removed validation errors on resources

* Added About field

* Removed locked-requirements.txt to prevent dependabot PRs

* Add K12 and Research CTAs to home page (#1470)

* readd SF name/abbr to book detail (#1472)

* Tweaks to improve blog search results (#1471)

* Tweaks to improve blog search results

* Added subjects, categories and collections to search

* Order by title (#1473)

* Added write for us and editorial calendar to sitemap (#1474)

* Added footer fields to news index page (#1475)

* Modified errata query to prefetch book, removed review totals from Partners (#1476)

* Modified errata query to prefetch book, removed review totals from Partners

* Fixed query

* undo last commit

* Import working for non-book pages (#1478)

* Handle exporting non-book pages

* Changed content type check

* improvements for non-book pages

* Import working for non-book pages

* added missing function and removed unused function

* Removed print statements

* Removed openstax logo fields from ally logos page (#1481)

* Added book_uuid field and copied cnx_id value into it (#1482)

* Only return live blog posts when querying by subject, collection or content type (#1483)

* Updated packages (#1484)

* Improved blog search results (#1486)

* Fixed n+1 query issue on news search (#1487)

* Webinars page (#1488)

* Added collections and search to webinar page

* Fixed search and search url

* Removed print stmts and added test for search

* Removed unneeded import

* Removed websearch parameter

* Added tests for 2 pages

* changed name of webinar search API

* K12 sitemap fix (#1490)

* Sitemap fix for k12 and new subjects page

* fixed k12 sitemap

* New subjects page is in sitemap if flag is set to display

* Now deals with -books on subject slugs correctly

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Michael Volo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dmoreno <[email protected]>
Co-authored-by: Chris Bendel <[email protected]>
Co-authored-by: dmoreno27 <[email protected]>
Co-authored-by: Devynn Moreno <[email protected]>
Co-authored-by: Colby <[email protected]>
Co-authored-by: Devynn Moreno <[email protected]>
Co-authored-by: Thomas Woodward <[email protected]>
  • Loading branch information
10 people authored Aug 29, 2023
1 parent 8f535a2 commit 20935c1
Show file tree
Hide file tree
Showing 20 changed files with 437 additions and 53 deletions.
2 changes: 1 addition & 1 deletion news/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def search(request):
found_entries = NewsArticle.objects.annotate(
rank=SearchRank(vector, query),
search=vector,
).filter(rank__gte=0.3, live=True).order_by('-date', 'rank')
).filter(rank__gte=0.3,live=True).order_by('-date', 'rank')


if ('collection' in request.GET) and request.GET['collection'].strip():
Expand Down
37 changes: 29 additions & 8 deletions openstax/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
from django.template.response import TemplateResponse
from django.http import HttpResponse
from urllib.parse import unquote
from books.models import Book

from api.models import FeatureFlag
from books.models import Book, BookIndex
from openstax.functions import build_image_url
from news.models import NewsArticle
from pages.models import HomePage, Supporters, GeneralPage, PrivacyPolicy
from pages.models import HomePage, Supporters, GeneralPage, PrivacyPolicy, K12Subject, Subject, Subjects


class HttpSmartRedirectResponse(HttpResponsePermanentRedirect):
Expand Down Expand Up @@ -91,6 +93,19 @@ def __call__(self, request, *args, **kwargs):
page = NewsArticle.objects.filter(slug=page_slug)
elif '/privacy' in url_path:
page = PrivacyPolicy.objects.filter(slug='privacy-policy')
elif '/k12' in url_path:
page = K12Subject.objects.filter(slug='k12-' + page_slug)
elif '/subjects' in url_path:
flag = FeatureFlag.objects.filter(name='new_subjects')
if flag[0].feature_active:
if page_slug == 'subjects':
page_slug = 'new-subjects'
page = Subjects.objects.filter(slug=page_slug)
else:
page = Subject.objects.filter(slug=page_slug+'-books')
else:
page_slug = 'subjects'
page = BookIndex.objects.filter(slug=page_slug)
else:
page = self.page_by_slug(page_slug)

Expand All @@ -103,28 +118,34 @@ def __call__(self, request, *args, **kwargs):
def build_template(self, page, page_url):
image_url = self.image_url(page.promote_image)
template = '<!DOCTYPE html> <html> <head> <meta charset="utf-8">\n'
template += ' <title>' + str(page.seo_title) + '</title>\n'
template += ' <title>' + str(page.title) + '</title>\n'
template += ' <meta name="description" content="{}" >\n'.format(page.search_description)
template += ' <link rel="canonical" href="{}" />\n'.format(page_url)
template += ' <meta property="og:url" content="{}" />\n'.format(page_url)
template += ' <meta property="og:type" content="article" />\n'
template += ' <meta property="og:title" content="{}" />\n'.format(page.seo_title)
template += ' <meta property="og:title" content="{}" />\n'.format(page.title)
template += ' <meta property="og:description" content="{}" />\n'.format(page.search_description)
template += ' <meta property="og:image" content="{}" />\n'.format(image_url)
template += ' <meta property="og:image:alt" content="{}" />\n'.format(page.seo_title)
template += ' <meta property="og:image:alt" content="{}" />\n'.format(page.title)
template += ' <meta name="twitter:card" content="summary_large_image">\n'
template += ' <meta name="twitter:site" content="@OpenStax">\n'
template += ' <meta name="twitter:title" content="{}">\n'.format(page.seo_title)
template += ' <meta name="twitter:title" content="{}">\n'.format(page.title)
template += ' <meta name="twitter:description" content="{}">\n'.format(page.search_description)
template += ' <meta name="twitter:image" content="{}">\n'.format(image_url)
template += ' <meta name="twitter:image:alt" content="OpenStax">\n'

template += '</head><body></body></html>'
return template

def redirect_path_found(self, url_path):
if '/blog/' in url_path or '/details/books/' in url_path or '/foundation' in url_path or '/privacy' in url_path or '' == url_path:
if '/blog/' in url_path or '/details/books/' in url_path or '/foundation' in url_path or '/privacy' in url_path or '/subjects' in url_path or '' == url_path:
return True
elif '/k12' in url_path:
last_slash = url_path.rfind('/')
k12_index = url_path.rfind('k12')
if last_slash < k12_index:
return False
else:
return True
else:
return False

Expand Down
1 change: 1 addition & 0 deletions pages/custom_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ def get_api_representation(self, value, context=None):
'cover': build_document_url(value['cover'].url),
'title': value['title'],
}

21 changes: 21 additions & 0 deletions pages/migrations/0082_remove_webinarpage_description_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.0.8 on 2023-07-27 14:45

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('pages', '0081_remove_allylogos_openstax_logos_and_more'),
]

operations = [
migrations.RemoveField(
model_name='webinarpage',
name='description',
),
migrations.RemoveField(
model_name='webinarpage',
name='hero_image',
),
]
61 changes: 34 additions & 27 deletions pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from wagtail.api import APIField
from wagtail.models import Site

from api.models import FeatureFlag
from openstax.functions import build_image_url, build_document_url
from books.models import Book, SubjectBooks, BookFacultyResources, BookStudentResources
from webinars.models import Webinar
Expand Down Expand Up @@ -581,7 +582,7 @@ class K12MainPage(Page):
def get_sitemap_urls(self, request=None):
return [
{
'location': '{}/k12/{}'.format(Site.find_for_request(request).root_url, self.slug),
'location': '{}/k12'.format(Site.find_for_request(request).root_url),
'lastmod': (self.last_published_at or self.latest_revision_created_at),
}
]
Expand Down Expand Up @@ -758,20 +759,6 @@ def get_sitemap_urls(self, request=None):
'lastmod': (self.last_published_at or self.latest_revision_created_at),
}
]
# elif self.slug == 'write-for-us':
# return [
# {
# 'location': '{}/{}'.format(Site.find_for_request(request).root_url, self.slug),
# 'lastmod': (self.last_published_at or self.latest_revision_created_at),
# }
# ]
# elif self.slug == 'editorial-calendar':
# return [
# {
# 'location': '{}/{}'.format(Site.find_for_request(request).root_url, self.slug),
# 'lastmod': (self.last_published_at or self.latest_revision_created_at),
# }
# ]
else:
return []

Expand Down Expand Up @@ -2241,27 +2228,15 @@ def partner_type_choices():

class WebinarPage(Page):
heading = models.CharField(max_length=255)
description = models.TextField()
hero_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)

content_panels = [
FieldPanel('title', classname='full title', help_text="Internal name for page."),
FieldPanel('heading'),
FieldPanel('description'),
FieldPanel('hero_image')
]

api_fields = [
APIField('title'),
APIField('heading'),
APIField('description'),
APIField('hero_image'),
APIField('slug'),
APIField('seo_title'),
APIField('search_description'),
Expand Down Expand Up @@ -2609,6 +2584,18 @@ def subjects(self):

return subject_list

def get_sitemap_urls(self, request=None):
flag = FeatureFlag.objects.filter(name='new_subjects')
if flag[0].feature_active:
return [
{
'location': '{}/subjects'.format(Site.find_for_request(request).root_url),
'lastmod': (self.last_published_at or self.latest_revision_created_at),
}
]
else:
return []

api_fields = [
APIField('heading'),
APIField('description'),
Expand Down Expand Up @@ -2721,6 +2708,18 @@ class Subject(Page):
related_name='+'
)

def get_sitemap_urls(self, request=None):
flag = FeatureFlag.objects.filter(name='new_subjects')
if flag[0].feature_active:
return [
{
'location': '{}/subjects/{}'.format(Site.find_for_request(request).root_url, self.slug[0:-6]),
'lastmod': (self.last_published_at or self.latest_revision_created_at),
}
]
else:
return []

@property
def selected_subject(self):
return self.subject.all()
Expand Down Expand Up @@ -3029,6 +3028,14 @@ def faculty_resource_headers(self):
})
return faculty_resource_data

def get_sitemap_urls(self, request=None):
return [
{
'location': '{}/k12/{}'.format(Site.find_for_request(request).root_url, self.slug[4:]),
'lastmod': (self.last_published_at or self.latest_revision_created_at),
}
]

api_fields = [
APIField('subheader'),
APIField('subject_intro'),
Expand Down
8 changes: 4 additions & 4 deletions pages/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<html>
<head>

<title>{{ page.seo_title }}</title>
<title>{{ page.title }}</title>
<meta name="description" content="{{ page.search_description }}">
<link rel="canonical" href="{{page.get_full_url}}" />
<meta http-equiv="refresh">

<meta property="og:url" content="{{page.get_full_url}}" />
<meta property="og:type" content="article" />
<meta property="og:title" content="{{ page.seo_title }}" />
<meta property="og:title" content="{{ page.title }}" />
<meta property="og:description" content="{{ page.search_description }}" />
<meta property="og:image" content="{{ promote_image.url }}" />
<meta property="og:image:alt" content="OpenStax: {{ page.seo_title }}" />
<meta property="og:image:alt" content="OpenStax: {{ page.title }}" />

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@OpenStax">
<meta name="twitter:title" content="{{ page.seo_title }}">
<meta name="twitter:title" content="{{ page.title }}">
<meta name="twitter:description" content="{{ page.search_description }}">
<meta name="twitter:image" content="{{ promote_image.url }}">
<meta name="twitter:image:alt" content="OpenStax">
Expand Down
62 changes: 62 additions & 0 deletions pages/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from django.test import TestCase, Client
from django.core.management import call_command
from wagtail.test.utils import WagtailTestUtils, WagtailPageTests
Expand Down Expand Up @@ -145,6 +147,66 @@ def test_can_create_team_page(self):

self.assertEqual(retrieved_page.title, "Team Page")

def test_can_create_about_us_page(self):
about_us = AboutUsPage(title='About Us',
who_heading='About Us',
who_paragraph='Who paragraph',
what_heading='what heading',
what_paragraph='what paragraph',
where_heading='where heading',
where_paragraph='where paragraph',
)
self.homepage.add_child(instance=about_us)
self.assertCanCreateAt(HomePage, AboutUsPage)

retrieved_page = Page.objects.get(id=about_us.id)
self.assertEqual(retrieved_page.title, "About Us")

def test_can_create_k12_main_page(self):
k12_page = K12MainPage(title='K12 Main Page',
banner_headline='banner heading',
banner_description='banner description',
subject_list_default='subject list default',
highlights_header='highlights header',
subject_library_header='subjects library header',
subject_library_description='subjects library description',
)
self.homepage.add_child(instance=k12_page)
self.assertCanCreateAt(HomePage, K12MainPage)

retrieved_page = Page.objects.get(id=k12_page.id)
self.assertEqual(retrieved_page.title, "K12 Main Page")

def test_can_create_contact_us_page(self):
contact_us_page = ContactUs(title='Contact Us',
tagline='this is a tagline',
mailing_header='Mailing header',
mailing_address='123 Street, East SomeTown, Tx',
customer_service='How can I help you?',
)
self.homepage.add_child(instance=contact_us_page)
self.assertCanCreateAt(HomePage, ContactUs)

retrieved_page = Page.objects.get(id=contact_us_page.id)
self.assertEqual(retrieved_page.title, "Contact Us")

def test_can_create_general_page(self):
general_page = GeneralPage(title='General Page',
body=json.dumps(
[{"id": "ae6f048b-6eb5-42e7-844f-cfcd459f81b5", "type": "heading",
"value": "General Page"},
{"id": "a21bcbd4-fec4-432e-bf06-966d739c6de9", "type": "paragraph",
"value": "<p data-block-key=\"wr6bg\">This is a test of a general page.</p><p data-block-key=\"d57h\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"},
{"id": "4d339739-131c-4547-954b-0787afdc4914", "type": "tagline",
"value": "This is a test"}]
),
)
self.homepage.add_child(instance=general_page)
self.assertCanCreateAt(HomePage, GeneralPage)

retrieved_page = Page.objects.get(id=general_page.id)
self.assertEqual(retrieved_page.title, "General Page")


class ErrataListTest(WagtailPageTests):

Expand Down
32 changes: 32 additions & 0 deletions snippets/migrations/0028_webinarcollection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.0.8 on 2023-07-26 19:47

from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0069_log_entry_jsonfield'),
('wagtailimages', '0024_index_image_file_hash'),
('snippets', '0027_nowebinarmessage'),
]

operations = [
migrations.CreateModel(
name='WebinarCollection',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('translation_key', models.UUIDField(default=uuid.uuid4, editable=False)),
('name', models.CharField(blank=True, max_length=255, null=True)),
('description', models.TextField(default='')),
('image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
('locale', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale')),
],
options={
'abstract': False,
'unique_together': {('translation_key', 'locale')},
},
),
]
Loading

0 comments on commit 20935c1

Please sign in to comment.