Skip to content

Commit

Permalink
Tethys Portal Logo Update (#1083)
Browse files Browse the repository at this point in the history
* updates to use new tethys logo

* fix for migration

* fixed migration

* black formatting fixes

* fixed tethys_config test

* typo fix in test
  • Loading branch information
jakeymac authored Sep 6, 2024
1 parent c006cf1 commit 56d0892
Show file tree
Hide file tree
Showing 5 changed files with 10,806 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/unit_tests/test_tethys_config/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_setting_defaults(self, mock_settings, mock_timezone):
)
mock_settings().setting_set.create.assert_any_call(
name="Brand Image",
content="/tethys_portal/images/" "tethys-logo-25.png",
content="/tethys_portal/images/" "tethys-on-blue-icon-only.svg",
date_modified=now,
)
mock_settings().setting_set.create.assert_any_call(
Expand Down
2 changes: 1 addition & 1 deletion tethys_config/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def setting_defaults(category):

category.setting_set.create(
name="Brand Image",
content="/tethys_portal/images/tethys-logo-25.png",
content="/tethys_portal/images/tethys-on-blue-icon-only.svg",
date_modified=now,
)

Expand Down
60 changes: 60 additions & 0 deletions tethys_config/migrations/0002_auto_20240820_2142.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 4.2.14 on 2024-08-20 21:42

from django.db import migrations
from django.utils import timezone
from tethys_config.init import (
initial_settings,
reverse_init,
custom_settings,
reverse_custom,
)


def update_brand_image(apps, schema_editor):
"""
Update the brand image setting
"""
Setting = apps.get_model("tethys_config", "Setting")

# Get the brand image setting
brand_image_setting = Setting.objects.get(name="Brand Image")

# Update the brand image setting if it's the default
if brand_image_setting.content == "/tethys_portal/images/tethys-logo-25.png":
brand_image_setting.content = (
"/tethys_portal/images/tethys-on-blue-icon-only.svg"
)
brand_image_setting.date_modified = timezone.now()
brand_image_setting.save()


def reverse_update_brand_image(apps, schema_editor):
"""
Reverse the brand image setting update
"""
Setting = apps.get_model("tethys_config", "Setting")

# Get the brand image setting
brand_image_setting = Setting.objects.get(name="Brand Image")

# Update the brand image setting if it's the default
if (
brand_image_setting.content
== "/tethys_portal/images/tethys-on-blue-icon-only.svg"
):
brand_image_setting.content = "/tethys_portal/images/tethys-logo-25.png"
brand_image_setting.date_modified = timezone.now()
brand_image_setting.save()


class Migration(migrations.Migration):

dependencies = [
("tethys_config", "0001_initial_40"),
]

operations = [
migrations.RunPython(
update_brand_image, reverse_code=reverse_update_brand_image
),
]
Loading

0 comments on commit 56d0892

Please sign in to comment.