~robbyoconnor/sahana-eden/surveytool

« back to all changes in this revision

Viewing changes to models/04_pr.py

  • Committer: Robert O'Connor
  • Date: 2010-09-29 13:36:11 UTC
  • mfrom: (840.1.453 eden)
  • Revision ID: robby.oconnor@gmail.com-20100929133611-r13rs4q65v1r1ed7
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
resource = "address"
26
26
tablename = "%s_%s" % (module, resource)
27
27
table = db.define_table(tablename,
28
 
                        timestamp, authorstamp, uuidstamp, deletion_status,
29
28
                        pe_id,
30
29
                        Field("type",
31
30
                              "integer",
41
40
                        Field("city"),
42
41
                        Field("state"),
43
42
                        pr_country,
44
 
                        location_id,
45
 
                        Field("comment"),
 
43
                        location_id(),
 
44
                        comments(),
 
45
                        *s3_meta_fields(),
46
46
                        migrate=migrate)
47
47
 
48
48
 
118
118
resource = "pe_contact"
119
119
tablename = "%s_%s" % (module, resource)
120
120
table = db.define_table(tablename,
121
 
                        timestamp, authorstamp, uuidstamp, deletion_status,
122
121
                        pe_id,
123
122
                        Field("name"),
124
123
                        Field("contact_method",
131
130
                        Field("contact_person"),
132
131
                        Field("priority"),
133
132
                        Field("value", notnull=True),
134
 
                        Field("comment"),
 
133
                        comments(),
 
134
                        *s3_meta_fields(),
135
135
                        migrate=migrate)
136
136
 
137
137
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
202
202
resource = "image"
203
203
tablename = "%s_%s" % (module, resource)
204
204
table = db.define_table(tablename,
205
 
                        timestamp, authorstamp, uuidstamp, deletion_status,
206
205
                        pe_id,
207
206
                        Field("type", "integer",
208
207
                              requires = IS_IN_SET(pr_image_type_opts, zero=None),
213
212
                        Field("image", "upload", autodelete=True),
214
213
                        Field("url"),
215
214
                        Field("description"),
216
 
                        Field("comment"),
 
215
                        comments(),
 
216
                        *s3_meta_fields(),
217
217
                        migrate=migrate)
218
218
 
219
219
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
220
220
 
221
221
table.title.requires = IS_NOT_EMPTY()
222
222
table.title.comment = DIV(SPAN("*", _class="req", _style="padding-right: 5px;"), DIV(_class="tooltip",
223
 
    _title=Tstr("Title") + "|" + Tstr("Specify a descriptive title for the image.")))
 
223
    _title=T("Title") + "|" + T("Specify a descriptive title for the image.")))
224
224
 
225
225
table.url.label = T("URL")
226
226
table.url.represent = lambda url: url and DIV(A(IMG(_src=url, _height=60), _href=url)) or T("None")
227
227
table.url.comment =  DIV(SPAN("*", _class="req", _style="padding-right: 5px;"), DIV(_class="tooltip",
228
 
    _title=Tstr("URL") + "|" + Tstr("The URL of the image file. If you don't upload an image file, then you must specify its location here.")))
 
228
    _title=T("URL") + "|" + T("The URL of the image file. If you don't upload an image file, then you must specify its location here.")))
229
229
 
230
230
table.image.comment =  DIV(SPAN("*", _class="req", _style="padding-right: 5px;"), DIV(_class="tooltip",
231
 
    _title=Tstr("Image") + "|" + Tstr("Upload an image file here. If you don't upload an image file, then you must specify its location in the URL field.")))
 
231
    _title=T("Image") + "|" + T("Upload an image file here. If you don't upload an image file, then you must specify its location in the URL field.")))
232
232
table.image.represent = lambda image: image and \
233
233
        DIV(A(IMG(_src=URL(r=request, c="default", f="download", args=image),_height=60, _alt=T("View Image")),
234
234
              _href=URL(r=request, c="default", f="download", args=image))) or \
235
235
        T("No Image")
236
236
 
237
237
table.description.comment =  DIV(_class="tooltip",
238
 
    _title=Tstr("Description") + "|" + Tstr("Give a brief description of the image, e.g. what can be seen where on the picture (optional)."))
 
238
    _title=T("Description") + "|" + T("Give a brief description of the image, e.g. what can be seen where on the picture (optional)."))
239
239
 
240
240
 
241
241
# -----------------------------------------------------------------------------
305
305
#
306
306
pr_presence_condition_opts = vita.presence_conditions
307
307
 
308
 
orig_id = db.Table(None, "orig_id",
309
 
                   Field("orig_id", db.gis_location,
310
 
                         requires = IS_NULL_OR(IS_ONE_OF(db, "gis_location.id", "%(name)s")),
311
 
                         represent = lambda id: (id and [A(db(db.gis_location.id==id).select(db.gis_location.name, limitby=(0, 1)).first().name, _href="#", _onclick="s3_viewMap(" + str(id) +");return false")] or [""])[0],
312
 
                         label = T("Origin"),
313
 
                         comment = DIV(A(ADD_LOCATION,
314
 
                                         _class="colorbox",
315
 
                                         _href=URL(r=request, c="gis", f="location", args="create", vars=dict(format="popup")),
316
 
                                         _target="top",
317
 
                                         _title=ADD_LOCATION),
318
 
                                       DIV(DIV(_class="tooltip",
319
 
                                               _title=Tstr("Location") + "|" + Tstr("The Location of this Site, which can be general (for Reporting) or precise (for displaying on a Map).")))),
320
 
                         ondelete = "RESTRICT"
321
 
                        )
322
 
                  )
323
 
 
324
 
dest_id = db.Table(None, "dest_id",
325
 
                   Field("dest_id", db.gis_location,
326
 
                         requires = IS_NULL_OR(IS_ONE_OF(db, "gis_location.id", "%(name)s")),
327
 
                         represent = lambda id: (id and [A(db(db.gis_location.id == id).select(db.gis_location.name, limitby=(0, 1)).first().name, _href="#", _onclick="s3_viewMap(" + str(id) +");return false")] or [""])[0],
328
 
                         label = T("Destination"),
329
 
                         comment = DIV(A(ADD_LOCATION,
330
 
                                         _class="colorbox",
331
 
                                         _href=URL(r=request, c="gis", f="location", args="create", vars=dict(format="popup")),
332
 
                                         _target="top",
333
 
                                         _title=ADD_LOCATION),
334
 
                                       DIV(DIV(_class="tooltip",
335
 
                                               _title=Tstr("Location") + "|" + Tstr("The Location of this Site, which can be general (for Reporting) or precise (for displaying on a Map).")))),
336
 
                         ondelete = "RESTRICT"
337
 
                        )
338
 
                  )
339
 
 
340
 
 
341
308
# -----------------------------------------------------------------------------
342
309
resource = "presence"
343
310
tablename = "%s_%s" % (module, resource)
344
311
table = db.define_table(tablename,
345
 
                        timestamp, authorstamp, uuidstamp, deletion_status,
346
312
                        pe_id,
347
313
                        Field("reporter", db.pr_person),
348
314
                        Field("observer", db.pr_person),
349
315
                        Field("shelter_id", "integer"),
350
 
                        location_id,
 
316
                        location_id(),
351
317
                        Field("location_details"),
352
 
                        Field("datetime", "datetime"), # 'time' is a reserved word in Postgres
 
318
                        Field("datetime", "datetime"),
353
319
                        Field("presence_condition", "integer",
354
320
                              requires = IS_IN_SET(pr_presence_condition_opts,
355
321
                                                   zero=None),
358
324
                              represent = lambda opt: \
359
325
                                          pr_presence_condition_opts.get(opt, UNKNOWN_OPT)),
360
326
                        Field("proc_desc"),
361
 
                        orig_id,
362
 
                        dest_id,
 
327
                        location_id("orig_id", label=T("Origin")),
 
328
                        location_id("dest_id", label=T("Destination")),
363
329
                        Field("comment"),
364
330
                        Field("closed", "boolean", default=False),
 
331
                        *s3_meta_fields(),
365
332
                        migrate=migrate)
366
333
 
367
334
 
370
337
table.observer.requires = IS_NULL_OR(IS_ONE_OF(db, "pr_person.id", shn_pr_person_represent, orderby="pr_person.first_name"))
371
338
table.observer.represent = lambda id: (id and [shn_pr_person_represent(id)] or ["None"])[0]
372
339
table.observer.comment = shn_person_comment(
373
 
        Tstr("Observer"),
374
 
        Tstr("Person who observed the presence (if different from reporter)."))
 
340
        T("Observer"),
 
341
        T("Person who observed the presence (if different from reporter)."))
375
342
table.observer.ondelete = "RESTRICT"
376
343
 
377
344
table.reporter.requires = IS_NULL_OR(IS_ONE_OF(db, "pr_person.id", shn_pr_person_represent, orderby="pr_person.first_name"))
378
345
table.reporter.represent = lambda id: (id and [shn_pr_person_represent(id)] or ["None"])[0]
379
346
table.reporter.comment = shn_person_comment(
380
 
        Tstr("Reporter"),
381
 
        Tstr("Person who is reporting about the presence."))
 
347
        T("Reporter"),
 
348
        T("Person who is reporting about the presence."))
382
349
table.reporter.ondelete = "RESTRICT"
383
350
 
384
351
table.datetime.requires = IS_UTC_DATETIME(utc_offset=shn_user_utc_offset(), allow_future=False)
492
459
#
493
460
resource = "pe_subscription"
494
461
tablename = "%s_%s" % (module, resource)
495
 
table = db.define_table(tablename, timestamp, uuidstamp, deletion_status,
496
 
                pe_id,
497
 
                Field("resource"),
498
 
                Field("record"), # type="s3uuid"
499
 
                Field("comment"),
500
 
                migrate=migrate)
 
462
table = db.define_table(tablename,
 
463
                        pe_id,
 
464
                        Field("resource"),
 
465
                        Field("record"), # type="s3uuid"
 
466
                        comments(),
 
467
                        *s3_meta_fields(),
 
468
                        migrate=migrate)
501
469
 
502
470
 
503
471
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
556
524
resource = "identity"
557
525
tablename = "%s_%s" % (module, resource)
558
526
table = db.define_table(tablename,
559
 
                        timestamp, authorstamp, uuidstamp, deletion_status,
560
 
                        person_id,
 
527
                        person_id(),
561
528
                        Field("type", "integer",
562
529
                              requires = IS_IN_SET(pr_id_type_opts, zero=None),
563
530
                              default = 1,
570
537
                        Field("ia_name"), # Name of issuing authority
571
538
                        #Field("ia_subdivision"), # Name of issuing authority subdivision
572
539
                        #Field("ia_code"), # Code of issuing authority (if any)
573
 
                        Field("comment"),
 
540
                        comments(),
 
541
                        *s3_meta_fields(),
574
542
                        migrate=migrate)
575
543
 
576
544
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
715
683
    resource = "physical_description"
716
684
    tablename = "%s_%s" % (module, resource)
717
685
    table = db.define_table(tablename,
718
 
                            timestamp, authorstamp, uuidstamp, deletion_status,
719
686
                            pe_id,
720
687
 
721
688
                            # Race and complexion
812
779
                            # Other details
813
780
                            Field("other_details", "text"),
814
781
 
815
 
                            Field("comment"),
 
782
                            comments(),
 
783
                            *s3_meta_fields(),
816
784
                            migrate=migrate)
817
785
 
818
786
    table.height_cm.comment = DIV(DIV(_class="tooltip",
819
 
        _title=Tstr("Height") + "|" + Tstr("The body height (crown to heel) in cm.")))
 
787
        _title=T("Height") + "|" + T("The body height (crown to heel) in cm.")))
820
788
    table.weight_kg.comment = DIV(DIV(_class="tooltip",
821
 
        _title=Tstr("Weight") + "|" + Tstr("The weight in kg.")))
 
789
        _title=T("Weight") + "|" + T("The weight in kg.")))
822
790
 
823
791
    table.pe_id.readable = False
824
792
    table.pe_id.writable = False