Merge lp:~graeme-acm/sahana-eden/LA into lp:sahana-eden/la

Proposed by Graeme Foster
Status: Merged
Merged at revision: 2724
Proposed branch: lp:~graeme-acm/sahana-eden/LA
Merge into: lp:sahana-eden/la
Diff against target: 174 lines (+72/-31)
3 files modified
controllers/don.py (+25/-26)
models/vol.py (+43/-1)
modules/s3/s3export.py (+4/-4)
To merge this branch: bzr merge lp:~graeme-acm/sahana-eden/LA
Reviewer Review Type Date Requested Status
Fran Boon Pending
Review via email: mp+74588@code.launchpad.net

This proposal supersedes a proposal from 2011-09-08.

Description of the change

remove donation request button when a donation has not been selected

fixed log 213 "Org Commit: Too Many for Slot should throw back error"

add fix to log 306

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 'controllers/don.py'
2--- controllers/don.py 2011-09-07 02:47:29 +0000
3+++ controllers/don.py 2011-09-08 12:42:18 +0000
4@@ -164,34 +164,33 @@
5
6 # Defined in the Model for use from Multiple Controllers for unified menus
7 output = response.s3.req_controller()
8- if len(request.args) >0:
9- args = request.args[0]
10- else:
11- args = None
12- reportButtons = DIV(
13- BUTTON(T("Donation Request Form"),
14- _class="accept-button",
15- _onClick="javascript: window.location='%s'" % \
16- URL(c=request.controller,
17- f="req_print",
18- args=args
19- )
20- ),
21- # Also in controllers/vol.py - DRY
22- A(IMG(_src="/%s/static/img/get_adobe_reader.png" % request.application,
23- _title="%s - %s" % (T("Get Adobe Reader"),
24- T("This link will open a new browser window.")),
25- _alt=T("Get Adobe Reader"),
26- _width=158,
27- _height=39,
28- _style="float:right;"),
29- _href="http://www.adobe.com/products/acrobat/readstep2.html",
30- _target="_blank"),
31- )
32 if "rheader" in output:
33+ if len(request.args) >0:
34+ args = request.args[0]
35+ else:
36+ args = None
37+ reportButtons = DIV(
38+ BUTTON(T("Print Donation Request Form"),
39+ _class="accept-button",
40+ _onClick="javascript: window.location='%s'" % \
41+ URL(c=request.controller,
42+ f="req_print",
43+ args=args
44+ )
45+ ),
46+ # Also in controllers/vol.py - DRY
47+ A(IMG(_src="/%s/static/img/get_adobe_reader.png" % request.application,
48+ _title="%s - %s" % (T("Get Adobe Reader"),
49+ T("This link will open a new browser window.")),
50+ _alt=T("Get Adobe Reader"),
51+ _width=158,
52+ _height=39,
53+ _style="float:right;"),
54+ _href="http://www.adobe.com/products/acrobat/readstep2.html",
55+ _target="_blank"),
56+ )
57 output["rheader"].append(reportButtons)
58- else:
59- output["rheader"] = reportButtons
60+
61 return output
62
63 def req_print():
64
65=== modified file 'models/vol.py'
66--- models/vol.py 2011-09-07 22:52:59 +0000
67+++ models/vol.py 2011-09-08 12:42:18 +0000
68@@ -175,11 +175,12 @@
69 """
70 Check for DSW (interactive forms only)
71 """
72-
73 if isinstance(form, FORM):
74 # Interactive form
75 _vars = request.post_vars
76
77+ checkCommitmentLevels(request.args[0], None, form)
78+
79 # Check for DSW
80 if "dsw" not in _vars or _vars.dsw != "on":
81 form.errors.dsw = T("You must agree to these conditions to commit to a Request for Volunteers")
82@@ -537,6 +538,46 @@
83 list_fields=list_fields)
84
85 # ---------------------------------------------------------------------
86+ def assignment_onvalidate(form):
87+
88+ if isinstance(form, FORM):
89+ # Interactive form
90+ req_id = request.args[0]
91+ if len(request.args) > 2:
92+ vas_id = request.args[2]
93+ else:
94+ vas_id = None
95+ checkCommitmentLevels(req_id, vas_id, form)
96+
97+ def checkCommitmentLevels(req_id, vas_id, form):
98+ rstable = db.req_req_skill
99+ vastable = db.vol_assignment
100+ _vars = request.post_vars
101+ # get the number required
102+ query = (rstable.req_id == req_id)
103+ record = db(query).select(rstable.quantity,
104+ limitby=(0, 1)).first()
105+ needed = record.quantity
106+ # get the number committed (excluding this record)
107+ if vas_id == None:
108+ query = (vastable.req_id == req_id) & \
109+ (vastable.deleted == False)
110+ else:
111+ query = (vastable.req_id == req_id) & \
112+ (vastable.deleted == False) & \
113+ (vastable.id != request.args[2])
114+ rows = db(query).select(vastable.number)
115+ qty = 0
116+ for row in rows:
117+ qty = qty + row.number
118+ available = needed - qty
119+ commit = _vars.number
120+ # Check the number avaiblabe against the number committed
121+ if available < commit:
122+ form.vars.number = available
123+ session.information = T("Only %s volunteers are required. The commitment total has been reduced." % available)
124+ return
125+ # ---------------------------------------------------------------------
126 def assignment_onupdate(form):
127 """
128 Update Fulfilment Status based on Check-Ins
129@@ -608,6 +649,7 @@
130 listadd = s3_has_role(STAFF)
131
132 s3mgr.configure(tablename,
133+ onvalidation = assignment_onvalidate,
134 update_onaccept = assignment_onupdate,
135 ondelete = assignment_ondelete,
136 listadd = listadd)
137
138=== modified file 'modules/s3/s3export.py'
139--- modules/s3/s3export.py 2011-08-07 20:08:20 +0000
140+++ modules/s3/s3export.py 2011-09-08 12:42:18 +0000
141@@ -135,7 +135,7 @@
142 table = resource.table
143 query = resource.get_query()
144 COL_WIDTH_MULTIPLIER = 360
145- ROW_ALTERNATING_COLOURS = [0x2A, 0x2B]
146+ ROW_ALTERNATING_COLOURS = [0x2C, 0x1F]
147 rowCnt = 0
148 colCnt = 0
149
150@@ -165,13 +165,13 @@
151 styleLargeHeader.font.height = 400
152 styleLargeHeader.alignment.horz = styleLargeHeader.alignment.HORZ_CENTER
153 styleLargeHeader.pattern.pattern = styleLargeHeader.pattern.SOLID_PATTERN
154- styleLargeHeader.pattern.pattern_fore_colour = 0x2C
155+ styleLargeHeader.pattern.pattern_fore_colour = 0x0C
156
157 styleHeader = xlwt.XFStyle()
158 styleHeader.font.bold = True
159 styleHeader.num_format_str = "D-MMM-YYYY h:mm"
160 styleHeader.pattern.pattern = styleHeader.pattern.SOLID_PATTERN
161- styleHeader.pattern.pattern_fore_colour = 0x2C
162+ styleHeader.pattern.pattern_fore_colour = 0x28
163
164 # Title row
165 currentRow = sheet1.row(rowCnt)
166@@ -203,7 +203,7 @@
167 styleSubHeader = xlwt.XFStyle()
168 styleSubHeader.font.bold = True
169 styleSubHeader.pattern.pattern = styleHeader.pattern.SOLID_PATTERN
170- styleSubHeader.pattern.pattern_fore_colour = 0x18
171+ styleSubHeader.pattern.pattern_fore_colour = 0x30
172 styleOdd = xlwt.XFStyle()
173 styleOdd.pattern.pattern = styleOdd.pattern.SOLID_PATTERN
174 styleOdd.pattern.pattern_fore_colour = ROW_ALTERNATING_COLOURS[0]

Subscribers

People subscribed via source and target branches

to all changes: