213
212
Field("image", "upload", autodelete=True),
215
214
Field("description"),
219
219
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
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.")))
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.")))
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 \
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)."))
241
241
# -----------------------------------------------------------------------------
306
306
pr_presence_condition_opts = vita.presence_conditions
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],
313
comment = DIV(A(ADD_LOCATION,
315
_href=URL(r=request, c="gis", f="location", args="create", vars=dict(format="popup")),
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"
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,
331
_href=URL(r=request, c="gis", f="location", args="create", vars=dict(format="popup")),
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"
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,
347
313
Field("reporter", db.pr_person),
348
314
Field("observer", db.pr_person),
349
315
Field("shelter_id", "integer"),
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,
358
324
represent = lambda opt: \
359
325
pr_presence_condition_opts.get(opt, UNKNOWN_OPT)),
360
326
Field("proc_desc"),
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),
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(
374
Tstr("Person who observed the presence (if different from reporter)."))
341
T("Person who observed the presence (if different from reporter)."))
375
342
table.observer.ondelete = "RESTRICT"
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(
381
Tstr("Person who is reporting about the presence."))
348
T("Person who is reporting about the presence."))
382
349
table.reporter.ondelete = "RESTRICT"
384
351
table.datetime.requires = IS_UTC_DATETIME(utc_offset=shn_user_utc_offset(), allow_future=False)
493
460
resource = "pe_subscription"
494
461
tablename = "%s_%s" % (module, resource)
495
table = db.define_table(tablename, timestamp, uuidstamp, deletion_status,
498
Field("record"), # type="s3uuid"
462
table = db.define_table(tablename,
465
Field("record"), # type="s3uuid"
503
471
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
813
780
Field("other_details", "text"),
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.")))
823
791
table.pe_id.readable = False
824
792
table.pe_id.writable = False