· 9 years ago · Sep 20, 2016, 02:30 PM
1"""
2Django settings for pac_gateway project.
3
4Generated by 'django-admin startproject' using Django 1.9.5.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/1.9/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/1.9/ref/settings/
11"""
12
13import os
14
15DEBUG = False
16
17if os.environ.get('DJANGO_DEBUG', False):
18 DEBUG = True
19
20# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
21BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22
23# Quick-start development settings - unsuitable for production
24# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
25
26# SECURITY WARNING: keep the secret key used in production secret!
27SECRET_KEY = 'nbqoc-^@f#1(g#cux^w*$%14opecsr8np@m^h2vykctm+76!pw'
28
29ALLOWED_HOSTS = []
30
31# Application definition
32
33INSTALLED_APPS = [
34 'django.contrib.admin',
35 'django.contrib.auth',
36 'django.contrib.contenttypes',
37 'django.contrib.sessions',
38 'django.contrib.messages',
39 'django.contrib.staticfiles',
40 'django.contrib.postgres',
41 'rest_framework.authtoken',
42 'rest_framework',
43 'corsheaders',
44 'rest_framework_swagger',
45 'anymail',
46 'pac_gateway.cfd',
47 'daterange_filter',
48 'colorfield',
49 'colorful'
50]
51
52MIDDLEWARE_CLASSES = [
53 'django.middleware.security.SecurityMiddleware',
54 'django.contrib.sessions.middleware.SessionMiddleware',
55 'corsheaders.middleware.CorsMiddleware',
56 'django.middleware.common.CommonMiddleware',
57 'django.middleware.csrf.CsrfViewMiddleware',
58 'django.contrib.auth.middleware.AuthenticationMiddleware',
59 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
60 'django.contrib.messages.middleware.MessageMiddleware',
61 'django.middleware.clickjacking.XFrameOptionsMiddleware',
62]
63
64CORS_ORIGIN_ALLOW_ALL = True
65CORS_ALLOW_CREDENTIALS = True
66
67ROOT_URLCONF = 'pac_gateway.urls'
68
69TEMPLATES = [
70 {
71 'BACKEND': 'django.template.backends.django.DjangoTemplates',
72 'DIRS': [os.path.join(BASE_DIR, 'templates'), ],
73 'APP_DIRS': True,
74 'OPTIONS': {
75 'context_processors': [
76 'django.template.context_processors.debug',
77 'django.template.context_processors.request',
78 'django.contrib.auth.context_processors.auth',
79 'django.contrib.messages.context_processors.messages',
80 ],
81 'debug': DEBUG
82 },
83 },
84]
85
86WSGI_APPLICATION = 'pac_gateway.wsgi.application'
87
88# Password validation
89# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
90
91AUTH_PASSWORD_VALIDATORS = [
92 {
93 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94 },
95 {
96 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97 },
98 {
99 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100 },
101 {
102 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103 },
104]
105
106# Internationalization
107# https://docs.djangoproject.com/en/1.9/topics/i18n/
108
109LANGUAGE_CODE = 'es'
110
111TIME_ZONE = 'UTC'
112
113USE_I18N = True
114
115# USE_L10N = True
116
117USE_TZ = True
118
119LOCALE_PATHS = (
120 os.path.join(BASE_DIR, 'locale'),
121)
122
123# Static files (CSS, JavaScript, Images)
124# https://docs.djangoproject.com/en/1.9/howto/static-files/
125
126STATIC_URL = '/static/'
127STATIC_ROOT = os.path.join(BASE_DIR, 'static')
128
129# Rest Framework
130
131REST_FRAMEWORK = {
132 'DEFAULT_PERMISSION_CLASSES': (
133 'rest_framework.permissions.IsAuthenticated',
134 ),
135 'DEFAULT_FILTER_BACKENDS': (
136 'rest_framework.filters.DjangoFilterBackend',
137 'rest_framework.filters.SearchFilter'
138 ),
139 'DEFAULT_AUTHENTICATION_CLASSES': (
140 'rest_framework.authentication.SessionAuthentication',
141 'rest_framework.authentication.TokenAuthentication'
142 ),
143 'DEFAULT_PAGINATION_CLASS': (
144 'rest_framework.pagination.LimitOffsetPagination'
145 )
146}
147
148LOGIN_REDIRECT_URL = "/api/docs/"
149
150# PAC Gateway setup
151CFDI_DEFAULT_VERSION = '3.2'
152CFDI_IR_SCHEMA_PATH = os.path.join(BASE_DIR, 'share', 'schemas',
153 'comprobante.json')
154
155PAC_GATEWAY_ENCRYPTION_KEY = os.environ.get('PAC_GATEWAY_ENCRYPTION_KEY', '')
156
157FINKOK_USERNAME = os.environ.get('FINKOK_USERNAME', '')
158FINKOK_PASSWORD = os.environ.get('FINKOK_PASSWORD', '')
159
160PAC_GATEWAY_AVAIL_SHEETS_WARNING_PCT = 0.125
161
162PAC_GATEWAY_DEFAULT_CERTIFICATION_DAYS = 3
163
164PAC_GATEWAY_FROM_EMAIL = "support@f-ambit.mx"
165
166# SAT Formats
167SAT_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S'
168
169# Default prefixes
170PAC_GATEWAY_DEFAULT_GLOBAL_INVOICE_PREFIX = 'FG'
171PAC_GATEWAY_DEFAULT_GLOBAL_CREDIT_NOTE_PREFIX = 'NCG'
172PAC_GATEWAY_DEFAULT_CREDIT_NOTE_PREFIX = 'NC'
173
174# Payment form strings
175PAC_GATEWAY_PAYMENT_FORM_SINGLE = 'Pago en una sola exhibición'
176PAC_GATEWAY_PAYMENT_FORM_MULTIPLE = 'Parcialidad {part} de {total_parts}'
177
178# Invoice defaults
179PAC_GATEWAY_DEFAULT_SAT_PAYMENT_METHOD = '01'
180PAC_GATEWAY_DEFAULT_UNIT = 'Unidad'
181
182PAC_GATEWAY_INSTALLED_APPS = {
183 'lightspeed-retail': ('pac_gateway.applications.lightspeed'
184 '.retail.LightSpeedRetailHandler')
185}
186
187DEFAULT_PAF_CONFIG = {
188 'palette': {
189 'bg': '#F9F9F9',
190 'header_bg': '#FDFDFD',
191 'container_bg': '#FFFFFF',
192 'title_bg': '#E31818',
193 'form_footer_bg': '#F5F5F5',
194 'footer_bg': '#FDFDFD',
195 'primary_button_bg': '#E31818',
196 'secondary_button_bg': '#A0A0A0',
197 'font_color': '#838383',
198 'title_color': '#FFFFFF',
199 'link_color': '#337AB7',
200 'primary_button_color': '#FFFFFF',
201 'secondary_button_color': '#FFFFFF',
202 'form_footer_color': '#838383',
203 'footer_color': '#838383'
204 }
205}
206
207# Invoice PDF setup
208
209INVOICE_PDF_PAGESIZE = 'letter'
210INVOICE_PDF_ORIENTATION = 'portrait'
211INVOICE_PDF_MARGIN = '1cm'
212INVOICE_PDF_PADDING = '0'
213
214# Swagger settings
215SWAGGER_SETTINGS = {
216 'api_version': '0.1',
217 'api_path': '/api/v1/',
218 'enabled_methods': [
219 'get',
220 'post',
221 ],
222 'is_authenticated': True,
223 'permission_denied_handler': 'pac_gateway.cfd.views.permission_denied_handler',
224 'info': {
225 'contact': 'team@uakami.com',
226 'description': 'API Pac Gateway to search, claim and stamp invoices. ',
227 # 'license': 'Apache 2.0',
228 # 'licenseUrl': 'http://www.apache.org/licenses/LICENSE-2.0.html',
229 # 'termsOfServiceUrl': 'http://helloreverb.com/terms/',
230 'title': 'Ambit - API Pac Gateway',
231 }
232}
233
234# Anymail settings
235ANYMAIL = {
236 "MAILGUN_API_KEY": os.environ.get('MAILGUN_API_KEY', None)
237}
238
239EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend"
240DEFAULT_FROM_EMAIL = "no-reply@f-ambit.mx"