Integrate with simple_theme: add design fields to instance registration form, send e-mail when values change, include ansible variables
This adds extra fields to Ocim's instance registration form to ask about 4 colors, favicon and logo. Files are uploaded to SWIFT and values are saved in DB. This is done for https://tasks.opencraft.com/browse/OC-3082
In addition, when it detects changes to the saved values, it sends an e-mail to the address configured in the .env. This was part of a future task, but it's already implemented. It sends e-mails only when fields change, not on creation. Note that you can't change the instance name.
In addition, it implements https://tasks.opencraft.com/browse/OC-3259 : it changes the ansible variables to be able to use simple-theme (https://github.com/open-craft/configuration/tree/clemente/ansible-theme), so that the provisioning will use them and the instance will have the desired colors and logo/favicon.
It includes an integration test to check that the spawned instance uses the provided files and colors.
Testing 1: form fields and e-mail
- Add to your .env settings the settings from https://github.com/open-craft/documentation/pull/203 (use your e-mail in VARIABLES_NOTIFICATION_EMAIL, and use all the values which are in comments there; you can use my SWIFT test container too)
- Migrate the DB (there are minor migrations)
- Start Ocim, Go to http://localhost:5000/registration/
- Check that there are 6 design fields, that they show a default color (not only black), and that they're using your browser's color chooser
- Play with the form, e.g. send it without choosing and image and see it fail
- Send the form with all data and your favourite colors
- Notice that no extra message about design fields should be shown, only the ones about application status
- Notice that no e-mail was sent to us about design changes
- Go back to the form
- Check that it has your favourite colors and both the images, and they are served from an OVH address
- Update colors and images, and save
- Check that the new settings are saved, and that on top of the form there's a message saying we will review the changes
- Check (in console) that an e-mail was sent with the information of the new colors
Testing 2: provisioning
- Create a SWIFT container and assign it to MEDIAFILES_SWIFT_CONTAINER_NAME in .env
- Follow the comment above the field
logo
inregistration/models.py
in order to upload the default logo and favicon to your SWIFT container - Get yourself a working Ocim that can deploy (good MySQL servers, versions, …) or adjust values later from admin if it fails.
- In your .env (or later in the admin if you prefer) choose configuration repository
https://github.com/open-craft/configuration/
and configuration commitclemente/ansible-theme
, so that simple_theme be used. That branch is near master. You can use ginkgo.1 for the other branches. - Create a new user through the registration form, and note which colors you choose. Don't upload a logo but do upload your icon (or the other way around) so that one of them stays with the default value (OpenCraft's)
- Validate the e-mail of that user, and let the provisioning start. In the admin check that the configuration version points to the simple-theme branch, and that everything else is correct (e.g. ginkgo.1), if not, modify the instance values and create a new appserver.
- Check in the instance settings page that the
configuration_extra_settings
contains SIMPLETHEME_… variables with the colors you choose. - Wait 2 hours. Check the log, the first time the simple_theme role will be skipped (because of: celery workers), the 2nd one it will collect files (including downloading them from SWIFT)
- Ocim will finish; check the appserver through the authenticated link, you should see the colors and logo/favicon (if you let the default value, you should see OpenCraft's logo/favicon).
- Change the values in the registration form as a user. Notice (from the instances list admin) that the ansible variables in the instance (configuration_extra_settings) have been updated.
Testing 3
- The automated integration test should run in CircleCI (2h). The code already contains (in circle.yml) some references to a SWIFT container used to upload files during the test.