134
134
message_id = db.Table(None, "message_id",
135
135
FieldS3("message_id", db.msg_log,
136
136
requires = IS_NULL_OR(IS_ONE_OF(db, "msg_log.id")),
137
represent = lambda id: db(db.msg_log.id == id).select(db.msg_log.subject, limitby=(0, 1)).first().subject,
137
138
ondelete = "RESTRICT"
158
160
# The following was added to show only the supported messaging methods
159
161
msg_contact_method_opts = { # pr_contact_method dependency
161
163
2:T("Mobile Phone"),
165
# Outbox - needs to be separate to Log since a single message sent needs different outbox entries for each recipient
163
166
resource = "outbox"
164
167
tablename = "%s_%s" % (module, resource)
165
168
table = db.define_table(tablename, timestamp, uuidstamp, deletion_status,
167
170
pe_id, # Person/Group to send the message out to
168
171
Field("address"), # If set used instead of picking up from pe_id
169
Field("pr_message_method",
171
requires = IS_IN_SET(msg_contact_method_opts, zero=None),
173
label = T("Contact Method"),
174
represent = lambda opt: msg_contact_method_opts.get(opt, UNKNOWN_OPT)),
172
Field("pr_message_method", "integer",
173
requires = IS_IN_SET(msg_contact_method_opts, zero=None),
175
label = T("Contact Method"),
176
represent = lambda opt: msg_contact_method_opts.get(opt, UNKNOWN_OPT)),
176
178
Field("system_generated", "boolean", default = False),
180
182
s3xrc.model.add_component(module, resource,
182
joinby=dict(msg_log="message_id"),
184
joinby=dict(msg_log="message_id"),
186
188
table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
187
189
s3xrc.model.configure(table,