apps.py 3.94 KB
Newer Older
Patrick's avatar
Patrick committed
1 2 3 4 5 6
# -*- coding: utf-8
from __future__ import unicode_literals
from django.apps import AppConfig
from django.conf import settings
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
Patrick Colmant's avatar
Patrick Colmant committed
7
from callback import pasword_reset_callback
Patrick's avatar
Patrick committed
8
from const import *
Patrick Colmant's avatar
Patrick Colmant committed
9
from password_reset.signals import user_recovers_password
Patrick's avatar
Patrick committed
10

Patrick Colmant's avatar
Patrick Colmant committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# repanier_settings = {
#     'CONFIG': None,
#     'TEST_MODE': None,
#     'GROUP_NAME': None,
#     'PERMANENCE_NAME': None,
#     'PERMANENCES_NAME': None,
#     'PERMANENCE_ON_NAME': None,
#     'MAX_WEEK_WO_PARTICIPATION': None,
#     'SEND_OPENING_MAIL_TO_CUSTOMER': None,
#     'SEND_ORDER_MAIL_TO_CUSTOMER': None,
#     'SEND_ORDER_MAIL_TO_PRODUCER': None,
#     'SEND_ORDER_MAIL_TO_BOARD': None,
#     'SEND_INVOICE_MAIL_TO_CUSTOMER': None,
#     'SEND_INVOICE_MAIL_TO_PRODUCER': None,
#     'DISPLAY_ANONYMOUS_ORDER_FORM': None,
#     'DISPLAY_PRODUCERS_ON_ORDER_FORM': None,
#     'BANK_ACCOUNT': None,
#     'PRODUCER_ORDER_ROUNDED': None,
#     'PRODUCER_PRE_OPENING': None,
#     'ACCEPT_CHILD_GROUP': None,
#     'DELIVERY_POINT': None,
#     'INVOICE': None,
#     'STOCK': None,
#     'DISPLAY_VAT': None,
#     'VAT_ID': None,
#     'PAGE_BREAK_ON_CUSTOMER_CHECK': None
# }
# class RepanierConfig(AppConfig):
Patrick's avatar
Patrick committed
39

Patrick Colmant's avatar
Patrick Colmant committed
40
class RepanierSettings(AppConfig):
Patrick's avatar
Patrick committed
41 42 43
    name = 'repanier'
    verbose_name = "Repanier"

Patrick Colmant's avatar
Patrick Colmant committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
    config = None
    test_mode = None
    group_name = None
    permanence_name = None
    permanences_name = None
    permanence_on_name = None
    max_week_wo_participation = None
    send_opening_mail_to_customer = None
    send_order_mail_to_customer = None
    send_order_mail_to_producer = None
    send_order_mail_to_board = None
    send_invoice_mail_to_customer = None
    send_invoice_mail_to_producer = None
    invoice = None
    stock = None
    display_anonymous_order_form = None
    display_producer_on_order_form = None
    bank_account = None
    producer_order_rounded = None
    producer_pre_opening = None
    accept_child_group = None
    delivery_point = None
    display_vat = None
    vat_id = None
    page_break_on_customer_check = None

Patrick's avatar
Patrick committed
70
    def ready(self):
Patrick Colmant's avatar
Patrick Colmant committed
71
        user_recovers_password.connect(pasword_reset_callback)
Patrick's avatar
Patrick committed
72 73 74 75 76 77 78 79 80 81 82 83
        from models import Configuration
        try:
            config = Configuration.objects.filter(id=DECIMAL_ONE).first()
            if config is None:
                group_name = settings.ALLOWED_HOSTS[0]
                site = Site.objects.get_current()
                if site is not None:
                    site.name = group_name
                    site.domain = group_name
                    site.save()
                config = Configuration.objects.create(
                    group_name=group_name,
Patrick's avatar
Patrick committed
84
                    test_mode=True,
Patrick's avatar
Patrick committed
85
                    name=PERMANENCE_NAME_PERMANENCE,
Patrick's avatar
Patrick committed
86 87 88 89 90 91 92
                    max_week_wo_participation=Decimal('99'),
                    send_opening_mail_to_customer=False,
                    send_order_mail_to_customer=False,
                    send_order_mail_to_producer=False,
                    send_invoice_mail_to_customer=False,
                    send_invoice_mail_to_producer=False,
                    send_order_mail_to_board=False,
Patrick's avatar
Patrick committed
93 94 95
                    invoice=True,
                    stock=False,
                    display_anonymous_order_form=False,
Patrick's avatar
Patrick committed
96
                    display_producer_on_order_form=False,
Patrick's avatar
Patrick committed
97 98
                    bank_account="BE99 9999 9999 9999",
                    producer_order_rounded=False,
Patrick's avatar
Patrick committed
99
                    producer_pre_opening=False,
Patrick's avatar
Patrick committed
100
                    accept_child_group=False,
Patrick's avatar
Patrick committed
101 102
                    delivery_point=False,
                    display_vat=False,
Patrick's avatar
Patrick committed
103
                    vat_id=EMPTY_STRING,
Patrick's avatar
Patrick committed
104
                    page_break_on_customer_check=False
Patrick's avatar
Patrick committed
105 106 107 108 109 110 111
                )
            config.save()
        except Exception as error_str:
            print("##################################")
            print error_str
            print("##################################")
            other = _("Other qty")