mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Major refactor of codebase.
This commit is contained in:
42
app/YtManagerApp/migrations/0013_auto_20200410_2037.py
Normal file
42
app/YtManagerApp/migrations/0013_auto_20200410_2037.py
Normal file
@ -0,0 +1,42 @@
|
||||
# Generated by Django 3.0.4 on 2020-04-10 20:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('YtManagerApp', '0012_auto_20190819_1615'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='VideoProviderConfig',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('provider_id', models.CharField(help_text='Provider ID', max_length=128, unique=True)),
|
||||
('settings', models.TextField(help_text='Video provider settings')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='subscription',
|
||||
name='provider_id',
|
||||
field=models.CharField(default='YtAPI', max_length=128),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='video',
|
||||
name='downloaded_size',
|
||||
field=models.IntegerField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='video',
|
||||
name='last_updated_date',
|
||||
field=models.DateTimeField(auto_now=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='video',
|
||||
name='name',
|
||||
field=models.TextField(),
|
||||
),
|
||||
]
|
28
app/YtManagerApp/migrations/0014_fix_video_provider.py
Normal file
28
app/YtManagerApp/migrations/0014_fix_video_provider.py
Normal file
@ -0,0 +1,28 @@
|
||||
# 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):
|
||||
globalPrefs = apps.get_model('dynamic_preferences', 'GlobalPreferenceModel')
|
||||
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)
|
||||
]
|
Reference in New Issue
Block a user