apps.py 2.94 KB
Newer Older
Patrick's avatar
Patrick committed
1
2
3
4
5
6
7
8
9
# -*- 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 _
from const import *

repanier_settings = {
Patrick's avatar
Patrick committed
10
11
    'CONFIG': None,
    'TEST_MODE': None,
Patrick's avatar
Patrick committed
12
13
14
15
    'GROUP_NAME': None,
    'PERMANENCE_NAME': None,
    'PERMANENCES_NAME': None,
    'PERMANENCE_ON_NAME': None,
Patrick's avatar
Patrick committed
16
17
18
19
20
21
22
    '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,
Patrick's avatar
Patrick committed
23
24
25
26
    'DISPLAY_ANONYMOUS_ORDER_FORM': None,
    'DISPLAY_PRODUCERS_ON_ORDER_FORM': None,
    'BANK_ACCOUNT': None,
    'PRODUCER_ORDER_ROUNDED': None,
Patrick's avatar
Patrick committed
27
    'PRODUCER_PRE_OPENING': None,
Patrick's avatar
Patrick committed
28
    'ACCEPT_CHILD_GROUP': None,
Patrick's avatar
Patrick committed
29
30
31
    'DELIVERY_POINT': None,
    'INVOICE': None,
    'STOCK': None,
Patrick's avatar
Patrick committed
32
33
    'DISPLAY_VAT': None,
    'VAT_ID': None,
Patrick's avatar
Patrick committed
34
    'PAGE_BREAK_ON_CUSTOMER_CHECK': None
Patrick's avatar
Patrick committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
}

class RepanierConfig(AppConfig):
    name = 'repanier'
    verbose_name = "Repanier"

    def ready(self):
        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
54
                    test_mode=True,
Patrick's avatar
Patrick committed
55
                    name=PERMANENCE_NAME_PERMANENCE,
Patrick's avatar
Patrick committed
56
57
58
59
60
61
62
                    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
63
64
65
                    invoice=True,
                    stock=False,
                    display_anonymous_order_form=False,
Patrick's avatar
Patrick committed
66
                    display_producer_on_order_form=False,
Patrick's avatar
Patrick committed
67
68
                    bank_account="BE99 9999 9999 9999",
                    producer_order_rounded=False,
Patrick's avatar
Patrick committed
69
                    producer_pre_opening=False,
Patrick's avatar
Patrick committed
70
                    accept_child_group=False,
Patrick's avatar
Patrick committed
71
72
                    delivery_point=False,
                    display_vat=False,
Patrick's avatar
Patrick committed
73
                    vat_id=EMPTY_STRING,
Patrick's avatar
Patrick committed
74
                    page_break_on_customer_check=False
Patrick's avatar
Patrick committed
75
76
77
78
79
80
81
                )
            config.save()
        except Exception as error_str:
            print("##################################")
            print error_str
            print("##################################")
            other = _("Other qty")