Giter Club home page Giter Club logo

openstax-cms's Introduction

OpenStax
codecov CI

OpenStax CMS

Built using Wagtail CMS on top of Django Framework. All installation instructions assume you already have Homebrew installed. If you are not running on MacOSX or a Linux distribution, see the hyperlinks for dependencies.

Dependencies

brew install postgresql
brew install python3

Installation

Verify you have Python ≥ 3.11 installed:

python --version
python3 --version

Start PostgreSQL:

brew services start postgresql

This will also make sure PostgreSQL service starts on boot.

Create a database (this is also a shell script), which is named as oscms_prodcms. However, it can be renamed as long as the change is reflected on the appropriate field in openstax/settings/base.py:

createdb oscms_prodcms

Now we can install the repository. Run the following commands line by line:

git clone https://github.com/openstax/openstax-cms
cd openstax-cms/
pip3 install -r requirements/dev.txt

After all the modules in requirements are installed, run the migration script:

python3 manage.py migrate

Now, create a superuser. Run the following command and then proceed with the instructions:

python3 manage.py createsuperuser

Finally, start the server:

python3 manage.py runserver

Testing

To test OpenStax CMS on a local device, you need to overwrite some settings. This can be streamlined by introducing local.py in openstax/settings/. Any changes on or additions to local.py will overwrite settings. Make copy of local.py.example and rename it to local.py: Alternatively, and maybe more conveniently, use a .env file in the project root to set environmental variables.

cd openstax/settings/
cp local.py.example local.py

Run the tests:

python3 manage.py test --settings=openstax.settings.test

SQLite Support

SQLite is supported as an alternative to PostgreSQL. In order to switch to SQLite, change the DATABASES setting in openstax/settings/base.py to use 'django.db.backends.sqlite3', and set NAME to be the full path of your database file, as you would with a regular Django project.

Docker

To run the CMS in Docker containers:

docker-compose up

The CMS code directory from your host machine is mounted in the app container at /code. To drop into a bash terminal in the app container:

docker-compose exec -e DJANGO_SETTINGS_MODULE=openstax.settings.docker app bash

This command has been wrapped in a tiny script:

./docker/bash

From within the bash shell, you can run the tests:

python3 manage.py test --keepdb

or pound on a specific test:

python3 manage.py test --keepdb books.tests.BookTests.test_can_create_book

The --keepdb option reuses the test database from run to run so you don't have to wait for it to recreate the database and run the migrations every time.

To debug tests, you can insert the normal import pdb; pdb.set_trace() lines in your code and test runs from the bash environment will show you the debugger.

API Endpoints

View the Wiki Page for the list of all available API endpoints and their descriptions.

Documentation

openstax-cms's People

Contributors

berkalpyakici avatar chrisbendel avatar cnuber avatar dak avatar dantemss avatar darkprincefrost avatar dependabot[bot] avatar dmoreno27 avatar edwoodward avatar jpslav avatar mwvolo avatar reedstrm avatar royejohnson avatar therealmarv avatar tomwoodward avatar yblock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openstax-cms's Issues

Add URL for Tech Scout form to CMS

Description

The new Tech Scout form does not currently load any data from the CMS. It will need a form endpoint URL from somewhere. I don't know whether this justifies making a page for it, or adding a snippet.

Also added fields for adoption and interest form URLs

Notes

The current testing endpoint is http://www2.openstax.org/l/218812/2021-10-06/t5tr2x

Acceptance Criteria

Fields are editable in the CMS: https://dev.openstax.org/django-admin/salesforce/salesforceforms
Fields are available via API: https://dev.openstax.org/apps/cms/api/salesforce/forms

Try setting up Wagtail to auto-convert images to WEBP

Description

Wagtail has the ability to auto-convert uploaded images. By default, it was set up to convert WEBP to PNG. We changed that. WEBP is the preferred format. If possible, configure Wagtail to convert uploaded PNG and JPG files to WEBP.

This should help with the problem we have of very large PNGs and (sometimes) JPGs.

Book details test

Unit test needed to make sure that book details are properly being served from cnx-archive's api. See PR #70

Handle review that does not have a partner

Description

An error happened on production when a review did not have a partner and the sync_reviews command failed because of it. The error happened when getting the partner_sf_account_id from the review partner object. The error was reported in Sentry

Acceptance Testing

Reviews without a Partner will be skipped and deleted when preparing data to be sent to Salesforce. This is nearly impossible to test.

Remove unused pages from Pages model

Description

The following pages are no longer is use as far as I can tell and could be removed from the Pages model.

  • Higher Education - slug: higher-education
  • Give - slug: give
  • AP - slug: ap
  • Support - slug: support
  • Comp Copy - slug: comp-copy
  • Adopt Form - slug: adoption-form
  • Interest Form - slug: interest-form
  • Hero Journey Page - not on production
  • Math Quiz Page - slug: quiz-results
  • LLPH Page - slug: llph
  • Tutor Landing - not on production

This list needs to be verified by others. I could be very wrong.

Acceptance Test

Before deployment of code, delete these pages from the CMS. Failing to do so will make deleting them difficult after code release

  • Higher Education
  • AP
  • Support
  • Comp Copy
  • Adopt Form
  • Interest Form
  • Hero Journey Page
  • Tutor Landing

These pages are no longer available for creation in the CMS

Add form endpoint URL to Adoption and Interest form page data

Description

Adoption and Interest forms will be submitted to Pardot for processing, rather than going to Salesforce. To allow for different endpoints in Dev, Staging, and Prod, the URLs should be stored in the page data.

Acceptance Criteria

The page data includes endpoint_url for each page.

Notes

The testing address for submitting Adoptions is
https://go.demo.pardot.com/l/308222/2021-09-17/33n
For Interest forms:
https://go.demo.pardot.com/l/308222/2021-09-15/2xv

(Notes from Michael)
We currently have an admin and endpoint for salesforce forms. This should be reused or removed depending on the implementation chosen.

admin: https://cms-dev.openstax.org/django-admin/salesforce/salesforceforms/1/change/
api endpoint: https://cms-dev.openstax.org/apps/cms/api/salesforce/forms

Also, WebToLead is being used for Testimonials and WebToCase is being used for Comp Copies (by string replacing the above URL). It'd be good to clarify what these URLs are being used for in the CMS during this work.

Relevant Slack convo: https://openstax.slack.com/archives/C69BU01RC/p1634221017336500

Upgrade to Wagtail 2.15.x

Description

Wagtail has release a new version.

Here are the release notes: https://docs.wagtail.io/en/stable/releases/2.15.html
Be sure to look at the upgrade considerations!

Be sure to upgrade to the latest 2.15.x version (as of now, it's 2.15.1)

Acceptance Criteria

  • Wagtail is upgraded

Acceptance Tests

derive these from "Acceptance Criteria" during "Design" phase

title: template

GIVEN something
AND something else
WHEN something
AND something else
THEN something
AND something else

Approvals

1A-DEFINE

  • PDM approves UX LoFi Design

1C-DESIGN

  • PDM approves UX HiFi Design

4A-UX REV

  • UX approves change
  • PDM approves change

Process

Work Management for BIT

Subject search for blog not working on dev

Description

The data structure of the json stored for subjects on dev is different than it was during local development. The original structure was
[{'type': 'subject', 'value': [{'subject': 4}], 'id': '98a80440-8b7c-4857-89ee-7bebbc87b904'}]

The structure on dev is
[{'type': 'subject', 'value': [{'type': 'item', 'value': {'subject': 1, 'featured': False}, 'id': '78e7e9c1-487f-42bb-b960-4a2901aa3150'}]

The code needs to work with the structure on dev. Blog Collections and content types have the same issue.

Acceptance Test

Search feature not functioning

The search field on the main page of wagtail and the search feature to select snippets on pages (and maybe others) is not currently functioning.

Screen Shot 2022-08-04 at 10.53.38 AM.png

Modify Subjects page BE

Description

To construct the context menu for the books on the Subjects page, the front end will need the book cover color and whether there are instructor resources and student resources. Ideally, three fields would be added to the pages/subjects data:

cover_color
has_faculty_resources
has_student_resources

Logging Configuration

Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/config.py", line 557, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/lib/python3.4/logging/config.py", line 725, in configure_handler
    result = factory(**kwargs)
  File "/usr/lib/python3.4/logging/__init__.py", line 1006, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.4/logging/__init__.py", line 1030, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/var/www/openstax-cms/server.log'

Current base logging configuration is not compatible with current dev environment. Quick fix: chmod 775 /var/www/openstax-cms/server.log.

Salesforce Book name in CMS

@denvergreene commented on Thu Jul 21 2022

Description

Pull book names from salesforce for the internal name (rather than setting it as free text) in the CMS.

Also maybe consider changing the name of the field in the CMS INTERNAL SALESFORCE NAME to something like INTERNAL SALESFORCE NAME (no edition numbers)

Proposed solution

  • Replace existing fields with Salesforce ID (optional)
  • Pull information from Salesforce if field is populated

Acceptance Criteria

  • What should be tested to make sure this is working?

Docker Image not work properly

docker-compose -f docker-compose.override.yml up --build
Faild build on pip install
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yi921t1y/psycopg2/setup.py'"'"'; file='"'"'/tmp/pip-install-yi921t1y/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-yi921t1y/psycopg2/
Complete output (23 lines):
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.

For further information please check the 'doc/src/install.rst' file (also at
<http://initd.org/psycopg/docs/install.html>).

----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Docker version 19.03.1, build 74b1e89

Update robots.txt

Description

Robots.txt appears to live in an S3 bucket. Google is indexing the api/spike pages, so adding the entire URL might help prevent that.

The line
/api/spike

should be updated to
/apps/cms/api/spike

Acceptance Criteria

openstax.org/robots.txt should contain /apps/cms/api/spike

Remove Duplicate Books and improve import-export

@oscryan commented on Mon Nov 29 2021

Description

Attempting to duplicate a book page in wagtail in any environment results in a 500 error, even when both the title and the slug are changed. Discussed in https://openstax.slack.com/archives/C69BU01RC/p1638220616221900

Acceptance Criteria

  • Removed Duplicate Book from book menu since it did not work and was a wrapper around import-export
  • Wagtail Copy menu item on the Book menu can be used to copy a book on the same server
  • Import-Export can be used to copy content to other servers. Code was improved to prevent id collisions and notify user of duplicate slug.

To test, you could do these things

  1. Create a new test page on QA or dev and save it. Go to import-export on that server and export. It will download a zip file
  2. Go to import-export on staging and import your zip file. You will have to choose a parent page such as home or subjects depending on where you made your test page
  3. To test Copy, once your test page is in staging, select Copy from the menu and make a copy. You can delete your test pages once your testing is done.

Blog summary data should include first chunk of body

The CMS data for the summary of blog articles does not include any of the body, so to make all the blurbs, the FE has to pull the article data for every article. The blurb comes from the first chunk of body data. If that data were included in the summary, we could save a lot of calls.

The alt text for the featured image should be in the summary info, too, but I think you may have done that with a recent PR.

##Acceptance

blog page summaries can be constructed without having to pull the individual article pages

Remove Logger reference in check redirects email code

Description

When an exception happens when sending the check redirects email, it is trying to log the exception which does not work. It should be sending the exception to Sentry - Sentry.capture_exception()

Acceptance Testing

Failure to send check redirects email sends exception to Sentry. This is most likely not testable outside of development.

error with load_initial_data

./manage.py load_initial_data

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/base.py", line 657, in handle
    return self.handle_noargs(**options)
  File "/Users/openstax/workspace/openstax-cms/demo/management/commands/load_initial_data.py", line 15, in handle_noargs
    call_command('loaddata', fixture_file, verbosity=0)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 60, in handle
    self.loaddata(fixture_labels)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 90, in loaddata
    self.load_label(fixture_label)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 141, in load_label
    for obj in objects:
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/serializers/json.py", line 84, in Deserializer
    six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/serializers/json.py", line 78, in Deserializer
    for obj in PythonDeserializer(objects, **options):
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/core/serializers/python.py", line 139, in Deserializer
    obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 24, in get_by_natural_key
    ct = self.get(app_label=app_label, model=model)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/openstax/workspace/openstax-cms/venv/lib/python2.7/site-packages/django/db/models/query.py", line 334, in get
    self.model._meta.object_name
django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/openstax/workspace/openstax-cms/openstax/settings/../../demo/fixtures/demo.json': ContentType matching query does not exist.

Retired books showing up on new Subject pages

The list of books is dynamically generated to filter by subject and category. Filtering by book state was missed. Retired books should not be in the list of books

Acceptance test:

Books marked as retired in the CMS are not displayed on Subject pages

API for collaborators?

Hi Openstax team,

I'm working on a team that's looking to use OpenStax content to create curricular modules that are adaptive and whose impact is measurable. We were wondering about whether the API for the CMS is available to third parties looking to use OpenStax data in this way, or alternatively, what the policy is on webscraping?

Thank you!

Switch Django admin to read the SSO cookie vs using OAuth flow

Description

The Django admin is using the oauth flow for authenticating admins in the CMS.
The FE is already using the SSO cookie, so we really don't need to keep the oauth flow for login. This also moves us towards a centralized authentication and authorization system.

Future work will allow more fine grained controls. For now, users will need to be added manually or login and given the correct permissions if they should not have full administrative access on accounts and the CMS.

Acceptance Criteria

  • A user should be able to login to /admin when assigned is_administrator in accounts

Salesforce Initialization Error

Python 3.4 on Ubuntu 15.04 does not like how the subclass is referencing simple_salesforce methods. I've ran this same test on in python 3.5 on OS X 10.11and it passes.

Creating test database for alias 'default'...
E
======================================================================
ERROR: test_faculty_rejected (accounts.tests.SalesforceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vagrant/development/openstax-cms/accounts/tests.py", line 111, in test_faculty_rejected
    status = sf.faculty_status(3)
  File "/home/vagrant/development/openstax-cms/accounts/salesforce.py", line 32, in faculty_status
    contact_info = self.query(sql_command)
  File "/home/vagrant/development/venv/lib/python3.4/site-packages/simple_salesforce/api.py", line 278, in query
    url = self.base_url + 'query/'
  File "/home/vagrant/development/venv/lib/python3.4/site-packages/simple_salesforce/api.py", line 167, in __getattr__
    return SFType(name, self.session_id, self.sf_instance, self.sf_version, self.proxies)

            *
            *
            *

  File "/home/vagrant/development/venv/lib/python3.4/site-packages/simple_salesforce/api.py", line 167, in __getattr__
    return SFType(name, self.session_id, self.sf_instance, self.sf_version, self.proxies)
RuntimeError: maximum recursion depth exceeded while calling a Python object

----------------------------------------------------------------------
Ran 1 test in 0.509s

FAILED (errors=1)
Destroying test database for alias 'default'...

Enhance cache clearing on save to cover more content

Description

Some items in the CMS are not cleared from the cache when saved. Examples are the Feature Flags and the General Pages. The cache should clear these specifically like it is doing for the pages, footer, sticky note and other content.

Acceptance Criteria

The cache should be cleared when these items are saved

  • General pages
  • Feature Flags
  • Others will be added

Upgrade to Wagtail 4.04

We are currently on Wagtail 3.0.3 - the current stable version is 4.2.0. However, Wagtail recommends updates happen on feature release numbers, so we would update to 4.0.4, then 4.1.2 and finally to 4.2.0. Other cards will be created for the other 2 upgrades. This update will include an update to Django 4.1.7 which is the current stable release.

Release notes: https://docs.wagtail.org/en/stable/releases/4.0.html

Be sure to review the release notes for the major versions we missed:
https://docs.wagtail.org/en/stable/releases/4.0.html

Test Fixes

Need to figure out a better configuration for selenium tests, or just remove them all together. Also, travis script is skipping some unittests.

Wagtail Image API Error

detailed_url field is no longer including port number with url. Bug coincides with PR #25. Not a critical error since detail_url field wont be used for api/v1.

detail_url_issue

Backend endpoint for renewal form and popup

Description

The renewal form will be hosted on the FE and will need to pull data in from Salesforce to pre-populate the field.

Proposed solution

An endpoint that replaces the current endpoint used for the renewal popup (and looks at an old School Adoption record type in salesforce) that will display the users current books and student per book count.

This management command should be updated/replaced with something that will pull:

Book__r.Name (or maybe Book__c.Name - try to avoid using Book_Name__c),
Fall_Students__c, Spring_Students__c (most recent number from either of these fields)
WHERE Renewal_Date__c > 6/1/2021 (or maybe > 1 year)
FROM Opportunities

Roy has requested this data to be formatted like the current adoptionJSON that is sent over with the adoption/renewal/signup forms.
Eg.

{"Books":[{"name":"AP Physics","students":"150"},{"name":"Astronomy","students":"300"}]}

There should also be a flag for when someone should see the popup - directing them to the renewal form.
We have two options here - pull all contacts that have Renewal_Eligible__c in the CMS and use that to trigger the popup. Or add this to the users account /api endpoint (preferred... but not sure of timing).
Discuss this before working on the contact grab.

renewalEndpoint setting is: https://www2.openstax.org/l/218812/2022-06-14/zldbyb

Acceptance Criteria

  • User gets popup when they have an opportunity with a confirmed date over 1 year old.
  • Opportunity data on the renewal form is pre-populated with the information from Salesforce

Title missing from Webinar API

Description

The title field was left off in the update to add subjects to Webinar posts. It needs to be added back

Acceptance Testing

The title field is included in the Webinar API (apps/cms/api/webinars?format=json&limit=500)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.