Status: | Merged |
---|---|
Approved by: | Arturo |
Approved revision: | 52 |
Merged at revision: | 50 |
Proposed branch: | lp:~seif/globaleaks/demo |
Merge into: | lp:globaleaks/demo |
Diff against target: |
496 lines (+301/-153) 5 files modified
.bzrignore (+1/-0) applications/globaleaks/models/db.py (+2/-153) applications/globaleaks/modules/logic/datamodel.py (+154/-0) applications/globaleaks/modules/logic/db.py (+67/-0) applications/globaleaks/modules/logic/globaleaks.py (+77/-0) |
To merge this branch: | bzr merge lp:~seif/globaleaks/demo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Arturo | Approve | ||
Review via email: mp+73818@code.launchpad.net |
This proposal supersedes a proposal from 2011-09-02.
Commit message
Description of the change
Clean up code
moved all globaleaks logic into modules
To post a comment you must log in.
Revision history for this message
Arturo (hellais) wrote : | # |
Revision history for this message
Arturo (hellais) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-09-01 15:27:04 +0000 | |||
3 | +++ .bzrignore 2011-09-02 13:56:08 +0000 | |||
4 | @@ -34,3 +34,4 @@ | |||
5 | 34 | material/* | 34 | material/* |
6 | 35 | applications/globaleaks/cache/cache.lock | 35 | applications/globaleaks/cache/cache.lock |
7 | 36 | applications/globaleaks/cache/cache.shelve | 36 | applications/globaleaks/cache/cache.shelve |
8 | 37 | applications/admin/cache/* | ||
9 | 37 | 38 | ||
10 | === removed file 'applications/admin/cache/cache.lock' | |||
11 | === removed file 'applications/admin/cache/cache.shelve' | |||
12 | 38 | Binary files applications/admin/cache/cache.shelve 2011-08-28 08:06:54 +0000 and applications/admin/cache/cache.shelve 1970-01-01 00:00:00 +0000 differ | 39 | Binary files applications/admin/cache/cache.shelve 2011-08-28 08:06:54 +0000 and applications/admin/cache/cache.shelve 1970-01-01 00:00:00 +0000 differ |
13 | === modified file 'applications/globaleaks/models/db.py' | |||
14 | --- applications/globaleaks/models/db.py 2011-09-01 15:27:04 +0000 | |||
15 | +++ applications/globaleaks/models/db.py 2011-09-02 13:56:08 +0000 | |||
16 | @@ -20,158 +20,8 @@ | |||
17 | 20 | db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB | 20 | db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB |
18 | 21 | """ | 21 | """ |
19 | 22 | randomizer = local_import('randomizer') | 22 | randomizer = local_import('randomizer') |
172 | 23 | 23 | db = local_import('logic.db').DB() | |
173 | 24 | class DB(DAL): | 24 | gl = local_import('logic.globaleaks').Globaleaks(db) |
22 | 25 | def __init__(self): | ||
23 | 26 | DAL.__init__(self, 'sqlite://storage.db') | ||
24 | 27 | self.create_db() | ||
25 | 28 | |||
26 | 29 | def create_db(self): | ||
27 | 30 | self.define_table('target', | ||
28 | 31 | Field('name'), | ||
29 | 32 | Field('category'), | ||
30 | 33 | Field('desc'), | ||
31 | 34 | Field('url'), | ||
32 | 35 | Field('type'), | ||
33 | 36 | Field('info'), | ||
34 | 37 | Field('status'), | ||
35 | 38 | Field('last_sent_tulip'), | ||
36 | 39 | Field('last_access'), | ||
37 | 40 | Field('last_download'), | ||
38 | 41 | Field('tulip_counter'), | ||
39 | 42 | Field('dowload_counter'), | ||
40 | 43 | format='%(name)s' | ||
41 | 44 | ) | ||
42 | 45 | |||
43 | 46 | self.define_table('leak', | ||
44 | 47 | Field('title'), | ||
45 | 48 | Field('desc'), | ||
46 | 49 | Field('submission_timestamp'), | ||
47 | 50 | Field('leaker_id', self.target), | ||
48 | 51 | Field('spooled', 'boolean', False), | ||
49 | 52 | format='%(name)s' | ||
50 | 53 | ) | ||
51 | 54 | |||
52 | 55 | self.define_table('comment', | ||
53 | 56 | Field('leak_id', self.leak), | ||
54 | 57 | Field('commenter_id', self.target), | ||
55 | 58 | Field('comment'), | ||
56 | 59 | format='%(name)s' | ||
57 | 60 | ) | ||
58 | 61 | |||
59 | 62 | self.define_table('material', | ||
60 | 63 | Field('url', unique=True), | ||
61 | 64 | Field('leak_id', self.leak), | ||
62 | 65 | Field('type'), | ||
63 | 66 | format='%(name)s' | ||
64 | 67 | ) | ||
65 | 68 | |||
66 | 69 | self.define_table('tulip', | ||
67 | 70 | Field('url', unique=True), | ||
68 | 71 | Field('leak_id', self.leak), | ||
69 | 72 | Field('target_id'), | ||
70 | 73 | Field('allowed_accesses'), | ||
71 | 74 | Field('accesses_counter'), | ||
72 | 75 | Field('allowed_downloads'), | ||
73 | 76 | Field('downloads_counter'), | ||
74 | 77 | Field('expiry_time'), | ||
75 | 78 | format='%(name)s' | ||
76 | 79 | ) | ||
77 | 80 | |||
78 | 81 | self.define_table('mail', | ||
79 | 82 | Field('target'), | ||
80 | 83 | Field('address'), | ||
81 | 84 | Field('tulip', unique=True), | ||
82 | 85 | format='%(name)s' | ||
83 | 86 | ) | ||
84 | 87 | |||
85 | 88 | db = DB() | ||
86 | 89 | |||
87 | 90 | |||
88 | 91 | #XXX remove for non demo functionality | ||
89 | 92 | # | ||
90 | 93 | |||
91 | 94 | |||
92 | 95 | #### | ||
93 | 96 | # The main GlobaLeaks Class | ||
94 | 97 | ### | ||
95 | 98 | |||
96 | 99 | class Globaleaks(object): | ||
97 | 100 | |||
98 | 101 | def __init__(self): | ||
99 | 102 | pass | ||
100 | 103 | |||
101 | 104 | def create_target(self, name, category, desc, url, type, info): | ||
102 | 105 | target_id = db.target.insert(name=name, | ||
103 | 106 | category=category, | ||
104 | 107 | desc = desc, url=url, type=type, info=info, | ||
105 | 108 | status="subscribed" #, last_send_tulip=None, | ||
106 | 109 | #last_access=None, last_download=None, | ||
107 | 110 | #tulip_counter=None, download_counter=None | ||
108 | 111 | ) | ||
109 | 112 | db.commit() | ||
110 | 113 | return target_id | ||
111 | 114 | |||
112 | 115 | def delete_target (self, id): | ||
113 | 116 | db(db.target.id==id).delete() | ||
114 | 117 | pass | ||
115 | 118 | |||
116 | 119 | def get_targets(self, target_set): | ||
117 | 120 | if target_set == "ANY": | ||
118 | 121 | return db(db.target).select() | ||
119 | 122 | return db(db.target.category==target_set).select() | ||
120 | 123 | |||
121 | 124 | def get_target(self, target_id): | ||
122 | 125 | return db(db.target.id==target_id).select().first() | ||
123 | 126 | |||
124 | 127 | def create_leak(self, title, desc, leaker, material, target_set, tags="", number=None): | ||
125 | 128 | #FIXME insert new tags into DB first | ||
126 | 129 | |||
127 | 130 | #Create leak and insert into DB | ||
128 | 131 | leak_id = db.leak.insert(title = title, desc = desc, | ||
129 | 132 | submission_timestamp = time.time(), | ||
130 | 133 | leaker_id = 0, spooled=False) | ||
131 | 134 | |||
132 | 135 | targets = gl.get_targets(target_set) | ||
133 | 136 | |||
134 | 137 | for t in targets: | ||
135 | 138 | #Create a tulip for each target and insert into DB | ||
136 | 139 | #for target_url, allowed_downloads in targets.iteritems(): | ||
137 | 140 | db.tulip.insert(url = randomizer.generate_tulip_url(), | ||
138 | 141 | leak_id = leak_id, | ||
139 | 142 | target_id = t.id, #FIXME get target_id_properly | ||
140 | 143 | allowed_accesses = 0, # inf | ||
141 | 144 | accesses_counter = 0, | ||
142 | 145 | allowed_downloads = 5, | ||
143 | 146 | downloads_counter = 0, | ||
144 | 147 | expiry_time = 0) | ||
145 | 148 | |||
146 | 149 | db.tulip.insert(url = number, | ||
147 | 150 | leak_id = leak_id, | ||
148 | 151 | target_id = 0, #FIXME get target_id_properly | ||
149 | 152 | allowed_accesses = 0, # inf | ||
150 | 153 | accesses_counter = 0, | ||
151 | 154 | allowed_downloads = 5, | ||
152 | 155 | downloads_counter = 0, | ||
153 | 156 | expiry_time = 0) | ||
154 | 157 | |||
155 | 158 | db.commit() | ||
156 | 159 | return leak_id | ||
157 | 160 | |||
158 | 161 | def get_leaks(self): | ||
159 | 162 | pass | ||
160 | 163 | |||
161 | 164 | def get_leak(self, leak_id): | ||
162 | 165 | pass | ||
163 | 166 | |||
164 | 167 | def get_tulips(self, leak_id): | ||
165 | 168 | pass | ||
166 | 169 | |||
167 | 170 | def get_tulip(self, tulip_id): | ||
168 | 171 | pass | ||
169 | 172 | |||
170 | 173 | |||
171 | 174 | |||
174 | 175 | 25 | ||
175 | 176 | #### | 26 | #### |
176 | 177 | # For the time being just use sqlite | 27 | # For the time being just use sqlite |
177 | @@ -267,4 +117,3 @@ | |||
178 | 267 | def formatter(self, value): | 117 | def formatter(self, value): |
179 | 268 | return format(value) | 118 | return format(value) |
180 | 269 | 119 | ||
181 | 270 | gl = Globaleaks() | ||
182 | 271 | 120 | ||
183 | === added directory 'applications/globaleaks/modules/logic' | |||
184 | === added file 'applications/globaleaks/modules/logic/__init__.py' | |||
185 | === added file 'applications/globaleaks/modules/logic/datamodel.py' | |||
186 | --- applications/globaleaks/modules/logic/datamodel.py 1970-01-01 00:00:00 +0000 | |||
187 | +++ applications/globaleaks/modules/logic/datamodel.py 2011-09-02 13:56:08 +0000 | |||
188 | @@ -0,0 +1,154 @@ | |||
189 | 1 | import time | ||
190 | 2 | |||
191 | 3 | # web2py's funny way to import "local" modules | ||
192 | 4 | #db = local_import('sql').db | ||
193 | 5 | #randomizer = local_import('randomizer') | ||
194 | 6 | |||
195 | 7 | randomizer = local_import('randomizer') | ||
196 | 8 | |||
197 | 9 | class Leak(object): | ||
198 | 10 | def __init__(self, id): | ||
199 | 11 | self._id = id | ||
200 | 12 | |||
201 | 13 | def get_id(self): | ||
202 | 14 | return self._id | ||
203 | 15 | def set_id(self): | ||
204 | 16 | print "Error: id is read only" | ||
205 | 17 | pass | ||
206 | 18 | id = property(get_id, set_id) | ||
207 | 19 | |||
208 | 20 | def get_title(self): | ||
209 | 21 | return db.leak[self.id].title | ||
210 | 22 | def set_title(self, title): | ||
211 | 23 | db.leak[self.id] = dict(title = title) | ||
212 | 24 | db.commit() | ||
213 | 25 | title = property(get_title, set_title) | ||
214 | 26 | |||
215 | 27 | #TODO:implement get/set tags | ||
216 | 28 | def set_tags(self): | ||
217 | 29 | pass | ||
218 | 30 | def get_tags(self): | ||
219 | 31 | pass | ||
220 | 32 | tags = property(get_tags, set_tags) | ||
221 | 33 | |||
222 | 34 | def get_desc(self): | ||
223 | 35 | return db.leak[self.id].desc | ||
224 | 36 | def set_desc(self, desc): | ||
225 | 37 | db.leak[self.id].desc = desc | ||
226 | 38 | db.commit() | ||
227 | 39 | desc = property(get_desc, set_desc) | ||
228 | 40 | |||
229 | 41 | #TODO: implement get/set material | ||
230 | 42 | def get_material(self): | ||
231 | 43 | pass | ||
232 | 44 | def set_material(self, material): | ||
233 | 45 | pass | ||
234 | 46 | material = property(get_material, set_material) | ||
235 | 47 | |||
236 | 48 | #TODO: implement get/set targets | ||
237 | 49 | def get_targets(self): | ||
238 | 50 | pass | ||
239 | 51 | def set_targets(self, targets): | ||
240 | 52 | pass | ||
241 | 53 | targets = property(get_targets, set_targets) | ||
242 | 54 | |||
243 | 55 | def get_submission_timestamp(self): | ||
244 | 56 | return db.leak[self.id].submission_timestamp | ||
245 | 57 | def set_submission_timstamp(self, timestamp): | ||
246 | 58 | print "Error: submission_timestamp is read only" | ||
247 | 59 | pass | ||
248 | 60 | submission_timestamp = property(get_submission_timestamp, set_submission_timstamp) | ||
249 | 61 | |||
250 | 62 | def get_leaker(self): | ||
251 | 63 | pass | ||
252 | 64 | def set_leaker(self, leaker): | ||
253 | 65 | print "Error: leaker is read only" | ||
254 | 66 | pass | ||
255 | 67 | leaker = property(get_leaker, set_leaker) | ||
256 | 68 | |||
257 | 69 | def get_tulips(self): | ||
258 | 70 | for tulip_id in db(db.tulip.leak_id==self._id).select(db.tulip.id): | ||
259 | 71 | yield Tulip(tulip_id["id"]) | ||
260 | 72 | |||
261 | 73 | def set_tulips(self, tulips): | ||
262 | 74 | print "Error: tulip is read only" | ||
263 | 75 | pass | ||
264 | 76 | tulips = property(get_tulips, set_tulips) | ||
265 | 77 | |||
266 | 78 | |||
267 | 79 | class Tulip(object): | ||
268 | 80 | def __init__(self, id=None, url=None): | ||
269 | 81 | if url: | ||
270 | 82 | self._id = db(db.tulip.url==url).select().first().id | ||
271 | 83 | else: | ||
272 | 84 | self._id = id | ||
273 | 85 | |||
274 | 86 | def get_id(self): | ||
275 | 87 | return self._id | ||
276 | 88 | def set_id(self, id): | ||
277 | 89 | print "Error: id is read only" | ||
278 | 90 | pass | ||
279 | 91 | id = property(get_id, set_id) | ||
280 | 92 | |||
281 | 93 | def get_url(self): | ||
282 | 94 | return db.tulip[self.id].url | ||
283 | 95 | def set_url(self, url): | ||
284 | 96 | print "Error: url is read only" | ||
285 | 97 | pass | ||
286 | 98 | url = property(get_url, set_url) | ||
287 | 99 | |||
288 | 100 | def get_target(self): | ||
289 | 101 | return db.tulip[self.id].target_id | ||
290 | 102 | def set_target(self, target): | ||
291 | 103 | print "Error: target is read only" | ||
292 | 104 | pass | ||
293 | 105 | target = property(get_target, set_target) | ||
294 | 106 | |||
295 | 107 | def get_allowed_accesses(self): | ||
296 | 108 | return db.tulip[self.id].allowed_accesses | ||
297 | 109 | def set_allowed_accesses(self, allowed_accesses): | ||
298 | 110 | db.tulip[self.id].update_record(allowed_accessess=allowed_accesses) | ||
299 | 111 | db.commit() | ||
300 | 112 | allowed_accesses = property(get_allowed_accesses, set_allowed_accesses) | ||
301 | 113 | |||
302 | 114 | def get_accesses_counter(self): | ||
303 | 115 | return db.tulip[self.id].accesses_counter | ||
304 | 116 | def set_accesses_counter(self, accesses_counter): | ||
305 | 117 | db.tulip[self.id].update_record(accesses_counter=accesses_counter) | ||
306 | 118 | db.commit() | ||
307 | 119 | accesses_counter = property(get_accesses_counter, set_accesses_counter) | ||
308 | 120 | |||
309 | 121 | def get_allowed_downloads(self): | ||
310 | 122 | return db.tulip[self.id].allowed_downloads | ||
311 | 123 | def set_allowed_downloads(self, allowed_downloads): | ||
312 | 124 | db.tulip[self.id].update_record(allowed_downloads=allowed_downloads) | ||
313 | 125 | db.commit() | ||
314 | 126 | allowed_downloads = property(get_allowed_downloads, set_allowed_downloads) | ||
315 | 127 | |||
316 | 128 | def get_downloads_counter(self): | ||
317 | 129 | return db.tulip[self.id].downloads_counter | ||
318 | 130 | def set_downloads_counter(self, downloads_counter): | ||
319 | 131 | db.tulip[self.id].update_record(downloads_counter=downloads_counter) | ||
320 | 132 | db.commit() | ||
321 | 133 | downloads_counter = property(get_downloads_counter, set_downloads_counter) | ||
322 | 134 | |||
323 | 135 | def get_leak(self): | ||
324 | 136 | return Leak(db.tulip[self.id].leak_id) | ||
325 | 137 | def set_leak(self): | ||
326 | 138 | print "Error: leak is read only" | ||
327 | 139 | pass | ||
328 | 140 | leak = property(get_leak, set_leak) | ||
329 | 141 | |||
330 | 142 | |||
331 | 143 | |||
332 | 144 | # FIXME move to better location | ||
333 | 145 | class NOT_IMPLEMENTED(object): | ||
334 | 146 | def __init__(self, a, error_message='This function is not implemented: visit http://blueprints.launchpad.net/globaleaks/+spec/%s'): | ||
335 | 147 | self.e = error_message % a | ||
336 | 148 | def __call__(self, value): | ||
337 | 149 | if value == "off" or not value: | ||
338 | 150 | return (value, None) | ||
339 | 151 | return (value, self.e) | ||
340 | 152 | def formatter(self, value): | ||
341 | 153 | return format(value) | ||
342 | 154 | |||
343 | 0 | 155 | ||
344 | === added file 'applications/globaleaks/modules/logic/db.py' | |||
345 | --- applications/globaleaks/modules/logic/db.py 1970-01-01 00:00:00 +0000 | |||
346 | +++ applications/globaleaks/modules/logic/db.py 2011-09-02 13:56:08 +0000 | |||
347 | @@ -0,0 +1,67 @@ | |||
348 | 1 | from gluon import DAL, Field | ||
349 | 2 | |||
350 | 3 | class DB(DAL): | ||
351 | 4 | def __init__(self): | ||
352 | 5 | DAL.__init__(self, 'sqlite://storage.db') | ||
353 | 6 | self.create_db() | ||
354 | 7 | |||
355 | 8 | def create_db(self): | ||
356 | 9 | self.define_table('target', | ||
357 | 10 | Field('name'), | ||
358 | 11 | Field('category'), | ||
359 | 12 | Field('desc'), | ||
360 | 13 | Field('url'), | ||
361 | 14 | Field('type'), | ||
362 | 15 | Field('info'), | ||
363 | 16 | Field('status'), | ||
364 | 17 | Field('last_sent_tulip'), | ||
365 | 18 | Field('last_access'), | ||
366 | 19 | Field('last_download'), | ||
367 | 20 | Field('tulip_counter'), | ||
368 | 21 | Field('dowload_counter'), | ||
369 | 22 | format='%(name)s' | ||
370 | 23 | ) | ||
371 | 24 | |||
372 | 25 | self.define_table('leak', | ||
373 | 26 | Field('title'), | ||
374 | 27 | Field('desc'), | ||
375 | 28 | Field('submission_timestamp'), | ||
376 | 29 | Field('leaker_id', self.target), | ||
377 | 30 | Field('spooled', 'boolean', False), | ||
378 | 31 | format='%(name)s' | ||
379 | 32 | ) | ||
380 | 33 | |||
381 | 34 | self.define_table('comment', | ||
382 | 35 | Field('leak_id', self.leak), | ||
383 | 36 | Field('commenter_id', self.target), | ||
384 | 37 | Field('comment'), | ||
385 | 38 | format='%(name)s' | ||
386 | 39 | ) | ||
387 | 40 | |||
388 | 41 | self.define_table('material', | ||
389 | 42 | Field('url', unique=True), | ||
390 | 43 | Field('leak_id', self.leak), | ||
391 | 44 | Field('type'), | ||
392 | 45 | format='%(name)s' | ||
393 | 46 | ) | ||
394 | 47 | |||
395 | 48 | self.define_table('tulip', | ||
396 | 49 | Field('url', unique=True), | ||
397 | 50 | Field('leak_id', self.leak), | ||
398 | 51 | Field('target_id'), | ||
399 | 52 | Field('allowed_accesses'), | ||
400 | 53 | Field('accesses_counter'), | ||
401 | 54 | Field('allowed_downloads'), | ||
402 | 55 | Field('downloads_counter'), | ||
403 | 56 | Field('expiry_time'), | ||
404 | 57 | format='%(name)s' | ||
405 | 58 | ) | ||
406 | 59 | |||
407 | 60 | self.define_table('mail', | ||
408 | 61 | Field('target'), | ||
409 | 62 | Field('address'), | ||
410 | 63 | Field('tulip', unique=True), | ||
411 | 64 | format='%(name)s' | ||
412 | 65 | ) | ||
413 | 66 | |||
414 | 67 | db = DB() | ||
415 | 0 | 68 | ||
416 | === added file 'applications/globaleaks/modules/logic/globaleaks.py' | |||
417 | --- applications/globaleaks/modules/logic/globaleaks.py 1970-01-01 00:00:00 +0000 | |||
418 | +++ applications/globaleaks/modules/logic/globaleaks.py 2011-09-02 13:56:08 +0000 | |||
419 | @@ -0,0 +1,77 @@ | |||
420 | 1 | import randomizer | ||
421 | 2 | import time | ||
422 | 3 | |||
423 | 4 | class Globaleaks(object): | ||
424 | 5 | |||
425 | 6 | def __init__(self, db): | ||
426 | 7 | self._db = db | ||
427 | 8 | |||
428 | 9 | def create_target(self, name, category, desc, url, type, info): | ||
429 | 10 | target_id = self._db.target.insert(name=name, | ||
430 | 11 | category=category, | ||
431 | 12 | desc = desc, url=url, type=type, info=info, | ||
432 | 13 | status="subscribed" #, last_send_tulip=None, | ||
433 | 14 | #last_access=None, last_download=None, | ||
434 | 15 | #tulip_counter=None, download_counter=None | ||
435 | 16 | ) | ||
436 | 17 | self._db.commit() | ||
437 | 18 | return target_id | ||
438 | 19 | |||
439 | 20 | def delete_target (self, id): | ||
440 | 21 | self._db(self._db.target.id==id).delete() | ||
441 | 22 | pass | ||
442 | 23 | |||
443 | 24 | def get_targets(self, target_set): | ||
444 | 25 | if target_set == "ANY": | ||
445 | 26 | return self._db(self._db.target).select() | ||
446 | 27 | return self._db(self._db.target.category==target_set).select() | ||
447 | 28 | |||
448 | 29 | def get_target(self, target_id): | ||
449 | 30 | return self._db(self._db.target.id==target_id).select().first() | ||
450 | 31 | |||
451 | 32 | def create_leak(self, title, desc, leaker, material, target_set, tags="", number=None): | ||
452 | 33 | #FIXME insert new tags into DB first | ||
453 | 34 | |||
454 | 35 | #Create leak and insert into DB | ||
455 | 36 | leak_id = self._db.leak.insert(title = title, desc = desc, | ||
456 | 37 | submission_timestamp = time.time(), | ||
457 | 38 | leaker_id = 0, spooled=False) | ||
458 | 39 | |||
459 | 40 | targets = self.get_targets(target_set) | ||
460 | 41 | |||
461 | 42 | for t in targets: | ||
462 | 43 | #Create a tulip for each target and insert into DB | ||
463 | 44 | #for target_url, allowed_downloads in targets.iteritems(): | ||
464 | 45 | self._db.tulip.insert(url = randomizer.generate_tulip_url(), | ||
465 | 46 | leak_id = leak_id, | ||
466 | 47 | target_id = t.id, #FIXME get target_id_properly | ||
467 | 48 | allowed_accesses = 0, # inf | ||
468 | 49 | accesses_counter = 0, | ||
469 | 50 | allowed_downloads = 5, | ||
470 | 51 | downloads_counter = 0, | ||
471 | 52 | expiry_time = 0) | ||
472 | 53 | |||
473 | 54 | self._db.tulip.insert(url = number, | ||
474 | 55 | leak_id = leak_id, | ||
475 | 56 | target_id = 0, #FIXME get target_id_properly | ||
476 | 57 | allowed_accesses = 0, # inf | ||
477 | 58 | accesses_counter = 0, | ||
478 | 59 | allowed_downloads = 5, | ||
479 | 60 | downloads_counter = 0, | ||
480 | 61 | expiry_time = 0) | ||
481 | 62 | |||
482 | 63 | self._db.commit() | ||
483 | 64 | return leak_id | ||
484 | 65 | |||
485 | 66 | def get_leaks(self): | ||
486 | 67 | pass | ||
487 | 68 | |||
488 | 69 | def get_leak(self, leak_id): | ||
489 | 70 | pass | ||
490 | 71 | |||
491 | 72 | def get_tulips(self, leak_id): | ||
492 | 73 | pass | ||
493 | 74 | |||
494 | 75 | def get_tulip(self, tulip_id): | ||
495 | 76 | pass | ||
496 | 77 |
Good cleanup and proper reorganization of GlobaLeaks models and classes. Though still a lot of methods need to be properly implemented