from django.db import migrations, models
import encrypted_model_fields.fields


class Migration(migrations.Migration):
    """
    The last two credentials that were still files: the FAB Club OAuth secret,
    and the Google Analytics service account key.

    FAB is straightforward, a client id and a secret. Analytics is a whole JSON
    document rather than a key, so it needs a text field, and it replaces
    GA_CREDENTIALS_FILE, which pointed at a path that no longer existed on the
    Mac. Additive, all three blank by default.
    """

    dependencies = [
        ('pages', '0039_sitesettings_recaptcha_v2'),
    ]

    operations = [
        migrations.AddField(
            model_name='sitesettings',
            name='fab_oauth_client_id',
            field=models.CharField(blank=True, help_text='OAuth2 client_id issued by FAB Club', max_length=200),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='fab_oauth_client_secret',
            field=encrypted_model_fields.fields.EncryptedCharField(blank=True, help_text='OAuth2 client secret, stored encrypted', max_length=255),
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='ga_credentials_json',
            field=encrypted_model_fields.fields.EncryptedTextField(blank=True, help_text='Paste the contents of the Google service account JSON file'),
        ),
    ]
