Merge lp:~ptressel/sahana-eden/stalled into lp:sahana-eden

Proposed by Pat Tressel
Status: Merged
Merged at revision: 1155
Proposed branch: lp:~ptressel/sahana-eden/stalled
Merge into: lp:sahana-eden
Diff against target: 86 lines (+21/-13)
2 files modified
models/cr.py (+18/-4)
views/cr/shelter_optional_data.js (+3/-9)
To merge this branch: bzr merge lp:~ptressel/sahana-eden/stalled
Reviewer Review Type Date Requested Status
Fran Boon Pending
Review via email: mp+34262@code.launchpad.net

Description of the change

Add required field * to names of shelter types and services.
(Trac bugs #597 and #603.)

Move setting of required field * for school_code and hospital_id from .js file to model file.

Do this for hospital_id by copying the reusable field and adjusting the comment. No reusable fields were harmed. The one other use of hospital_id, in hms_hrequest (hospital request) does not get a * on its comment.

To post a comment you must log in.
lp:~ptressel/sahana-eden/stalled updated
1154. By Fran Boon

Progress the Location Selector (set the Dropdowns if an Lx is selected in the Name box), add useful jquery.form-extension library

1155. By Fran Boon

Merge ptressel: Add required field * to names of shelter types and services

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'models/cr.py'
2--- models/cr.py 2010-08-31 21:51:59 +0000
3+++ models/cr.py 2010-09-01 00:36:48 +0000
4@@ -20,7 +20,9 @@
5 resource = "shelter_type"
6 tablename = module + "_" + resource
7 table = db.define_table(tablename, timestamp, uuidstamp, deletion_status,
8- Field("name", notnull=True),
9+ Field("name",
10+ notnull=True,
11+ comment = SPAN("*", _class="req")),
12 comments,
13 migrate=migrate)
14
15@@ -55,7 +57,9 @@
16 resource = "shelter_service"
17 tablename = module + "_" + resource
18 table = db.define_table(tablename, timestamp, uuidstamp, deletion_status,
19- Field("name", notnull=True),
20+ Field("name",
21+ notnull=True,
22+ comment = SPAN("*", _class="req")),
23 comments,
24 migrate=migrate)
25
26@@ -134,16 +138,26 @@
27 # are for Pakistan flood response. It is simpler
28 # to keep this info in the shelter table and hide it if
29 # the shelter is not a school.
30- Field("school_code", "integer"),
31+ Field("school_code", "integer",
32+ comment = SPAN("*", _class="req")),
33 Field("school_pf", "integer"),
34 )
35+
36 fields_after_hospital = db.Table(None, None, comments)
37
38+ # Make a copy of reusable field hospital_id and change its comment to
39+ # include a *. # We want it to look required whenever it's visible.
40+ cr_hospital_id = db.Table(None, "hospital_id", hospital_id)
41+ comment_with_star = DIV(SPAN("*", _class="req"),
42+ cr_hospital_id.hospital_id.comment)
43+ cr_hospital_id.hospital_id.comment = comment_with_star
44+
45+
46 # Only include hospital_id if the hms module is enabled.
47 if deployment_settings.has_module("hms"):
48 table = db.define_table(tablename,
49 fields_before_hospital,
50- hospital_id,
51+ cr_hospital_id,
52 fields_after_hospital,
53 migrate=migrate)
54 else:
55
56=== modified file 'views/cr/shelter_optional_data.js'
57--- views/cr/shelter_optional_data.js 2010-08-31 21:51:59 +0000
58+++ views/cr/shelter_optional_data.js 2010-09-01 00:36:48 +0000
59@@ -15,14 +15,11 @@
60 // Adding tooltip here is too late to get proper decorations, so add them.
61 $('#is_school_tooltip').cluetip(
62 {activation: 'hover', sticky: false, splitTitle: '|'});
63- // Make the school code line appear required -- we'll test for a non-empty
64- // code if the checkbox is checked. (This jQuery selector tests within
65- // the set selected by the first selector for a child matching the second.)
66- $('#cr_shelter_school_code__row .w2p_fc').append(
67- '{{=SPAN("*", _class="req")}}');
68 // If data is present (on update), or if there's a validation error
69 // (meaning box was checked but no school code filled in on create),
70- // set checked and do not hide.
71+ // set checked and do not hide. (The jQuery selector with two terms
72+ // tests within the set selected by the first selector, for a child
73+ // matching the second.)
74 if ($('#cr_shelter_school_code').val() != "" ||
75 $('#cr_shelter_school_code__row #school_code__error').length != 0) {
76 $('#is_school').attr('checked','on');
77@@ -64,9 +61,6 @@
78 // Add tooltip decorations.
79 $('#is_hospital_tooltip').cluetip(
80 {activation: 'hover', sticky: false, splitTitle: '|'});
81- // Make hospital_id appear required.
82- $('#cr_shelter_hospital_id__row .w2p_fc').append(
83- '{{=SPAN("*", _class="req")}}');
84 // If data is present (on update), or if there's a validation error
85 // (meaning box was checked but no hospital id filled in on create),
86 // set checked and do not hide.