Skip to content

Integrate with simple_theme: add design fields to instance registration form, send e-mail when values change, include ansible variables

Daniel Clemente Laboreo requested to merge clemente/ui-choose-colors into master

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

  1. 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)
  2. Migrate the DB (there are minor migrations)
  3. Start Ocim, Go to http://localhost:5000/registration/
  4. 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
  5. Play with the form, e.g. send it without choosing and image and see it fail
  6. Send the form with all data and your favourite colors
  7. Notice that no extra message about design fields should be shown, only the ones about application status
  8. Notice that no e-mail was sent to us about design changes
  9. Go back to the form
  10. Check that it has your favourite colors and both the images, and they are served from an OVH address
  11. Update colors and images, and save
  12. Check that the new settings are saved, and that on top of the form there's a message saying we will review the changes
  13. Check (in console) that an e-mail was sent with the information of the new colors

Testing 2: provisioning

  1. Create a SWIFT container and assign it to MEDIAFILES_SWIFT_CONTAINER_NAME in .env
  2. Follow the comment above the field logo in registration/models.py in order to upload the default logo and favicon to your SWIFT container
  3. Get yourself a working Ocim that can deploy (good MySQL servers, versions, …) or adjust values later from admin if it fails.
  4. In your .env (or later in the admin if you prefer) choose configuration repository https://github.com/open-craft/configuration/ and configuration commit clemente/ansible-theme, so that simple_theme be used. That branch is near master. You can use ginkgo.1 for the other branches.
  5. 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)
  6. 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.
  7. Check in the instance settings page that the configuration_extra_settings contains SIMPLETHEME_… variables with the colors you choose.
  8. 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)
  9. 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).
  10. 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

  1. 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.

Merge request reports