@@ -29,6 +29,7 @@ def _type_to_template(output, strip_code):
29
29
30
30
31
31
class ReportMetadataConfig (HasTraits ):
32
+ '''Paperboy configuration object representing a Report (metadata component)'''
32
33
notebook = Instance (NotebookConfig )
33
34
job = Instance (JobConfig )
34
35
@@ -48,6 +49,7 @@ class ReportMetadataConfig(HasTraits):
48
49
modified = Instance (datetime )
49
50
50
51
def to_json (self , include_notebook = False ):
52
+ '''Convert ReportMetadata to a JSON'''
51
53
ret = {}
52
54
ret = {}
53
55
ret ['notebook' ] = self .notebook .name
@@ -76,6 +78,7 @@ def to_json(self, include_notebook=False):
76
78
77
79
@staticmethod
78
80
def from_json (jsn ):
81
+ '''Create ReportMetadata from a JSON'''
79
82
ret = ReportMetadataConfig ()
80
83
for k , v in jsn .items ():
81
84
if k in ('created' , 'modified' , 'run' ):
@@ -86,18 +89,21 @@ def from_json(jsn):
86
89
87
90
88
91
class ReportConfig (Base ):
92
+ '''Paperboy configuration object representing a Report'''
89
93
name = Unicode ()
90
94
id = Unicode ()
91
95
meta = Instance (ReportMetadataConfig )
92
96
93
97
def to_json (self , include_notebook = False ):
98
+ '''Convert Report to a JSON'''
94
99
ret = {}
95
100
ret ['name' ] = self .name
96
101
ret ['id' ] = self .id
97
102
ret ['meta' ] = self .meta .to_json (include_notebook )
98
103
return ret
99
104
100
105
def form (self ):
106
+ '''Generate Form template for client from a Report object'''
101
107
f = Response ()
102
108
f .entries = [
103
109
FormEntry (name = 'name' , type = 'text' , label = 'Name' , placeholder = 'Name for Report...' , required = True ),
@@ -114,6 +120,7 @@ def form(self):
114
120
115
121
@staticmethod
116
122
def from_json (jsn , config ):
123
+ '''Create Report from a JSON'''
117
124
ret = ReportConfig (config )
118
125
ret .name = jsn ['name' ]
119
126
ret .id = jsn ['id' ]
@@ -123,6 +130,7 @@ def from_json(jsn, config):
123
130
return ret
124
131
125
132
def edit (self ):
133
+ '''Generate Edit template for client from a Report object'''
126
134
f = Response ()
127
135
f .entries = [
128
136
FormEntry (name = 'name' , type = 'text' , value = self .name , label = 'Name' , placeholder = 'Name for Report...' , required = True ),
@@ -141,6 +149,7 @@ def edit(self):
141
149
return f .to_json ()
142
150
143
151
def entry (self ):
152
+ '''Generate ListTable entry for client from a Report object'''
144
153
f = Response ()
145
154
f .entries = [
146
155
DOMEntry (name = 'name' , type = 'label' , value = self .name , label = 'Name' ),
@@ -160,6 +169,7 @@ def entry(self):
160
169
return f .to_json ()
161
170
162
171
def store (self ):
172
+ '''Generate response modal for client when saving a Report object'''
163
173
ret = Response ()
164
174
ret .entries = [
165
175
DOMEntry (type = 'h2' , value = 'Success!' ),
0 commit comments