__init__.py 4.11 KB
Newer Older
1

Krishnakant Mane's avatar
Krishnakant Mane committed
2
"""
abhi1tb's avatar
abhi1tb committed
3
Copyright (C) 2013, 2014, 2015, 2016 Digital Freedom Foundation
Abhijith Balan's avatar
Abhijith Balan committed
4
Copyright (C) 2017, 2018 Digital Freedom Foundation & Accion Labs 
5
6
7
  This file is part of GNUKhata:A modular,robust and Free Accounting System.

  GNUKhata is Free Software; you can redistribute it and/or modify
abhi1tb's avatar
abhi1tb committed
8
  it under the terms of the GNU Affero General Public License as
9
  published by the Free Software Foundation; either version 3 of
10
  the License, or (at your option) any later version.
11
12
13
14

  GNUKhata is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
abhi1tb's avatar
abhi1tb committed
15
  GNU Affero General Public License for more details.
16

abhi1tb's avatar
abhi1tb committed
17
  You should have received a copy of the GNU Affero General Public
18
19
20
21
22
  License along with GNUKhata (COPYING); if not, write to the
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA  02110-1301  USA59 Temple Place, Suite 330,


abhi1tb's avatar
abhi1tb committed
23
Contributors:
24
25
26
"Krishnakant Mane" <kk@gmail.com>
"Ishan Masdekar " <imasdekar@dff.org.in>
"Navin Karkera" <navin@dff.org.in>
27
"Prajkta Patkar"<prajakta@dff.org.in>
28

Krishnakant Mane's avatar
Krishnakant Mane committed
29

30
31
32
33
34
35
36
Main entry point:
This package initializer module is run when the application is served.
The module contains enum dict containing all gnukahta success and failure messages.
It also contains all the routes which are connected to respective resources.
To trace the link of the routes we look at the name of a route and then see where it appeares in any of the @view_defaults or @view_config decorator of any resource.
This module also scanns for the secret from the database which is then used for jwt authentication.
"""
Krishnakant Mane's avatar
Krishnakant Mane committed
37

38
from pyramid.config import Configurator
Navin Karkera's avatar
Navin Karkera committed
39
from gkcore.models.meta import dbconnect
40
from gkcore.views import *
41
42
43
from webob import request
from webob.request import Request
from wsgicors import CORS
44
try:
45
46
47
48
49
    eng = dbconnect()
    resultset = eng.execute("select * from signature")
    row = resultset.fetchone()
    secret = row[0]
    #print secret
50
except:
51
    secret = ""
52

53
enumdict = {"Success":0,"DuplicateEntry":1,"UnauthorisedAccess":2,"ConnectionFailed":3,"BadPrivilege":4, "ActionDisallowed":5}
54

55

56
57
                        

58
def main(global_config, **settings):
abhi1tb's avatar
abhi1tb committed
59
60
    config = Configurator(settings=settings)
    config.add_route("organisation","/organisation")
ishan masdekar's avatar
ishan masdekar committed
61
    config.add_route("invoice","/invoice")
abhi1tb's avatar
abhi1tb committed
62
    config.add_route("organisations","/organisations")
63
    config.add_route("categoryspecs","/categoryspecs")
abhi1tb's avatar
abhi1tb committed
64
65
66
67
68
69
70
71
72
    config.add_route("orgyears","/orgyears/{orgname}/{orgtype}")
    config.add_route("transaction","/transaction")
    config.add_route("users",'/users')
    config.add_route('user','/user')
    config.add_route('bankrecon','/bankrecon')
    config.add_route("accounts",'/accounts')
    config.add_route("account",'/account/{accountcode}')
    config.add_route("projects",'/projects')
    config.add_route("project",'/project/{projectcode}')
73
    config.add_route("customersupplier",'/customersupplier')
74
    config.add_route("unitofmeasurement","/unitofmeasurement")
abhi1tb's avatar
abhi1tb committed
75
76
77
78
79
80
81
82
83
    config.add_route("accountsbyrule",'/accountsbyrule')
    config.add_route("login",'/login')
    config.add_route("groupallsubgroup","/groupallsubgroup/{groupcode}")
    config.add_route("groupsubgroup","/groupsubgroup/{groupcode}")
    config.add_route("groupsubgroups","/groupsubgroups")
    config.add_route("groupDetails","/groupDetails/{groupcode}")
    config.add_route("report","/report")
    config.add_route("rollclose","/rollclose")
    config.add_route("forgotpassword","/forgotpassword")
84
    config.add_route("categories","/categories")
Navin Karkera's avatar
Navin Karkera committed
85
    config.add_route("products","/products")
86
    config.add_route("godown","/godown")
Navin Karkera's avatar
Navin Karkera committed
87
    config.add_route("delchal","/delchal")
Bhavesh's avatar
Bhavesh committed
88
    config.add_route("purchaseorder","/purchaseorder")
Prajkta_Patkar's avatar
Prajkta_Patkar committed
89
    config.add_route("transfernote","/transfernote")
Prajkta_Patkar's avatar
Prajkta_Patkar committed
90
    config.add_route("discrepancynote","/discrepancynote")
bhagyashri194's avatar
bhagyashri194 committed
91
    config.add_route("tax","/tax")
Bhavesh's avatar
Bhavesh committed
92
    config.add_route("log", "/log")
Bhavesh's avatar
Bhavesh committed
93
    config.add_route("rejectionnote", "/rejectionnote")
94
    config.add_route('billwise','/billwise')
95
    config.add_route("state","/state")
abhi1tb's avatar
abhi1tb committed
96
    config.scan("gkcore.views")
97

abhi1tb's avatar
abhi1tb committed
98
    return CORS(config.make_wsgi_app(),headers="*",methods="*",maxage="180",origin="*")