# -*- coding: utf-8 -*-
import os

from froide.settings import Base, ThemeBase, German


class FragDenStaatBase(German, ThemeBase, Base):

    gettext = lambda s: s
    LANGUAGES = (
        ('de', gettext('German')),
    )

    FROIDE_THEME = 'fragdenstaat_de.theme'

    @property
    def INSTALLED_APPS(self):
        installed = super(FragDenStaatBase, self).INSTALLED_APPS
        installed += [
            'foiidea',
            'celery_haystack',
            'djcelery_email',
            'djangosecure',
            'django.contrib.redirects',
            'django.contrib.flatpages'
        ]
        return installed

    @property
    def GEOIP_PATH(self):
        return os.path.join(super(FragDenStaatBase, self).PROJECT_ROOT, '..', 'data')

    MIDDLEWARE_CLASSES = [
        'django.contrib.sessions.middleware.SessionMiddleware',
        'djangosecure.middleware.SecurityMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
        'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
        'froide.account.middleware.AcceptNewTermsMiddleware',
    ]

    CACHES = {
        'default': {
            'LOCATION': 'unique-snowflake',
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
        }
    }

    ########## Debug ###########

    HAYSTACK_CONNECTIONS = {
        'default': {
            'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
            'URL': 'http://127.0.0.1:8983/solr/fragdenstaat'
        }
    }
    HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'

    SITE_NAME = "Frag den Staat"
    SITE_EMAIL = "info@fragdenstaat.de"
    SITE_URL = 'http://localhost:8000'

    SECRET_URLS = {
        "admin": "admin",
    }

    DEFAULT_FROM_EMAIL = 'info@fragdenstaat.de'
    EMAIL_SUBJECT_PREFIX = '[AdminFragDenStaat] '

    EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
    CELERY_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    CELERY_EMAIL_TASK_CONFIG = {
        'max_retries': None,
        'ignore_result': False,
        'acks_late': True,
        'store_errors_even_if_ignored': True
    }


class Dev(FragDenStaatBase):
    pass


try:
    from .local_settings import *  # noqa
except ImportError:
    pass

@@ -2400,16 +2400,1146 @@
 %0A    %7D%0A%0A
+    @property%0A    def FROIDE_CONFIG(self):%0A        config = super(FragDenStaatBase, self).FROIDE_CONFIG%0A        config.update(dict(%0A            create_new_publicbody=False,%0A            publicbody_empty=True,%0A            user_can_hide_web=True,%0A            public_body_officials_public=True,%0A            public_body_officials_email_public=False,%0A            default_law=2,%0A            doc_conversion_binary=%22/usr/bin/libreoffice%22,%0A            dryrun=False,%0A            dryrun_domain=%22fragdenstaat.stefanwehrmeyer.com%22,%0A            allow_pseudonym=True,%0A            api_activated=True,%0A            search_engine_query='http://www.google.de/search?as_q=%25(query)s&as_epq=&as_oq=&as_eq=&hl=en&lr=&cr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=%25(domain)s&as_rights=&safe=images',%0A            show_public_body_employee_name=False,%0A            greetings=%5Brec(u%22Sehr geehrt(er? (?:Herr%7CFrau)(?: ?Dr%5C.?)?(?: ?Prof%5C.?)? .*)%22)%5D,%0A            closings=%5Brec(u%22%5BMm%5Dit( den)? (freundlichen%7Cvielen%7Cbesten) Gr%5Cxfc%5Cxdfen,?%22), rec(%22Hochachtungsvoll,?%22), rec('i%5C. ?A%5C.'), rec('%5BiI%5Dm Auftrag')%5D%0A        ))%0A        return config%0A%0A
 %0Aclass D

Add basic fragdenstaat.de froide config to settings