2020-04-10 21:30:24 +00:00
|
|
|
# Generated by Django 3.0.4 on 2020-04-10 20:37
|
|
|
|
|
|
|
|
from django.db import migrations, models
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
def fix_video_provider(apps, schema_editor):
|
2020-10-18 12:54:03 +00:00
|
|
|
try:
|
|
|
|
globalPrefs = apps.get_model('dynamic_preferences', 'GlobalPreferenceModel')
|
|
|
|
except LookupError as e:
|
|
|
|
print("Warning: could not get dynamic_preferences model.")
|
|
|
|
return
|
|
|
|
|
2020-04-10 21:30:24 +00:00
|
|
|
api_key_entries = globalPrefs.objects.filter(name='youtube_api_key')
|
|
|
|
if len(api_key_entries) < 1:
|
|
|
|
return
|
|
|
|
|
|
|
|
videoProviderConfig = apps.get_model('YtManagerApp', 'VideoProviderConfig')
|
|
|
|
ytApiProvider = videoProviderConfig(provider_id='YtAPI', settings=json.dumps({
|
|
|
|
'api_key': api_key_entries[0].raw_value
|
|
|
|
}))
|
|
|
|
ytApiProvider.save()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
|
|
|
('YtManagerApp', '0013_auto_20200410_2037'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(fix_video_provider)
|
|
|
|
]
|