rca-wagtail-2019

Upgrading guidelines

This document describes aspects of the system which should be given particular attention when upgrading Wagtail or its dependencies.

Wagtail package dependencies

We are maintaining our own forks of Wagtail packages at: https://github.com/torchbox-forks.

The enables any team member to propose a change to a package, we can all work directly on the work branch and submit it to the original author for consideration.

As much as possible, we want to use the official releases available on PyPI for the Wagtail package dependencies. A temporary solution is to fork the package dependency, tag the working branch, and use the tag in the pyproject file.

Check these packages for updates

Last tested for wagtail 6.0 upgrade Comments in the pyproject.toml file may have more detailed information.

It is important to replace the usage of the git tags in the pyproject.toml file with the official release version from PyPI as soon as they become available.

Critical paths

The following areas of functionality are critical paths for the site which don’t have full automated tests and should be checked manually.

1. Account Management

App https://github.com/torchbox/rca-wagtail-2019/tree/master/rca/account_management

The account management app provides the functionality for administrators to create student accounts. Most of this IS covered by unit tests, however it’s still worth doing a test over the UI.

Expected behaviour after submitting the form:

1.2 Student Accounts

App https://github.com/torchbox/rca-wagtail-2019/tree/master/rca/people

Most of the custom logic for students is covered by tests, but again it’s worth testing the UI for any changes between wagtail versions.

Given in 1 (above) a student account is created, the student is able to sign in and edit their own page. There are a number of fields that we don’t want the student to be able to edit. E.G title, collection, page link. There are also fields that we don’t want anyone to be able to edit.

How to test:

2. Enquire to study form

URL: https://www.rca.ac.uk/register-your-interest/ App: https://github.com/torchbox/rca-wagtail-2019/tree/master/rca/enquire_to_study

Whilst there are unit tests for this form, it has 2 integrations so important to test this form. When submitted the form will geneate a submission object at admin/enquire_to_study/enquiryformsubmission/.

How to test:

3. Scholarship

URL: https://www.rca.ac.uk/study/application-process/funding-your-studies/rca-scholarships-and-awards/express-interest/ App: https://github.com/torchbox/rca-wagtail-2019/tree/master/rca/scholarships

Scholarships are added as snippets admin/snippets/scholarships/scholarship/ and are rendered as choices on the form. After submitting the form, a submission object should be created in the admin at admin/scholarships/scholarshipenquiryformsubmission/

How to test:

4. Import to intranet

The RCA intranet supports importing certain page types to the intranet from the main site. This is done by reading the pages API endpoint. Testing this can be a little tricky, but rca-inforca-staging can be used to test it, as that staging site has the env var RCA_CONTENT_API_URL to read from the rca-develompoent site.

How to test:

Other considerations

As well as testing the critical paths, these areas of functionality should be checked:

Student account vs Admin account editor viewing permissions.

  1. The site has custom code to show/hide fields and panels depending on if a StudentPage is viewed by an admin (superuser) or a Student (none superuser).
  2. The site has custom code to show/hide sidebar elements depending on if a Student is viewing the editor vs an admin (superuser).

Users who logged in via SSO automatically gets ‘Editor’ permissions.

  1. When users log in via SSO, they are automatically made editors. This is done via rca.utils.pipeline.make_sso_users_editors and added to the SOCIAL_AUTH_PIPELINE. RCA will manually elevate permissiosn if necessary.

Users who logged in via SSO is redirected to a logout confirmation when they logout.

  1. The site overrides the /admin/logout/ endpoint to redirect users who logged in to /logout/. This is a confirmation screen that users will still need to manually log out of their SSO accounts. This is done with rca.account_management.views.CustomLogoutView and rca.account_management.views.SSOLogoutConfirmationView.
  2. Users who did not log in via SSO should be able to log out without seeing any confirmation screen.

Overridden core Wagtail templates

The following templates are overridden and should be checked for changes when upgrading Wagtail:

Last checked against Wagtail version: 6.1

!!! warning “Technical Debt - to be addressed in Wagtail 6.2”

The deleted `rca/users/templates/wagtailusers/users/list.html` template did two things:

1.  altered the "Admin" (now called "Access level") column to show "Yes" if `user.is_superuser`.
    The default behaviour is to show "Admin" if `user.is_superuser`.
2.  added a "Groups" column after the preceding column, whose contents are ``

Retaining the above functionality in Wagtail 6.1 is not a trivial task.
There's currently an [open PR](https://github.com/wagtail/wagtail/pull/11952) which
seeks to solve this problem, and it may be ready in the 6.2 release.

**Action**: When upgrading to Wagtail 6.2, look out for the above change, and restore
the feature to the way it was before the 6.1 upgrade.

Frontend authentication

This is the path to the Django template which is used to display the “password required” form when a user accesses a private page. For more details, see Wagtail’s Private pages documentation.

WAGTAIL_PASSWORD_REQUIRED_TEMPLATE = "patterns/pages/wagtail/password_required.html"

Python version upgrade

We don’t generally upgrade python versions until a new LTS/Major version is released and has been stable for a while. We prefer to be running a more stable version of python.

If you are upgrading python, you should check the following python version references are updated:

Pyupgrade tool

If you are upgrading python. There is a development tool available to help with modernising the codebase. This is installed as part of the poetry development dependencies.

To run the tool, use the following command:

git ls-files -z -- '*.py' | xargs -0 pyupgrade [python-version-arg]

Where [python-version-arg] is the version of python you are upgrading to.

To view the available version arguments, use the following command:

pyupgrade --help

Pre-commit + Pyupgrade

The pyupgrade tool is run as a step in the pre-commit configuration. This will help you to use the modern syntax as you work on the codebase.

You can manually run the pre-commit checks on *.py files using the following command:

git ls-files -z -- '*.py' | xargs -0 | pre-commit run --files

Django upgrades

If you are upgrading Django. There is a development tool available to help with modernising the codebase. This is installed as part of the poetry development dependencies.

Django upgrade tool

If you are upgrading django. There is a development tool available to help with modernising the codebase. This is installed as part of the poetry development dependencies.

To run the tool, use the following command:

git ls-files -z -- '*.py' | xargs -0 django-upgrade --target-version [django-version-arg]

Where [django-version-arg] is the version of Django you are upgrading to.

Pre-commit + django-upgrade

The django-upgrade tool is run as a step in the pre-commit configuration. This will help you to use the modern syntax as you work on the codebase.

You can manually run the pre-commit checks on *.py files using the following command:

git ls-files -z -- '*.py' | xargs -0 | pre-commit run --files