# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-13 00:13
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations

FAQ_TEXT = """
<div id="faq">
<h3>What is Freelance Finder?</h3>
<div>
  <p>Freelance Finder is a contract/freelance job aggregator designed to help freelancers find clients.  It is not designed for use by people seeking freelance help, but instead to be used by the freelancers themselves to more efficiently find the jobs that are advertised elsewhere.</p>
</div>
<h3>I often check a site that doesn't seem to be listed.  Can you add it?</h3>
<div>
  <p>Yes!  Just use the contact form page or send an email to <a href="mailto:info@freelancefinder.work">info@freelancefinder.work</a>.</p>
</div>
</div>
"""


def add_faq(apps, schema_editor):
    FlatPage = apps.get_model('flatpages', 'FlatPage')
    Site = apps.get_model('sites', 'Site')
    this_site = Site.objects.filter(domain='freelancefinder.work').first()
    faq_page = FlatPage.objects.create(
        url='/about/faq/',
        title='FAQ',
        content=FAQ_TEXT,
    )
    faq_page.sites.add(this_site)


def delete_faq(apps, schema_editor):
    FlatPage = apps.get_model('flatpages', 'FlatPage')
    FlatPage.objects.filter(url='/about/faq/').delete()


class Migration(migrations.Migration):

    dependencies = [
        ('freelancefinder', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(add_faq, reverse_code=delete_faq),
    ]
