Skip to content

Commit

Permalink
Migrate date_of_birth overrides to S3CalendarWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Jun 30, 2015
1 parent da117c8 commit 5608073
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
nursix-1.1.0-devel-2456-g07c446b (2015-06-30 14:06:45)
nursix-1.1.0-devel-2457-gda117c8 (2015-06-30 14:06:57)
5 changes: 4 additions & 1 deletion controllers/default.py
Expand Up @@ -727,7 +727,10 @@ def prep(r):
table.age_group.readable = False
table.age_group.writable = False
# Assume volunteers only between 12-81
table.date_of_birth.widget = S3DateWidget(past=972, future=-144)
dob = table.date_of_birth
dob.widget = S3CalendarWidget(past_months = 972,
future_months = -144,
)
return True
else:
# Disable non-interactive & import
Expand Down
11 changes: 8 additions & 3 deletions controllers/hrm.py
Expand Up @@ -138,8 +138,10 @@ def prep(r):
table.status.writable = table.status.readable = False

# Assume staff only between 16-81
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=972,
future=-192)
dob = s3db.pr_person.date_of_birth
dob.widget = S3CalendarWidget(past_months = 972,
future_months = -192,
)
elif r.representation == "xls":
# Make it match Import sheets
list_fields = s3db.get_config(tablename, "list_fields")
Expand Down Expand Up @@ -268,7 +270,10 @@ def prep(r):
table.missing.readable = table.missing.writable = False
table.age_group.readable = table.age_group.writable = False
# Assume volunteers only between 12-81
table.date_of_birth.widget = S3DateWidget(past=972, future=-144)
dob = table.date_of_birth
dob.widget = S3CalendarWidget(past_months = 972,
future_months = -144,
)
return True
else:
# Disable non-interactive & import
Expand Down
6 changes: 4 additions & 2 deletions controllers/member.py
Expand Up @@ -53,7 +53,8 @@ def prep(r):
redirect(URL(f="person", vars=vars))

# Assume members under 120
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=1440)
s3db.pr_person.date_of_birth.widget = \
S3CalendarWidget(past_months=1440)

elif r.representation == "xls":
# Split person_id into first/middle/last to make it match Import sheets
Expand Down Expand Up @@ -155,7 +156,8 @@ def prep(r):
if r.method != "import":
if not r.component:
# Assume members under 120
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=1440)
s3db.pr_person.date_of_birth.widget = \
S3CalendarWidget(past_months=1440)
resource = r.resource
if resource.count() == 1:
resource.load()
Expand Down
5 changes: 4 additions & 1 deletion modules/s3db/hrm.py
Expand Up @@ -7122,7 +7122,10 @@ def prep(r):
table.missing.readable = table.missing.writable = False
table.age_group.readable = table.age_group.writable = False
# Assume volunteers only between 5-120
table.date_of_birth.widget = S3DateWidget(past=1440, future=-60)
dob = table.date_of_birth
dob.widget = S3CalendarWidget(past_months = 1440,
future_months = -60,
)

person_details_table = s3db.pr_person_details
# No point showing the 'Occupation' field - that's the Job Title in the Staff Record
Expand Down
12 changes: 9 additions & 3 deletions modules/s3db/vol.py
Expand Up @@ -867,8 +867,11 @@ def prep(r):
set_org_dependent_field("vol_volunteer_cluster", "vol_cluster_position_id")
# Label for "occupation"
s3db.pr_person_details.occupation.label = T("Normal Job")
# Assume volunteers only between 12-81
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=972, future=-144)
# Assume staff only between 12-81
dob = s3db.pr_person.date_of_birth
dob.widget = S3CalendarWidget(past_months = 972,
future_months = -144,
)
return True
s3.prep = prep

Expand Down Expand Up @@ -1064,7 +1067,10 @@ def prep(r):
if not r.component:
table = r.table
# Assume volunteers only between 12-81
table.date_of_birth.widget = S3DateWidget(past=972, future=-144)
dob = table.date_of_birth
dob.widget = S3CalendarWidget(past_months = 972,
future_months = -144,
)
table.pe_label.readable = table.pe_label.writable = False
table.missing.readable = table.missing.writable = False
table.age_group.readable = table.age_group.writable = False
Expand Down

0 comments on commit 5608073

Please sign in to comment.