Skip to content

Commit

Permalink
Merge pull request #1108 from Amsterdam-Music-Lab/release/2.2.0
Browse files Browse the repository at this point in the history
Release: v2.2.0
  • Loading branch information
drikusroor authored Jun 12, 2024
2 parents 2fc2bc6 + 0b20a27 commit 7ce3812
Show file tree
Hide file tree
Showing 165 changed files with 7,227 additions and 3,871 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/db-backup-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Database Backup Template

on:
workflow_call:
inputs:
runner:
required: true
type: string

jobs:
backup:
runs-on: ${{ inputs.runner }}
steps:

- name: Set Date
id: date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Backup Database
run: |
podman exec muscle_db_1 sh -c "pg_dump -Fc > /backups/${{ env.DATE }}.dump"
- name: Remove Old Backups (older than 7 days)
run: |
podman exec muscle_db_1 sh -c "find /backups -type f -name '*.dump' -mtime +7 -exec rm {} \;"
32 changes: 27 additions & 5 deletions .github/workflows/podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
types: [created]

jobs:

deploy-test:
name: Deploy to test environment
environment: Test
Expand Down Expand Up @@ -79,8 +80,10 @@ jobs:
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d --force-recreate
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
Expand Down Expand Up @@ -169,8 +172,10 @@ jobs:
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d --force-recreate
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
Expand Down Expand Up @@ -209,7 +214,7 @@ jobs:
AML_LOCATION_PROVIDER: ${{ vars.AML_LOCATION_PROVIDER }}
AML_SUBPATH: ${{ vars.AML_SUBPATH }}
DJANGO_SETTINGS_MODULE: ${{ vars.DJANGO_SETTINGS_MODULE }}
SENTRY_ENVIRONMENT: "acceptance"
SENTRY_ENVIRONMENT: "production"
SQL_DATABASE: ${{ vars.SQL_DATABASE }}
SQL_HOST: ${{ vars.SQL_HOST }}
SQL_PORT: ${{ vars.SQL_PORT }}
Expand Down Expand Up @@ -256,8 +261,10 @@ jobs:
cp .env frontend/.env
- name: Build Podman images
run: podman-compose -f docker-compose-deploy.yml build
- name: Shut down running containers
run: podman compose -f docker-compose-deploy.yml down
- name: Deploy Podman images
run: podman-compose -f docker-compose-deploy.yml up -d --force-recreate
run: podman-compose -f docker-compose-deploy.yml up -d
- name: Notify Sentry of new release
run: |
curl -X POST "https://sentry.io/api/0/organizations/uva-aml/releases/" \
Expand All @@ -275,4 +282,19 @@ jobs:
- name: Prune old images
run: podman image prune -a -f
- name: Check Podman images
run: podman-compose -f docker-compose-deploy.yml ps
run: podman-compose -f docker-compose-deploy.yml ps

e2e-acceptance:
name: E2E tests on acceptance environment
runs-on: ACC
# temporarily true to test e2e tests
if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')

env:
BASE_URL: "https://acc.amsterdammusiclab.nl"

steps:

- uses: actions/checkout@v4
- name: Run E2E tests
run: cd e2e && bash run-tests
13 changes: 13 additions & 0 deletions .github/workflows/schedule-db-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Schedule Database Backup

on:
schedule:
- cron: '0 0 * * *' # Runs every night at midnight UTC
workflow_dispatch: # Allows manual triggering

jobs:

backup-production:
uses: ./.github/workflows/db-backup-template.yml
with:
runner: PRD
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ yarn.lock
tests/*.ini
tests/*.log
tests/__pycache__

e2e/screenshots
Empty file.
105 changes: 105 additions & 0 deletions backend/admin_interface/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
from django.contrib import admin
from django.utils.html import format_html
from .models import AdminInterfaceConfiguration, AdminInterfaceThemeConfiguration
from .forms import AdminInterfaceConfigurationForm, AdminInterfaceThemeConfigurationForm


class AdminInterfaceThemeConfigurationInline(admin.StackedInline):
model = AdminInterfaceThemeConfiguration
form = AdminInterfaceThemeConfigurationForm
extra = 0
fields = (
# Color scheme

# - Official Django colors

# -- Main colors
'color_primary',
'color_secondary',
'color_accent',
'color_primary_fg',

# -- Body
'color_body_fg',
'color_body_bg',
'color_body_quiet_color',
'color_body_loud_color',

# -- Header
'color_header_color',

# -- Breadcumbs
'color_breadcrumbs_fg',

# -- Link
'color_link_fg',
'color_link_hover_color',
'color_link_selected_fg',

# -- Borders
'color_hairline_color',
'color_border_color',

# -- Error
'color_error_fg',

# -- Message
'color_message_success_bg',
'color_message_warning_bg',
'color_message_error_bg',

# -- Darkened
'color_darkened_bg',

# -- Selected
'color_selected_bg',
'color_selected_row',

# -- Button
'color_button_fg',
'color_button_bg',
'color_button_hover_bg',
'color_default_button_bg',
'color_default_button_hover_bg',
'color_close_button_bg',
'color_close_button_hover_bg',
'color_delete_button_bg',
'color_delete_button_hover_bg',

# Custom colors
'color_default_bg',
'color_default_fg',
'color_success_bg',
'color_success_fg',
'color_warning_bg',
'color_warning_fg',
'color_error_bg',
)


class AdminInterfaceConfigurationAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'theme_overview', 'active',)

form = AdminInterfaceConfigurationForm
inlines = [AdminInterfaceThemeConfigurationInline]

def theme_overview(self, obj):
theme = obj.theme if hasattr(obj, 'theme') else None

if not theme:
return "No theme assigned"

fields = AdminInterfaceThemeConfigurationInline.fields
color_fields = [f for f in fields if f.startswith('color_')]
color_overview = ''.join(
f'<span style="display: inline-block; width: 20px; height: 20px; background-color: {getattr(theme, f)}; margin-right: 5px;"></span>'
for f in color_fields
)

return format_html(f'<div>{color_overview}</div>')


admin.site.register(
AdminInterfaceConfiguration,
AdminInterfaceConfigurationAdmin,
)
6 changes: 6 additions & 0 deletions backend/admin_interface/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AdminInterfaceConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'admin_interface'
19 changes: 19 additions & 0 deletions backend/admin_interface/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from django import forms
from .models import AdminInterfaceConfiguration


class AdminInterfaceConfigurationForm(forms.ModelForm):

class Meta:
model = AdminInterfaceConfiguration
fields = '__all__'


class AdminInterfaceThemeConfigurationForm(forms.ModelForm):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

for field in self.fields:
self.fields[field].widget = forms.TextInput(attrs={'type': 'color'})
69 changes: 69 additions & 0 deletions backend/admin_interface/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Generated by Django 3.2.25 on 2024-05-01 14:23

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='AdminInterfaceConfiguration',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(default='Default', max_length=255, unique=True)),
('description', models.TextField(blank=True, default='')),
('active', models.BooleanField(default=True)),
],
),
migrations.CreateModel(
name='AdminInterfaceThemeConfiguration',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('color_primary', models.CharField(blank=True, default='#79aec8', max_length=255)),
('color_secondary', models.CharField(blank=True, default='#417690', max_length=255)),
('color_accent', models.CharField(blank=True, default='#f5dd5d', max_length=255)),
('color_primary_fg', models.CharField(blank=True, default='#ffffff', max_length=255)),
('color_body_fg', models.CharField(blank=True, default='#333333', max_length=255)),
('color_body_bg', models.CharField(blank=True, default='#ffffff', max_length=255)),
('color_body_quiet_color', models.CharField(blank=True, default='#666666', max_length=255)),
('color_body_loud_color', models.CharField(blank=True, default='#000000', max_length=255)),
('color_header_color', models.CharField(blank=True, default='#ffffcc', max_length=255)),
('color_breadcrumbs_fg', models.CharField(blank=True, default='#c4dce8', max_length=255)),
('color_link_fg', models.CharField(blank=True, default='#447e9b', max_length=255)),
('color_link_hover_color', models.CharField(blank=True, default='#003366', max_length=255)),
('color_link_selected_fg', models.CharField(blank=True, default='#5b80b2', max_length=255)),
('color_hairline_color', models.CharField(blank=True, default='#e8e8e8', max_length=255)),
('color_border_color', models.CharField(blank=True, default='#cccccc', max_length=255)),
('color_error_fg', models.CharField(blank=True, default='#ba2121', max_length=255)),
('color_message_success_bg', models.CharField(blank=True, default='#ddffdd', max_length=255)),
('color_message_warning_bg', models.CharField(blank=True, default='#ffffcc', max_length=255)),
('color_message_error_bg', models.CharField(blank=True, default='#ffefef', max_length=255)),
('color_darkened_bg', models.CharField(blank=True, default='#f8f8f8', max_length=255)),
('color_selected_bg', models.CharField(blank=True, default='#e4e4e4', max_length=255)),
('color_selected_row', models.CharField(blank=True, default='#ffffcc', max_length=255)),
('color_button_fg', models.CharField(blank=True, default='#ffffff', max_length=255)),
('color_button_bg', models.CharField(blank=True, default='#79aec8', max_length=255)),
('color_button_hover_bg', models.CharField(blank=True, default='#609ab6', max_length=255)),
('color_default_button_bg', models.CharField(blank=True, default='#417690', max_length=255)),
('color_default_button_hover_bg', models.CharField(blank=True, default='#205067', max_length=255)),
('color_close_button_bg', models.CharField(blank=True, default='#888888', max_length=255)),
('color_close_button_hover_bg', models.CharField(blank=True, default='#747474', max_length=255)),
('color_delete_button_bg', models.CharField(blank=True, default='#ba2121', max_length=255)),
('color_delete_button_hover_bg', models.CharField(blank=True, default='#a41515', max_length=255)),
('color_default_bg', models.CharField(blank=True, default='#f8d7da', max_length=255)),
('color_default_fg', models.CharField(blank=True, default='#721c24', max_length=255)),
('color_success_bg', models.CharField(blank=True, default='#d4edda', max_length=255)),
('color_success_fg', models.CharField(blank=True, default='#155724', max_length=255)),
('color_warning_bg', models.CharField(blank=True, default='#fff3cd', max_length=255)),
('color_warning_fg', models.CharField(blank=True, default='#856404', max_length=255)),
('color_error_bg', models.CharField(blank=True, default='#f8d7da', max_length=255)),
('configuration', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='theme', to='admin_interface.admininterfaceconfiguration')),
],
),
]
Empty file.
Loading

0 comments on commit 7ce3812

Please sign in to comment.