Skip to content

Commit

Permalink
Release dec 2022 merge into main (#1380)
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]>

* Code to set visible_on_website to true on update

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>
  • Loading branch information
3 people authored Dec 14, 2022
1 parent 7d89811 commit c97731b
Show file tree
Hide file tree
Showing 18 changed files with 603 additions and 1,275 deletions.
13 changes: 0 additions & 13 deletions backup/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ class BookIndex(Page):

@property
def books(self):
books = Book.objects.live().filter(locale=self.locale).order_by('path')
books = Book.objects.live().filter(locale=self.locale).order_by('title')
book_data = []
for book in books:
has_faculty_resources = BookFacultyResources.objects.filter(book_faculty_resource=book).exists()
Expand Down
1,576 changes: 395 additions & 1,181 deletions fixtures/vcr_cassettes/partners.yaml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions global_settings/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

def clear_cloudfront_on_page_publish(sender, **kwargs):
invalidate_cloudfront_caches('v2/pages')
# clear general pages
invalidate_cloudfront_caches('spike')


page_published.connect(clear_cloudfront_on_page_publish)
Expand All @@ -18,6 +20,8 @@ def clear_cloudfront_on_page_publish(sender, **kwargs):
@receiver(post_save, sender=StickyNote)
def clear_cloudfront_on_sticky_save(sender, **kwargs):
invalidate_cloudfront_caches('sticky')
# this should not be needed, but we had an issue with it not clearing
invalidate_cloudfront_caches('sticky/')


@receiver(post_save, sender=Footer)
Expand Down
12 changes: 0 additions & 12 deletions openstax/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@
WSGI_APPLICATION = 'openstax.wsgi.application'

INSTALLED_APPS = [
'scout_apm.django',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
Expand All @@ -188,7 +187,6 @@
'django.contrib.postgres',
'django.contrib.admin',
'django.contrib.sitemaps',
'dbbackup', # django-dbbackup
# contrib
'compressor',
'taggit',
Expand Down Expand Up @@ -245,7 +243,6 @@

CRONJOBS = [
('0 2 * * *', 'django.core.management.call_command', ['delete_resource_downloads']),
('0 4 * * *', 'django.core.management.call_command', ['sync_reviews']),
('0 6 * * *', 'django.core.management.call_command', ['update_resource_downloads']),
('0 8 * * *', 'django.core.management.call_command', ['update_schools_and_mapbox']),
('0 9 * * *', 'django.core.management.call_command', ['update_opportunities']),
Expand Down Expand Up @@ -416,11 +413,6 @@

WAGTAILIMAGES_MAX_UPLOAD_SIZE = 2 * 1024 * 1024 # 2MB

# Scout
SCOUT_KEY = os.getenv('SCOUT_KEY', '')
SCOUT_MONITOR = bool(SCOUT_KEY)
SCOUT_NAME = os.getenv('SCOUT_NAME', f"openstax-cms ({ENVIRONMENT})")

# Sentry
sentry_sdk.init(
dsn=os.getenv('SENTRY_DSN'),
Expand All @@ -436,10 +428,6 @@
EVENTBRITE_API_PRIVATE_TOKEN = os.getenv('EVENTBRITE_API_PRIVATE_TOKEN', '')
EVENTBRITE_API_PUBLIC_TOKEN = os.getenv('EVENTBRITE_API_PUBLIC_TOKEN', '')

# djago-dbbackup
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
DBBACKUP_STORAGE_OPTIONS = {'location': 'backup/'}

# to override any of the above settings use a local.py file in this directory
try:
from .local import *
Expand Down
2 changes: 0 additions & 2 deletions openstax/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#CNX URL for viewing book online
CNX_URL = 'https://staging.cnx.org/'

SCOUT_MONITOR = False

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
Expand Down
7 changes: 7 additions & 0 deletions pages/custom_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,10 @@ class InfoBoxBlock(blocks.StructBlock):
class Meta:
icon = 'placeholder'


class AllyLogoBlock(blocks.StructBlock):
image = APIImageChooserBlock()

class Meta:
icon = 'placeholder'

41 changes: 41 additions & 0 deletions pages/migrations/0066_allylogos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 3.2.5 on 2022-10-17 19:30

from django.db import migrations, models
import django.db.models.deletion
import pages.custom_blocks
import wagtail.core.blocks
import wagtail.core.fields


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0066_collection_management_permissions'),
('wagtailimages', '0023_add_choose_permissions'),
('pages', '0065_auto_20220823_1112'),
]

operations = [
migrations.CreateModel(
name='AllyLogos',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('heading', models.CharField(max_length=255)),
('description', wagtail.core.fields.RichTextField()),
('ally_logos_heading', models.CharField(max_length=255)),
('ally_logos_description', wagtail.core.fields.RichTextField()),
('ally_logos', wagtail.core.fields.StreamField([('ally_logo', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', pages.custom_blocks.APIImageChooserBlock())])))])),
('openstax_logos_heading', models.CharField(max_length=255)),
('openstax_logos_description', wagtail.core.fields.RichTextField()),
('openstax_logos', wagtail.core.fields.StreamField([('openstax_logo', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', pages.custom_blocks.APIImageChooserBlock())])))])),
('book_ally_logos_heading', models.CharField(max_length=255)),
('book_ally_logos_description', wagtail.core.fields.RichTextField()),
('book_ally_logos', wagtail.core.fields.StreamField([('book_ally_logo', wagtail.core.blocks.ListBlock(wagtail.core.blocks.StructBlock([('image', pages.custom_blocks.APIImageChooserBlock())])))])),
('promote_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
74 changes: 73 additions & 1 deletion pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
StoryBlock, \
TutorAdBlock, \
AboutOpenStaxBlock, \
InfoBoxBlock
InfoBoxBlock, \
AllyLogoBlock

from .custom_fields import \
Institutions, \
Expand Down Expand Up @@ -446,6 +447,7 @@ class Meta:
'pages.TutorMarketing',
'pages.Subjects',
'pages.FormHeadings',
'pages.AllyLogos',
'books.BookIndex',
'news.NewsIndex',
'news.PressIndex'
Expand Down Expand Up @@ -2596,3 +2598,73 @@ class FormHeadings(Page):

parent_page_types = ['pages.HomePage']
max_count = 1


class AllyLogos(Page):
heading = models.CharField(max_length=255)
description = RichTextField()
ally_logos_heading = models.CharField(max_length=255)
ally_logos_description = RichTextField()
ally_logos = StreamField([
('ally_logo', blocks.ListBlock(AllyLogoBlock())),
])
openstax_logos_heading = models.CharField(max_length=255)
openstax_logos_description = RichTextField()
openstax_logos = StreamField([
('openstax_logo', blocks.ListBlock(AllyLogoBlock())),
])
book_ally_logos_heading = models.CharField(max_length=255)
book_ally_logos_description = RichTextField()
book_ally_logos = StreamField([
('book_ally_logo', blocks.ListBlock(AllyLogoBlock())),
])

promote_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)

content_panels = [
FieldPanel('title'),
FieldPanel('heading'),
FieldPanel('description'),
FieldPanel('ally_logos_heading'),
FieldPanel('ally_logos_description'),
StreamFieldPanel('ally_logos'),
FieldPanel('openstax_logos_heading'),
FieldPanel('openstax_logos_description'),
StreamFieldPanel('openstax_logos'),
FieldPanel('book_ally_logos_heading'),
FieldPanel('book_ally_logos_description'),
StreamFieldPanel('book_ally_logos')
]

api_fields = [
APIField('heading'),
APIField('description'),
APIField('ally_logos_heading'),
APIField('ally_logos_description'),
APIField('ally_logos'),
APIField('openstax_logos_heading'),
APIField('openstax_logos_description'),
APIField('openstax_logos'),
APIField('book_ally_logos_heading'),
APIField('book_ally_logos_description'),
APIField('book_ally_logos'),
]

promote_panels = [
FieldPanel('slug'),
FieldPanel('seo_title'),
FieldPanel('search_description'),
ImageChooserPanel('promote_image')
]

template = 'page.html'

parent_page_types = ['pages.HomePage']


6 changes: 4 additions & 2 deletions pages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
TutorMarketing,
Subjects,
Subject,
FormHeadings)
FormHeadings,
AllyLogos)
from news.models import NewsIndex, PressIndex
from books.models import BookIndex
from shared.test_utilities import assertPathDoesNotRedirectToTrailingSlash, mock_user_login
Expand Down Expand Up @@ -93,7 +94,8 @@ def test_allowed_subpages(self):
LLPHPage,
TutorMarketing,
Subjects,
FormHeadings
FormHeadings,
AllyLogos
})

class PageTests(WagtailPageTests):
Expand Down
2 changes: 0 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ django-rest-auth==0.9.5
django-reversion==5.0.0
django-ses==3.0.1
django-storages==1.12.3
django-dbbackup==4.0.2
future==0.18.2
html2text==2020.1.16 # used in news feed
jsonfield==3.1.0
mapbox==0.18.0
psycopg2>=2.9.2
pycryptodome==3.14.1 # for using the SSO cookie from accounts
PyJWE==1.0.0
scout-apm
sentry-sdk
simple_salesforce==1.11.6
social-auth-app-django==5.0.0
Expand Down
7 changes: 1 addition & 6 deletions requirements/locked-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ rich-click==1.4
rich==12.4.1
commonmark==0.9.1
Pygments==2.12.0
scout-apm==2.25.1
asgiref==3.5.2
psutil==5.9.0
urllib3==1.26.9
wrapt==1.14.1
selenium==4.1.5
trio==0.20.0
async-generator==1.10
Expand Down Expand Up @@ -275,7 +270,7 @@ wagtail==2.16.2
l18n==2021.3
pytz==2022.1
six==1.16.0
Pillow==9.1.1
Pillow==9.3.0
requests==2.27.1
certifi==2021.10.8
charset-normalizer==2.0.12
Expand Down
2 changes: 1 addition & 1 deletion salesforce/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class PartnerReviewAdmin(admin.ModelAdmin):
'partner',
'status')
search_fields = ['review_salesforce_id', 'submitted_by_name', 'submitted_by_account_uuid', ]
actions = ['sync_with_salesforce', 'populate_review_faculty_status']
actions = ['populate_review_faculty_status']
readonly_fields = ('partner',
'review_salesforce_id',
'rating',
Expand Down
3 changes: 2 additions & 1 deletion salesforce/management/commands/update_partners.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def handle(self, *args, **options):
"International__c, " \
"Partnership_Level__c, " \
"Equity_Rating__c " \
"FROM Partner__c"
"FROM Partner__c WHERE Partner_Status__c = 'Current Partner' AND RecordType.Name = 'Child'"
response = sf.query_all(query)
sf_marketplace_partners = response['records']

Expand Down Expand Up @@ -239,6 +239,7 @@ def handle(self, *args, **options):
p.international=self.str2bool(partner['International__c'])
p.partnership_level=partner['Partnership_Level__c']
p.equity_rating = partner['Equity_Rating__c']
p.visible_on_website = True
p.save()

if created:
Expand Down
15 changes: 8 additions & 7 deletions salesforce/management/commands/update_resource_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ def handle(self, *args, **options):
with Salesforce() as sf:
new_data = []
for nrd in new_resource_downloads:
data_dict_item = {'Contact__c': nrd.contact_id,
'Last_accessed__c': nrd.last_access.strftime('%Y-%m-%d'),
'Name': nrd.resource_name,
'Book__c': nrd.book.salesforce_abbreviation,
'Book_Format__c': nrd.book_format,
'Accounts_UUID__c': str(nrd.account_uuid)}
new_data.append(data_dict_item)
if nrd.book.salesforce_abbreviation:
data_dict_item = {'Contact__c': nrd.contact_id,
'Last_accessed__c': nrd.last_access.strftime('%Y-%m-%d'),
'Name': nrd.resource_name,
'Book__c': nrd.book.salesforce_abbreviation,
'Book_Format__c': nrd.book_format,
'Accounts_UUID__c': str(nrd.account_uuid)}
new_data.append(data_dict_item)

new_results = sf.bulk.Resource__c.insert(new_data)

Expand Down
18 changes: 18 additions & 0 deletions salesforce/migrations/0104_alter_partner_visible_on_website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.16 on 2022-12-02 20:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('salesforce', '0103_auto_20220516_1045'),
]

operations = [
migrations.AlterField(
model_name='partner',
name='visible_on_website',
field=models.BooleanField(default=True),
),
]
Loading

0 comments on commit c97731b

Please sign in to comment.