~erobererunc/sahana-eden/tropo_xforms

« back to all changes in this revision

Viewing changes to models/vol.py

  • Committer: Michael
  • Date: 2010-12-16 13:45:28 UTC
  • mfrom: (1479.1.91 eden)
  • Revision ID: ero@gmail.com-20101216134528-7x3m6m3fk9uc9i69
mergeĀ fromĀ trunk...

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
                              multiple=False,
84
84
                              joinby=dict(pr_person="person_id"))
85
85
 
 
86
    def vol_onvalidation(form):
 
87
        status = form.vars.date_avail_start <= form.vars.date_avail_end
 
88
        if status:
 
89
            return status
 
90
        else:
 
91
            error_msg = T("End date should be after start date")
 
92
            #form.errors["date_avail_start"] = error_msg
 
93
            form.errors["date_avail_end"] = error_msg
 
94
            return status
 
95
 
86
96
    s3xrc.model.configure(table,
 
97
                          onvalidation=vol_onvalidation,
87
98
                          list_fields=["organisation_id",
88
99
                                       "status"])
89
100
 
115
126
    }
116
127
 
117
128
    vol_resource_status_opts = {
118
 
        1:T("approved"),
119
 
        2:T("unapproved"),
120
 
        3:T("denied")
 
129
        1:T("not needed"),
 
130
        2:T("pending"),
 
131
        3:T("approved"),
 
132
        4:T("unapproved"),
 
133
        5:T("denied")
121
134
    }
122
135
 
123
136
    resourcename = "resource"
191
204
 
192
205
 
193
206
    # Field settings
194
 
    table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % tablename)
195
 
    table.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, "%s.name" % tablename)]
 
207
    table.uuid.requires = IS_NOT_ONE_OF(db, "%s.uuid" % tablename)
 
208
    table.name.requires = [IS_NOT_EMPTY(), IS_NOT_ONE_OF(db, "%s.name" % tablename)]
196
209
    table.name.label = T("Name")
197
210
 
198
211
    # CRUD strings
235
248
 
236
249
    # -------------------------------------------------------------------------
237
250
    # vol_skill
238
 
    #   A volunteer's skills (component of pr)
 
251
    #   A volunteer's skills (component of PR)
239
252
    #
240
253
 
241
254
    resourcename = "skill"
244
257
                            person_id(),
245
258
                            skill_types_id(),
246
259
                            Field("status",
247
 
                                  requires=IS_IN_SET(["approved", "unapproved", "denied"]),
 
260
                                  requires=IS_IN_SET(vol_resource_status_opts),
248
261
                                  label=T("Status"),
249
262
                                  notnull=True,
250
 
                                  default="unapproved"),
 
263
                                  represent = lambda opt: vol_resource_status_opts.get(opt, UNKNOWN_OPT),
 
264
                                  # unapproved
 
265
                                  default=4),
251
266
                            migrate=migrate, *s3_meta_fields())
252
267
 
253
 
 
254
268
    s3xrc.model.add_component(module, resourcename,
255
 
        multiple=True,
256
 
        joinby=dict(pr_person="person_id"))
 
269
                              multiple=True,
 
270
                              joinby=dict(pr_person="person_id"))
257
271
 
258
272
    s3xrc.model.configure(table,
259
273
                          list_fields=["id",