__init__.py
2.93 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
import os
from pyramid.events import BeforeRender, subscriber
from tangsel.base import get_params
from tangsel.tools import get_settings
from tangsel.tools import create_static_path
from tangsel.base import get_params, BaseApp
class AppModels(BaseApp):
# sspd_by_kode digunakan untuk no_urut dari1 setiap tahun berdasarkan kode
def __init__(self):
super().__init__()
self.base_dir = os.path.split(__file__)[0]
self.mirror_url = "" # URL ke API PBB
self.files = ""
self.files_bukti = ""
self.files_tpl = ""
self.files_draft = ""
self.files_final = ""
self.uri = "" # URL untuk internal
self.url = "" # URL untuk download/verifikasi
self.unoconv = ""
self.http_server = ""
self.mirror_url = ""
self.bsre_url = ""
def init(self):
settings = get_settings()
self.mirror_url = settings.get('pbb_esppt_mirror.url', "")
self.bsre_url = settings.get('pbb_esppt_bsre.url', "")
self.bsre_ttd_img = settings.get('pbb_esppt_bsre_ttd_img', "")
self.files = get_params(
"pbb_esppt_files", settings.get("pbb_esppt_files", ""))
if not self.files:
raise ValueError('pbb_esppt_files Not Found in config.')
sep = os.sep
if sep != '/':
# sep = "/"
self.files = self.files.replace('/', '\\')
self.files += sep
else:
self.files += sep
self.files_tpl = self.files + f"tpl{sep}"
self.files_bukti = self.files + f"bukti{sep}"
self.files_draft = self.files+ f"draft{sep}"
self.files_final = self.files + f"final{sep}"
self.captcha_files = get_params(
"captcha_files", settings.get("captcha_files", ""))
self.uri = 'pbb/esppt/files'
sppt_url = settings.get("esppt_url", "/".join([self.uri, "final"]))
self.url = settings.get("esppt_file_url",sppt_url)
if self.url.find("http") < 0:
self.http_server = settings.get("_host", "http://localhost:6543")
self.url = self.http_server+'/'+self.url
# self.menus = get_module_menus("esppt")
# add_view_config(config, "esppt", "tangsel.pbb.esppt.views")
def static_views(self, config):
create_static_path(config, self.files, self.uri, 0)
# URL Khusus untuk eksternal
create_static_path(config, self.files_final, self.uri+'/final', 0)
# def get_menus(self):
# _logging.info(self.menus)
# return self.menus
SPPT_CLASS = AppModels()
def includeme(config):
SPPT_CLASS.init()
SPPT_CLASS.static_views(config)
# SPPT_CLASS.route_from_list(config, routes, paket="tangsel.pbb.esppt")
SPPT_CLASS.route_from_csv(config, "tangsel.pbb.esppt.views")
config.scan(".")
print("+", __name__, "includeme class loaded")
@subscriber(BeforeRender)
def add_global(event):
event['get_esppt_menus'] = SPPT_CLASS.get_menus