Merge lp:~graeme-acm/sahana-eden/LA into lp:sahana-eden/la
- LA
- Merge into la
Proposed by
Graeme Foster
Status: | Merged |
---|---|
Merged at revision: | 2557 |
Proposed branch: | lp:~graeme-acm/sahana-eden/LA |
Merge into: | lp:sahana-eden/la |
Diff against target: |
235 lines (+59/-92) 5 files modified
models/vol.py (+37/-66) modules/s3/s3import.py (+6/-6) modules/s3/s3rest.py (+1/-2) modules/s3/s3widgets.py (+1/-4) private/prepopulate/demo/LA/req_req.csv (+14/-14) |
To merge this branch: | bzr merge lp:~graeme-acm/sahana-eden/LA |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Fran Boon | Pending | ||
Review via email: mp+71155@code.launchpad.net |
Commit message
Description of the change
Got application_
Fixed some bugs in branch
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'models/vol.py' |
2 | --- models/vol.py 2011-08-10 19:44:18 +0000 |
3 | +++ models/vol.py 2011-08-11 06:41:45 +0000 |
4 | @@ -163,60 +163,25 @@ |
5 | """ |
6 | |
7 | req = form.request_vars.req_id |
8 | - rstable = db.req_req_skill |
9 | - query = (rstable.req_id == req) |
10 | - record = db(query).select(rstable.quantity, |
11 | - rstable.quantity_commit, |
12 | + rrtable = db.req_req |
13 | + query = (rrtable.id == req) |
14 | + record = db(query).select(rrtable.request_number, |
15 | limitby=(0, 1)).first() |
16 | - if record and \ |
17 | - record.quantity > record.quantity_commit: |
18 | + if record: |
19 | # Lookup the Report To |
20 | - rtable = db.req_req |
21 | - _req = db(rtable.id == req).select(rtable.request_for_id, |
22 | - limitby=(0, 1)).first() |
23 | - if _req: |
24 | - report_to = _req.request_for_id |
25 | - else: |
26 | - report_to = None |
27 | - # Add Assignment |
28 | - table = db.vol_assignment |
29 | - assign = table.insert(req_id = req, |
30 | - person_id = s3_logged_in_person(), |
31 | - report_to_id = report_to) |
32 | - # Update Commit Quantity in Req |
33 | - query = (table.req_id == req) & \ |
34 | - (table.deleted == False) |
35 | - rows = db(query).select(table.number) |
36 | - qty = 0 |
37 | - for row in rows: |
38 | - qty = qty + row.number |
39 | - if qty >= record.quantity: |
40 | - commit_status = 2 # Complete (defined in models/req.py) |
41 | - else: |
42 | - commit_status = 1 # Partial |
43 | - db(rstable.req_id == req).update(quantity_commit = qty) |
44 | - db(rtable.id == req).update(commit_status = commit_status) |
45 | - if commit_status == 2: |
46 | - # Mail out Volunteer Roster |
47 | - response.s3.vol_rostermail(req) |
48 | - |
49 | - session.confirmation = T("Your application has been successful - please notify us if you are unable to attend") |
50 | - redirect(URL(c="vol", f="req", args=["assignment", assign])) |
51 | - #s3mgr.configure("vol_assignment", |
52 | - # create_next = URL(c="vol", |
53 | - # f="req", |
54 | - # args=["assignment", assign])) |
55 | - |
56 | - else: |
57 | - session.warning = T("Unfortunately this Request is already full - please apply for another") |
58 | - redirect(URL(c="vol", f="req_skill")) |
59 | - #s3mgr.configure("vol_assignment", |
60 | - # create_next = URL(c="vol", |
61 | - # f="req_skill")) |
62 | - |
63 | + (result, assign) = application_manage_totals(record.request_number, s3_logged_in_person()) |
64 | + if result == False: |
65 | + session.warning = T("Unfortunately this Request is already full - please apply for another") |
66 | + redirect(URL(c="vol", f="req_skill")) |
67 | + else: |
68 | + if result == "Full": |
69 | + # Mail out Volunteer Roster |
70 | + response.s3.vol_rostermail(req) |
71 | + session.confirmation = T("Your application has been successful - please notify us if you are unable to attend") |
72 | + redirect(URL(c="vol", f="req", args=["assignment", assign])) |
73 | return |
74 | |
75 | - def application_onaccept(req_num): |
76 | + def application_manage_totals(req_num, person_id): |
77 | """ |
78 | Check whether full |
79 | if full: |
80 | @@ -237,19 +202,25 @@ |
81 | limitby=(0, 1)).first() |
82 | if record and \ |
83 | record.req_req_skill.quantity > record.req_req_skill.quantity_commit: |
84 | - # Lookup the Report To |
85 | req_id = record.req_req.id |
86 | - _req = db(rrtable.id == req_id).select(rrtable.request_for_id, |
87 | - limitby=(0, 1)).first() |
88 | - if _req: |
89 | - report_to = _req.request_for_id |
90 | - else: |
91 | - report_to = None |
92 | - # Add Assignment |
93 | - vatable = db.vol_assignment |
94 | - query = (vatable.req_id == req_id) & \ |
95 | - (vatable.deleted == False) |
96 | - rows = db(query).select(vatable.number) |
97 | + if person_id != None: |
98 | + # Lookup the Report To |
99 | + _req = db(rrtable.id == req_id).select(rrtable.request_for_id, |
100 | + limitby=(0, 1)).first() |
101 | + if _req: |
102 | + report_to = _req.request_for_id |
103 | + else: |
104 | + report_to = None |
105 | + |
106 | + # Add Assignment |
107 | + vastable = db.vol_assignment |
108 | + assign = vastable.insert(req_id = req_id, |
109 | + person_id = person_id, |
110 | + report_to_id = report_to) |
111 | + # Calculate the number of people assigned to a request |
112 | + query = (vastable.req_id == req_id) & \ |
113 | + (vastable.deleted == False) |
114 | + rows = db(query).select(vastable.number) |
115 | qty = 0 |
116 | for row in rows: |
117 | qty = qty + row.number |
118 | @@ -260,11 +231,11 @@ |
119 | db(rstable.req_id == req_id).update(quantity_commit = qty) |
120 | db(rrtable.id == req_id).update(commit_status = commit_status) |
121 | if commit_status == 2: |
122 | - return "Full" |
123 | + return ("Full", assign) |
124 | else: |
125 | - return True |
126 | + return (True, assign) |
127 | else: |
128 | - return False |
129 | + return (False, False) |
130 | return |
131 | |
132 | def vol_application_onaccept_csv(req_csv): |
133 | @@ -273,7 +244,7 @@ |
134 | for r in csvReader: |
135 | # this relies on the named field being in the import file |
136 | reqNum = r["Request Number"] |
137 | - application_onaccept(reqNum) |
138 | + application_manage_totals(reqNum, None) |
139 | |
140 | |
141 | |
142 | |
143 | === modified file 'modules/s3/s3import.py' |
144 | --- modules/s3/s3import.py 2011-08-10 22:12:05 +0000 |
145 | +++ modules/s3/s3import.py 2011-08-11 06:41:45 +0000 |
146 | @@ -661,12 +661,12 @@ |
147 | ignore_errors = True, |
148 | commit = False, |
149 | ) |
150 | -# # debug diagnostics validation errors |
151 | -# if t != None: |
152 | -# dump = StringIO() |
153 | -# t.write(dump, pretty_print=True) |
154 | -# _debug(dump.getvalue()) |
155 | -# print >> sys.stderr, dump.getvalue() |
156 | + # debug diagnostics validation errors |
157 | + if t != None: |
158 | + dump = StringIO() |
159 | + t.write(dump, pretty_print=True) |
160 | + _debug(dump.getvalue()) |
161 | + print >> sys.stderr, dump.getvalue() |
162 | # # @todo: make this available on the UI in advanced mode |
163 | if job == True: |
164 | # no elements found |
165 | |
166 | === modified file 'modules/s3/s3rest.py' |
167 | --- modules/s3/s3rest.py 2011-08-10 15:13:21 +0000 |
168 | +++ modules/s3/s3rest.py 2011-08-11 06:41:45 +0000 |
169 | @@ -3327,7 +3327,6 @@ |
170 | t = s |
171 | elif format == "json": |
172 | if isinstance(s, basestring): |
173 | - from StringIO import StringIO |
174 | source = StringIO(s) |
175 | t = xml.json2tree(s) |
176 | else: |
177 | @@ -3359,7 +3358,7 @@ |
178 | commit=commit) |
179 | self.files = Storage() |
180 | |
181 | - # debug diagnostics |
182 | +# # debug diagnostics |
183 | # if tree != None: |
184 | # dump = StringIO() |
185 | # tree.getroottree().write(dump, pretty_print=True) |
186 | |
187 | === modified file 'modules/s3/s3widgets.py' |
188 | --- modules/s3/s3widgets.py 2011-08-10 18:13:43 +0000 |
189 | +++ modules/s3/s3widgets.py 2011-08-11 06:41:45 +0000 |
190 | @@ -157,10 +157,7 @@ |
191 | |
192 | earliest = earliest.strftime(format) |
193 | latest = latest.strftime(format) |
194 | - |
195 | - earliest = earliest.strftime(format) |
196 | - latest = latest.strftime(format) |
197 | - |
198 | + |
199 | default = dict( |
200 | _type = "text", |
201 | _class = "anytime", # Prevent default "datetime" calendar from showing up |
202 | |
203 | === modified file 'private/prepopulate/demo/LA/req_req.csv' |
204 | --- private/prepopulate/demo/LA/req_req.csv 2011-08-09 20:28:46 +0000 |
205 | +++ private/prepopulate/demo/LA/req_req.csv 2011-08-11 06:41:45 +0000 |
206 | @@ -1,15 +1,15 @@ |
207 | "Scenario","Event","Request Type","Request Number","Date Requested","Priority","Purpose","Date Required","Date Required Until","Requester","Assigned To","Approved by","Requested for","Requested for Facility","Transportation Required","Security Required","Public","Date Delivered","Received by","Comments" |
208 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#01","07-24-2011 12:00:00","Medium","Provide refreshments to people coming to the Poinsettia Recreation Center Family Assistance Center to get information","09-26-2011 10:00:00","09-26-2011 20:00:00","Frank Bone","Joe Bloggs","Jeff Wayne","Curran Spencer","San Gabriel Pomona Valley Chapter","T","T","F","07-26-2011 9:15:00",, |
209 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#02","07-24-2011 12:15:00","High","Transportation required","09-26-2011 10:00:00","09-26-2011 20:00:00","Frank Bone","Jeff Wayne","Joe Bloggs","Curran Spencer","San Gabriel Pomona Valley Chapter","F","F","F",,, |
210 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#03","07-24-2011 12:00:00","Low","Additional water will be needed","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Curran Spencer","San Gabriel Pomona Valley Chapter","F","F","F",,, |
211 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#04","07-24-2011 12:15:00","High","Drivers are needed to be on stand-by","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
212 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#05","07-24-2011 12:15:00","Medium","We need people to prepare and hand out refreshments","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
213 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#06","07-24-2011 12:15:00","High","We need people to hand out information and welcome people","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
214 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#07","07-24-2011 12:20:00","Low","We need people to take donations","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
215 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#08","07-24-2011 12:20:00","Medium","We need some posters to be designed","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
216 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#09","07-24-2011 12:20:00","Medium","We need some security guards","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
217 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#10","07-24-2011 12:20:00","Medium","We need people to help plan the event","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
218 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#11","07-24-2011 12:20:00","Medium","We need people to take photographs of the event","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
219 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#12","07-24-2011 12:20:00","Medium","We need people to write up a summary of the event","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
220 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#13","07-24-2011 12:20:00","Medium","We need people to clear up afterward","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
221 | -"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#14","07-24-2011 12:20:00","Medium","We need people to man the telephones and answer queries","09-26-2011 10:00:00","09-26-2011 20:00:00","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","F",,, |
222 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#01","2011-07-24 12:00:00","Medium","Provide refreshments to people coming to the Poinsettia Recreation Center Family Assistance Center to get information","2011-09-26 10:00:00","2011-09-26 20:00:00","Frank Bone","Joe Bloggs","Jeff Wayne","Curran Spencer","San Gabriel Pomona Valley Chapter","T","T","F","07-26-2011 9:15:00",, |
223 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#02","2011-07-24 12:00:01","High","Transportation required","2011-09-26 10:00:01","2011-09-26 20:00:01","Frank Bone","Jeff Wayne","Joe Bloggs","Curran Spencer","San Gabriel Pomona Valley Chapter","F","F","F",,, |
224 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Inventory Items","LAUREL_CANYON*07_2011#03","2011-07-24 12:00:02","Low","Additional water will be needed","2011-09-26 10:00:02","2011-09-26 20:00:02","Joe Bloggs","Jeff Wayne","Frank Bone","Curran Spencer","San Gabriel Pomona Valley Chapter","F","F","F",,, |
225 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#04","2011-07-24 12:00:03","High","Drivers are needed to be on stand-by","2011-09-26 10:00:03","2011-09-26 20:00:03","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
226 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#05","2011-07-24 12:00:04","Medium","We need people to prepare and hand out refreshments","2011-09-26 10:00:04","2011-09-26 20:00:04","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
227 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#06","2011-07-24 12:00:05","High","We need people to hand out information and welcome people","2011-09-26 10:00:05","2011-09-26 20:00:05","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
228 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#07","2011-07-24 12:00:06","Low","We need people to take donations","2011-09-26 10:00:06","2011-09-26 20:00:06","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
229 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#08","2011-07-24 12:00:07","Medium","We need some posters to be designed","2011-09-26 10:00:07","2011-09-26 20:00:07","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
230 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#09","2011-07-24 12:00:08","Medium","We need some security guards","2011-09-26 10:00:08","2011-09-26 20:00:08","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
231 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#10","2011-07-24 12:00:09","Medium","We need people to help plan the event","2011-09-26 10:00:09","2011-09-26 20:00:09","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
232 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#11","2011-07-24 12:00:10","Medium","We need people to take photographs of the event","2011-09-26 10:00:10","2011-09-26 20:00:10","Joe Bloggs","Jeff Wayne","Frank Bone","Iliana Hurley","San Gabriel Pomona Valley Chapter","F","F","T",,, |
233 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#12","2011-07-24 12:00:11","Medium","We need people to write up a summary of the event","2011-09-26 10:00:11","2011-09-26 20:00:11","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
234 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#13","2011-07-24 12:00:12","Medium","We need people to clear up afterward","2011-09-26 10:00:12","2011-09-26 20:00:12","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","T",,, |
235 | +"Summer 2011 Forest Fires","Laurel Canyon Brush Fire","Volunteer","LAUREL_CANYON*07_2011#14","2011-07-24 12:00:13","Medium","We need people to man the telephones and answer queries","2011-09-26 10:00:13","2011-09-26 20:00:13","Joe Bloggs","Jeff Wayne","Frank Bone","Emerald Potter","San Gabriel Pomona Valley Chapter","F","F","F",,, |