forked from fossasia/open-event-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting.py
More file actions
246 lines (211 loc) · 7.33 KB
/
setting.py
File metadata and controls
246 lines (211 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
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
39
40
41
42
43
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
from sqlalchemy.ext.hybrid import hybrid_property
from app.models import db
class Environment:
def __init__(self):
pass
DEVELOPMENT = 'development'
STAGING = 'staging'
PRODUCTION = 'production'
TESTING = 'testing'
class Setting(db.Model):
__tablename__ = 'settings'
id = db.Column(db.Integer, primary_key=True)
#
# General
#
app_environment = db.Column(db.String, default=Environment.PRODUCTION)
# Name of the application. (Eg. Event Yay!, Open Event)
app_name = db.Column(db.String)
# Tagline for the application. (Eg. Event Management and Ticketing, Home)
tagline = db.Column(db.String)
# Static domain
static_domain = db.Column(db.String)
# Order Expiry Time in Minutes
order_expiry_time = db.Column(db.Integer, default=15, nullable=False)
# Maximum number of complex custom fields allowed for a given form
max_complex_custom_fields = db.Column(db.Integer, default=30, nullable=False)
#
# STORAGE
#
# storage place, local, s3, .. can be more in future
storage_place = db.Column(db.String)
# S3
aws_key = db.Column(db.String)
aws_secret = db.Column(db.String)
aws_bucket_name = db.Column(db.String)
aws_region = db.Column(db.String)
# Google Storage
gs_key = db.Column(db.String)
gs_secret = db.Column(db.String)
gs_bucket_name = db.Column(db.String)
#
# CAPTCHA
#
# Google reCAPTCHA
is_google_recaptcha_enabled = db.Column(db.Boolean, default=False, nullable=False)
google_recaptcha_site = db.Column(db.String)
google_recaptcha_secret = db.Column(db.String)
#
# Social Login
#
# Google Auth
google_client_id = db.Column(db.String)
google_client_secret = db.Column(db.String)
# FB
fb_client_id = db.Column(db.String)
fb_client_secret = db.Column(db.String)
# Twitter
tw_consumer_key = db.Column(db.String)
tw_consumer_secret = db.Column(db.String)
# Instagram
in_client_id = db.Column(db.String)
in_client_secret = db.Column(db.String)
#
# Payment Gateway
#
# Stripe Keys
stripe_client_id = db.Column(db.String)
stripe_secret_key = db.Column(db.String)
stripe_publishable_key = db.Column(db.String)
stripe_test_client_id = db.Column(db.String)
stripe_test_secret_key = db.Column(db.String)
stripe_test_publishable_key = db.Column(db.String)
# AliPay Keys - Stripe Sources
alipay_secret_key = db.Column(db.String)
alipay_publishable_key = db.Column(db.String)
# Paypal credentials
paypal_mode = db.Column(db.String)
paypal_client = db.Column(db.String)
paypal_secret = db.Column(db.String)
paypal_sandbox_client = db.Column(db.String)
paypal_sandbox_secret = db.Column(db.String)
# Omise credentials
omise_mode = db.Column(db.String)
omise_live_public = db.Column(db.String)
omise_live_secret = db.Column(db.String)
omise_test_public = db.Column(db.String)
omise_test_secret = db.Column(db.String)
# payTM credentials
is_paytm_activated = db.Column(db.Boolean, default=False, nullable=False)
paytm_mode = db.Column(db.String)
paytm_live_merchant = db.Column(db.String)
paytm_live_secret = db.Column(db.String)
paytm_sandbox_merchant = db.Column(db.String)
paytm_sandbox_secret = db.Column(db.String)
#
# EMAIL
#
# Email service. (sendgrid,smtp)
email_service = db.Column(db.String)
email_from = db.Column(db.String)
email_from_name = db.Column(db.String)
# Sendgrid
sendgrid_key = db.Column(db.String)
# SMTP
smtp_host = db.Column(db.String)
smtp_username = db.Column(db.String)
smtp_password = db.Column(db.String)
smtp_port = db.Column(db.Integer)
smtp_encryption = db.Column(db.String) # Can be tls, ssl, none
# Google Analytics
analytics_key = db.Column(db.String)
#
# Social links
#
google_url = db.Column(db.String)
github_url = db.Column(db.String)
twitter_url = db.Column(db.String)
support_url = db.Column(db.String)
facebook_url = db.Column(db.String)
instagram_url = db.Column(db.String)
patreon_url = db.Column(db.String)
gitter_url = db.Column(db.String)
telegram_url = db.Column(db.String)
youtube_url = db.Column(db.String)
#
# Event Invoices settings
#
invoice_sending_day = db.Column(db.Integer, nullable=False, default=1)
invoice_sending_timezone = db.Column(db.String, nullable=False, default="UTC")
#
# Admin Invoice Details
#
admin_billing_contact_name = db.Column(db.String)
admin_billing_phone = db.Column(db.String)
admin_billing_email = db.Column(db.String)
admin_billing_country = db.Column(db.String)
admin_billing_state = db.Column(db.String)
admin_billing_tax_info = db.Column(db.String)
admin_company = db.Column(db.String)
admin_billing_address = db.Column(db.String)
admin_billing_city = db.Column(db.String)
admin_billing_zip = db.Column(db.String)
admin_billing_additional_info = db.Column(db.String)
admin_billing_paypal_email = db.Column(db.String)
#
# Generators
#
android_app_url = db.Column(db.String)
web_app_url = db.Column(db.String)
frontend_url = db.Column(db.String, default="http://eventyay.com")
#
# Cookie Policy
#
cookie_policy = db.Column(
db.String,
default="This website, and certain approved third parties, use functional, "
"analytical and tracking cookies (or similar technologies) to understand your "
"event preferences and provide you with a customized experience. "
"By closing this banner or by continuing to use the site, you agree. "
"For more information please review our cookie policy.",
)
cookie_policy_link = db.Column(
db.String, default="https://next.eventyay.com/cookie-policy"
)
@hybrid_property
def is_paypal_activated(self):
if (
self.paypal_mode == 'sandbox'
and self.paypal_sandbox_client
and self.paypal_sandbox_secret
):
return True
if self.paypal_client and self.paypal_secret:
return True
return False
@hybrid_property
def is_stripe_activated(self):
return self.stripe_client_id is not None
def __repr__(self):
return 'Settings'
@hybrid_property
def is_alipay_activated(self):
return bool(self.alipay_publishable_key and self.alipay_secret_key)
@hybrid_property
def is_omise_activated(self):
if (
self.omise_mode == 'test'
and self.omise_test_public
and self.omise_test_secret
):
return True
if self.omise_live_public and self.omise_live_secret:
return True
return False
@property
def is_billing_paypal_activated(self):
return self.admin_billing_paypal_email is not None
def get_full_billing_address(self, sep: str = '\n') -> str:
return sep.join(
filter(
None,
[
self.admin_billing_address,
self.admin_billing_city,
self.admin_billing_state,
self.admin_billing_zip,
self.admin_billing_country,
],
)
)
full_billing_address = property(get_full_billing_address)