funkwhale/api/funkwhale_api/contrib/sites/migrations/0002_set_site_domain_and_na...

30 wiersze
841 B
Python
Czysty Zwykły widok Historia

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
def update_site_forward(apps, schema_editor):
"""Set site domain and name."""
Site = apps.get_model("sites", "Site")
Site.objects.update_or_create(
id=settings.SITE_ID,
2018-06-09 13:36:16 +00:00
defaults={"domain": "funkwhale.io", "name": "funkwhale_api"},
)
def update_site_backward(apps, schema_editor):
"""Revert site domain and name to default."""
Site = apps.get_model("sites", "Site")
Site.objects.update_or_create(
2018-06-09 13:36:16 +00:00
id=settings.SITE_ID, defaults={"domain": "example.com", "name": "example.com"}
)
class Migration(migrations.Migration):
2018-06-09 13:36:16 +00:00
dependencies = [("sites", "0001_initial")]
2018-06-09 13:36:16 +00:00
operations = [migrations.RunPython(update_site_forward, update_site_backward)]