Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating production: new aesthetics #115

Merged
merged 72 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
bf79df4
updating and streamlining docs
acholyn Apr 8, 2024
d3530d9
adding info about how to set up email notifs
acholyn Apr 9, 2024
a7b25e1
small addition
acholyn Apr 9, 2024
34cdfc7
reducing mod_site s3 perms
acholyn Apr 9, 2024
7658314
adding a bit of blurb to distinguish current and setup files
acholyn Apr 11, 2024
1db917b
adding a development SOP
acholyn Apr 15, 2024
512045e
making note of availability zone subnets to prevent faulty launches
acholyn Apr 16, 2024
fbf0f42
updating readme
acholyn May 30, 2024
4384e80
updating css files
acholyn Jun 4, 2024
2bb1e80
new fonts
acholyn Jun 4, 2024
e304ab2
adding iframe for mediacentral
acholyn Jun 4, 2024
8ba5349
updating video previews for mediacentral
acholyn Jun 5, 2024
ec68ee6
card component basis
acholyn Jun 7, 2024
d058f72
tweaks + tidy
acholyn Jun 7, 2024
77a256e
adding card component
acholyn Jun 7, 2024
36b3733
fixing fonts and tags
acholyn Jun 7, 2024
ada3251
using card component
acholyn Jun 7, 2024
af2fff9
adding card css
acholyn Jun 7, 2024
f7c03dc
tweaks to imports and colours
acholyn Jun 7, 2024
878d8ae
hiding file for videos in admin
acholyn Jun 7, 2024
4315b77
tweaks and fixes
acholyn Jun 10, 2024
cf91c99
new header
acholyn Jun 10, 2024
698d643
tweaks to fonts and footer
acholyn Jun 14, 2024
02b9020
footer mobile tweaks + adding logo area placeholder
acholyn Jun 14, 2024
3e9a8ce
abstracting pagination
acholyn Jun 14, 2024
c27bfef
fixing footer sizing to be more consistent and responsive
acholyn Jun 14, 2024
bd445fb
slight bibliography tweaks
acholyn Jun 14, 2024
ebc7ac1
tweaks to bib styling
acholyn Jun 18, 2024
50bb888
adding collab logos + using text instead of image for logo text
acholyn Jun 24, 2024
4742640
tweaks to mobile view of collab logos
acholyn Jun 24, 2024
0f20a7c
adding collaborator logos and putting them in the footer
acholyn Jun 25, 2024
f1aaecf
center aligning header text
acholyn Jun 25, 2024
cbbd8c7
adding width to header menu icons
acholyn Jun 25, 2024
b2b802f
adding lang attr to html
acholyn Jun 25, 2024
bfc4de3
adding more links to menu and footer + 404 placeholders + small tweaks
acholyn Jun 27, 2024
4cb9d6a
tweaking shadows
acholyn Jun 27, 2024
705770e
header tweaks to make things bolder + tidying
acholyn Jun 27, 2024
c5bb499
Add Feedback model
p-j-smith Jun 27, 2024
cf6935e
Add migrations for Feedback model
p-j-smith Jun 27, 2024
daa6a0d
Add Feedback model to admin view
p-j-smith Jun 27, 2024
027babe
adding some menu icons
acholyn Jun 27, 2024
434aaa2
fixing project note bib related name
acholyn Jun 27, 2024
7cc1ee7
Remove unnecessary alteration for projectnote related_name
p-j-smith Jun 27, 2024
1b990b1
fixing note admin search fields
acholyn Jun 27, 2024
0881108
minor merge
acholyn Jun 27, 2024
aa3909c
tweaks/fixes to drawer
acholyn Jun 27, 2024
3d8dd3d
font + footer tweaks for Aylin, initial base for d/l modes
acholyn Jul 1, 2024
dab647d
minor tweaks to video and source previews
acholyn Jul 1, 2024
f7f12de
fixing migration name
acholyn Jul 1, 2024
ac70d23
adding feedback to admin
acholyn Jul 1, 2024
f289835
updated logos
acholyn Jul 1, 2024
5644141
logo styling
acholyn Jul 1, 2024
d9c07e2
adding js conditional to stop console complaining
acholyn Jul 1, 2024
09226af
Merge pull request #111 from UCL-ARC/feat/feedback-model
p-j-smith Jul 1, 2024
ed0fe2c
Make Film.format_type choices a tuple rather than set
p-j-smith Jul 1, 2024
668ad36
Add migrations
p-j-smith Jul 1, 2024
685b830
Add CI check for missing migrations
p-j-smith Jul 1, 2024
86ceeed
basic bits for colours + fixing mobile title
acholyn Jul 1, 2024
cfaee9b
use more explicit name for migration file
p-j-smith Jul 1, 2024
e138daa
Merge pull request #113 from UCL-ARC/fix/migrations
p-j-smith Jul 1, 2024
f20b335
tidying
acholyn Jul 2, 2024
b5665f4
colour distinctions for for light/dark modes
acholyn Jul 2, 2024
b704a93
Merge pull request #110 from UCL-ARC/updating-style-assets
acholyn Jul 2, 2024
c6a482d
Merge branch 'feat/feedback-model' into updating-style-assets because…
acholyn Jul 2, 2024
832e94b
Merge branch 'updating-style-assets' into development
acholyn Jul 2, 2024
390452a
reordering imports for diff
acholyn Jul 2, 2024
e90a43d
tracking feedback model file
acholyn Jul 2, 2024
aaae995
Merge branch 'development' into fix/feedback-not-merging
acholyn Jul 2, 2024
591de7f
re init feedback again.....
acholyn Jul 2, 2024
a701d53
fixing disappearing bib annotations
acholyn Jul 2, 2024
396875c
Merge pull request #114 from UCL-ARC/fix/feedback-not-merging
acholyn Jul 2, 2024
1980904
Merge pull request #85 from UCL-ARC/updating-docs
acholyn Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .ebextensions/db-migrate.config

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Check no migrations are missing
run: |
python manage.py makemigrations --check --dry-run --no-input

- name: Run DB Migrations
run: |
python manage.py migrate

- name: Run Tests
run: |
python manage.py test mod_app/tests
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ The production website is hosted at http://museumofdreamworlds.eu-west-2.elastic

The staging one is http://museumofdreams.eu-west-2.elasticbeanstalk.com/ and is built from the `development` branch

The more public versions are https://museumofdreamworlds.org and https://staging.museumofdreamworlds.org
The offical versions are https://museumofdreamworlds.org and https://staging.museumofdreamworlds.org

Development should be done locally and staged to the website. At present this is not a production version.
Development should be done locally and pushed to the staging website where researchers can test features and sign off on them before putting the code on production.

## Getting Started

To work on this project as is, clone the repo into an appropriate folder (eg. `museum_of_dreams_project`). Create a venv at the top level and start it. Then install the requirements and launch the app
To work on this project as is, clone the repo into an appropriate folder (eg. `museum_of_dreams_project`). Create a venv at the top level and start it. Then install the requirements and launch the app. We use `requirements-base.txt` as AWS looks for `requirements.txt` and we don't need to install MySQL locally (we use a local sqlite db).

```
python3 -m venv modvenv
Expand All @@ -26,6 +26,10 @@ If it's your first time initialising the app on your machine, you may need to ru
python manage.py migrate
python manage.py createsuperuser
```
### AWS

This project is hosted on AWS, if you do not have access to the account, let [Amanda Ho-Lyn](mailto:[email protected]) know and she will arrange this.
You may find it beneficial to read through the [current AWS setup docs](docs/baseAWSSetup.md) to gain an understanding of the architecture of the project. Also have a look at the [development SOP](docs/developmentSOP.md) for an idea of the general development flow.

### Running tests

Expand All @@ -36,12 +40,28 @@ To run the tests locally, run
python manage.py test mod_app/tests
```

### Technologies used

This project uses a number of technologies, including:
- [Django 4.2](https://docs.djangoproject.com/en/4.2/)
- [OpenProps](https://open-props.style/#colors) (CSS variable package)
- [CK Editor 4](https://ckeditor.com/docs/ckeditor4/latest/index.html)
- [Fuse.js](https://www.fusejs.io/)
- [AWS](aws.com)

Others which have tangentially helped with development:
- Hypothesis
- Figma
---

### See these other files for recreating the setup etc.
### See these other files for recreating the AWS setup and other features.

#### [Setting up from scratch](docs/howtoSetupBase.md) This covers how you'd go about recreating the AWS setup from scratch

#### [Current AWS Settings](docs/baseAWSSetup.md) This describes our current AWS settings without the processes of setting up, with a bit more explanation of why they are what they are

#### [Setting up from scratch](docs/fullSetup.md)
#### [How to set up the AWS chatbot for notifications](docs/AWSchatbot.md)

#### [Current AWS Settings](docs/AWScurrentSetup.md)
#### [Using S3 for staticfiles](docs/s3ForStatic.md)

#### [AWS chatbot](docs/AWSchatbot.md)
#### [Setting up email notifications](docs/AWSses.md)
1 change: 1 addition & 0 deletions dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def init_with_context(self, context):
"mod_app.models.support_models.Source",
"mod_app.models.support_models.OtherLink",
"mod_app.models.support_models.Tag",
"mod_app.models.feedback_model.Feedback",
),
),
],
Expand Down
64 changes: 0 additions & 64 deletions docs/AWScurrentSetup.md

This file was deleted.

11 changes: 11 additions & 0 deletions docs/AWSses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Setting up email notification system for changes on the website

These instructions assume you have purchased a domain name.

I followed the instructions in [this article](https://medium.com/hackernoon/the-easiest-way-to-send-emails-with-django-using-ses-from-aws-62f3d3d33efd). You don't need the seciton on sending from personal emails, but do need the section sending from a domain (that you've purchased).

When you have set up a domain in SES, you need to ensure you have selected "publish to Route 53" so that the details (DKIM) get added to the relevant domain name. You don't need to set up the `Custom MAIL FROM domain` unless you want to (allows you to send from abc.yourdomain), if you do, ensure you publish those credentials to Route 53.

To include it in the admin for select models, I created a mixin which expands the `save_model` function and added the mixin to the admin models. This way, whenever the model is saved in the admin, the researchers should be notified. I also opted to use a template for the html message rather than plain text.

You can view the [code for the mixin](../mod_app/utils/mixins.py) and the [email template](../mod_app/templates/email_template.html)
2 changes: 1 addition & 1 deletion docs/awsSSL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Go to the EB environment, go to the `Configuration` tab and go to the section ab

Once the changes have been applied, go to your `EC2 Security Groups` and here you should see a new load balancer type for your environment. I recommend changing the name to include LB or something similar so you can tell them apart easily.

On your environment's security group, the inbound rules should include http traffic from the load balancer, add it if it doesn't. Update the inbound rules in the load balancer's security group to allow HTTPS traffic from: itself, 0.0.0.0 (anywhere), the database and the environment. Also allow HTTP from anywhere.
On your environment's security group, the inbound rules should include http traffic from the load balancer, add it if it doesn't. Update the inbound rules in the load balancer's security group to allow HTTPS traffic from 0.0.0.0 (anywhere), the database and the environment. Also allow HTTP from anywhere.
85 changes: 85 additions & 0 deletions docs/baseAWSSetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Current Setup

Currently the AWS system is set up such that:

## VPC

There is one VPC called `MuseumofDreams`.
This has subnets across 3 availability zones (eu-west-2 a, b & c)
Below is a diagram of how the subnets are laid out.

![VPC resource map](imgs/VPCresource_map.png)

Internet gateways allow the assigned routetables and their subnets to be exposed to the internet. Both `mod_routetable_subnet`s are exposed to the internet and are used for the EB apps and their load balancers, whilst the `RDS-Pvt-rt` is for the databases, shielding them from public internet access.

They have been distributed between dev and prod as shown because load balancers are required to be in at least 2 different availability zones and require subnets with internet gateways. The instances of the EB apps can have subnets with and without an internet gateway. The configuration for these will be covered in the ElasticBeanstalk section.


## IAM

The IAM configuration is that laid out in the [IAM Roles section](howtoSetupBase.md) of setting up. There is a role called `MuseumofDreams_EB_EC2`.
There is also a user called `mod_site`.

## RDS

There are two RDS instances, one for staging (`mod-mysql-dev-db`) and one for prod (`mod-mysql-ebdb-prod`).

They are almost identical in their setup aside from their availability zones and secondary security groups to connect with their respective environments - `rds-ec2-1` for production and `ec2-rds-1` for staging.


## ElasticBeanstalk

There is one EBS application - Museum of Dreams site and it has 2 environments - ...`env` which is production and ...`env-dev` for staging.

The workflow is that development is done on a feature branch and this gets merged into `development` and the CodePipeline for the staging site deploys these updates. When these have been reviewed and approved, they can be merged into `main` and the production CodePipeline will deploy a new version of production.

There are saved configurations for both dev and prod environments with load balancers (`mod prod config` and `dev scaling config`), which have most of the necessary selections, the exception being regarding security groups and subnets that will be covered below. You can also set these up with scaling single instances instead of load balancers and then change to load balancers later on (necessary for [SSL](awsSSL.md))

They should also both use the `moddbkey` for EC2 access and `MuseumofDreams_EB_EC2` for the EC2 instance profile.

### Configuration
**Production**

| Parameter name | Value/s |
|----|---|
|instance subnets | `mod-subnet-a1`, `mod-subnet-c1`, `RDS-Pvt-subnet-3`|
|additional ec2 security groups | `rds-ec2-1`|
|load balancer subnets | `mod-subnet-a1`, `mod-subnet-c1`|
---


**Staging**

| Parameter name | Value/s |
|----|---|
|instance subnets | `mod-subnet-a2`, `mod-subnet-b1`, `RDS-Pvt-subnet-2`|
|additional ec2 security groups | `ec2-rds-1`|
|load balancer subnets | `mod-subnet-a2`, `mod-subnet-b1`|
---

Use the saved configurations to launch instances if an environment needs to be terminated and spun up again. Make sure you detach the security groups before doing this (can be done from the security group console).
Ensure the private subnets for the instances are in a different availability zone from the public subnets (which overlap with the load balancer subnets) to prevent instances being launched in a private subnet by mistake.


## Security Groups

Security groups allow traffic to pass between the instances attached to the SG and any others that have been defined in the incoming/outgoing rules. If traffic is allowed in via one rule it is also allowed out by that same rule, which means you only need to define it once.

Each EC2 instance has a default SG and a load balancer SG and these are automatically populated when an instance is launched. The additional groups are attached to the EC2 instances so that they can communicate with the MySQL databases.


## Restoring DB instances

If ever you need to spin up a new verison of the db, this should be done from *backups*, **not** snapshots as snapshots do not allow you to set an initial db name, which is necessary for EBS to connect to the RDS.

# Accessing the db through an EC2 shell

The following commands are important to run anytime you have to use the shell to manually run commands (this shouldn't be often!)

```
cd /var/app
source venv/staging-LQM1lest/bin/activate
cd current

export $(/opt/elasticbeanstalk/bin/get-config --output YAML environment | sed -r 's/: /=/' | xargs)
```
15 changes: 15 additions & 0 deletions docs/developmentSOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Standard development procedure

This document outlines the recommended way we develop and publish features for this project.

#### 1. Begin to develop code locally on new branch

#### 2. If you are working on a feature that needs to be tested on staging whilst in development, use the `dev-feature-test-pipeline` pipeline and edit it to point towards your branch. You will have to manually release the change. Be sure to notify your colleagues _before_ doing this to ensure there is no conflict in the versions.

#### 3. Once you've finished developing the feature, open a PR to `development`. Once merged, double check the behaviour is as expected on staging.

#### 4. Once confirmed, open a PR to `main` and once merged, check the behaviour is as expected on production. You may wish to inform the researchers via email.

#### 5. On the the next! 😁

If you have any questions, contact [Amanda Ho-Lyn](mailto:[email protected])
Loading
Loading