~shikharkohli/sahana-eden/gsoc1

« back to all changes in this revision

Viewing changes to models/msg.py

  • Committer: Shikhar Kohli
  • Date: 2010-08-11 18:40:09 UTC
  • mfrom: (802.1.156 eden)
  • Revision ID: shikharkohli@gmail.com-20100811184009-yy8zag5dowlam0ip
Merge trunk and update (a bit) of JS

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
138
139
                ))
139
140
 
155
156
                                        "record_uuid",
156
157
                                        "resource",
157
158
                                       ])
 
159
 
158
160
    # The following was added to show only the supported messaging methods
159
161
    msg_contact_method_opts = { # pr_contact_method dependency
160
162
        1:T("E-Mail"),
161
163
        2:T("Mobile Phone"),
162
164
    }
 
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,
166
169
        message_id,
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",
170
 
                "integer",
171
 
                requires = IS_IN_SET(msg_contact_method_opts, zero=None),
172
 
                default = 1,
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),
 
174
              default = 1,
 
175
              label = T("Contact Method"),
 
176
              represent = lambda opt: msg_contact_method_opts.get(opt, UNKNOWN_OPT)),
175
177
        opt_msg_status,
176
178
        Field("system_generated", "boolean", default = False),
177
179
        Field("log"),
178
180
        migrate=migrate)
179
181
 
180
182
    s3xrc.model.add_component(module, resource,
181
 
                          multiple=True,
182
 
                          joinby=dict(msg_log="message_id"),
183
 
                          deletable=True,
184
 
                          editable=True)
 
183
                              multiple=True,
 
184
                              joinby=dict(msg_log="message_id"),
 
185
                              deletable=True,
 
186
                              editable=True)
185
187
 
186
188
    table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
187
189
    s3xrc.model.configure(table,
191
193
                                        "status",
192
194
                                        "log",
193
195
                                       ])
 
196
 
194
197
    # Message Read Status - To replace Message Outbox #TODO
195
198
    resource = "read_status"
196
199
    tablename = "%s_%s" % (module, resource)