forked from code4romania/redirectioneaza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
103 lines (82 loc) · 4.09 KB
/
main.py
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
import webapp2
from os import environ
from appengine_config import SESSION_SECRET_KEY, DEV
from webapp2_extras import routes
from webapp2 import Route as r
from controllers.site import *
from controllers.account_management import *
from controllers.my_account import *
from controllers.api import *
from controllers.admin import *
from controllers.ngo import NgoHandler, TwoPercentHandler, DonationSucces
from cron import cron_routes
config = {
'webapp2_extras.auth': {
'user_model': 'models.user.User',
'user_attributes': ['first_name']
},
# by default the session backend is the cookie
# cookie_name: session
# session_max_age: None => until the client is closed
'webapp2_extras.sessions': {
'secret_key': SESSION_SECRET_KEY,
# just make it as the default
'cookie_name': 'session',
'cookie_args': {
# make the cookie secure only if we are on production
# we can't use the config DEV bool, because if we set that manually to False, in order
# to test prod locally, the cookie will not work
# so make sure the cookie are set to secure only in production
'secure': not environ.get('SERVER_SOFTWARE', 'Development').startswith('Development'),
'httponly': True
}
}
}
# use string in dotted notation to be lazily imported
app = webapp2.WSGIApplication([
# the public part of the app
r('/', handler=HomePage),
r('/ong', handler=ForNgoHandler),
# backup in case of old urls. to be removed
r('/pentru-ong-uri', handler=ForNgoHandler),
r('/asociatii', handler=NgoListHandler),
r('/termeni', handler=TermsHandler),
r('/TERMENI', handler=TermsHandler),
r('/nota-de-informare', handler=NoteHandler, name='note'),
r('/politica', handler=PolicyHandler),
r('/despre', handler=AboutHandler),
# account management
r('/cont-nou', handler=SignupHandler),
r('/login', handler=LoginHandler, name='login'),
r('/logout', handler=LogoutHandler, name='logout'),
r('/forgot', handler=ForgotPasswordHandler, name='forgot'),
# verification url: used for signup, and reset password
r('/<type:v|p>/<user_id:\d+>-<signup_token:.+>', handler=VerificationHandler, name='verification'),
r('/password', handler=SetPasswordHandler),
# my account
r('/contul-meu', handler=MyAccountHandler, name='contul-meu'),
r('/asociatia', handler=NgoDetailsHandler, name='asociatia'),
r('/date-cont', handler=MyAccountDetailsHandler, name='date-contul-meu'),
r('/api/ngo/check-url/<ngo_url>', handler=CheckNgoUrl, name='api-ngo-check-url'),
r('/api/ngo/upload-url', handler=GetUploadUrl, name='api-ngo-upload-url'),
r('/api/ngo/form/<ngo_url>', handler=GetNgoForm, name='api-ngo-form-url'),
r('/api/ngos', handler=NgosApi, name='api-ngos'),
# ADMIN HANDLERS
r('/admin', handler=AdminHandler, name='admin'),
r('/admin/conturi', handler=UserAccounts, name='admin-users'),
r('/admin/campanii', handler=SendCampaign, name='admin-campanii'),
r('/admin/ong-nou', handler=AdminNewNgoHandler, name='admin-ong-nou'),
r('/admin/<ngo_url>', handler=AdminNgoHandler, name='admin-ong'),
r('/<ngo_url>', handler=NgoHandler, name="ngo-url"),
r('/catre/<ngo_url>', handler=NgoHandler),
r('/<ngo_url>/doilasuta', handler=TwoPercentHandler, name="twopercent"),
r('/<ngo_url>/doilasuta/succes', handler=DonationSucces, name="ngo-twopercent-success"),
routes.PathPrefixRoute("/cron", cron_routes),
],
debug=True,
config=config
)
# error handling for 404 and 500
# imported from controllers.site
# app.error_handlers[404] = NotFoundPage
# app.error_handlers[500] = InternalErrorPage