Skip to content

Commit

Permalink
Membership Types -> Table filtered by Organisation. Fix filtering for…
Browse files Browse the repository at this point in the history
… Courses & Programmes. Tweak orgs/roles for IFRC_Train prepop to improve testing. Move Facebook & Google logins to a separate class to be able to reduce the every-request modules being loaded.
  • Loading branch information
flavour committed Jun 30, 2012
1 parent ee3e4d3 commit f83dee2
Show file tree
Hide file tree
Showing 38 changed files with 1,101 additions and 808 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
4e1f4cd (2012-06-29 23:06:10)
ee3e4d3 (2012-06-30 16:17:20)
2 changes: 1 addition & 1 deletion controllers/assess.py
Expand Up @@ -84,7 +84,7 @@ def assess_tables():
default = request.utcnow),
location_id(widget = S3LocationAutocompleteWidget(),
requires = IS_LOCATION()),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile = True)),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile=True)),
person_id("assessor_person_id",
label = T("Assessor"),
default = s3_logged_in_person()),
Expand Down
6 changes: 4 additions & 2 deletions controllers/default.py
Expand Up @@ -640,7 +640,8 @@ def facebook():
if not auth.settings.facebook:
redirect(URL(f="user", args=request.args, vars=request.vars))

auth.settings.login_form = s3base.FaceBookAccount()
from s3oauth import FaceBookAccount
auth.settings.login_form = FaceBookAccount()
form = auth()

return dict(form=form)
Expand All @@ -652,7 +653,8 @@ def google():
if not auth.settings.google:
redirect(URL(f="user", args=request.args, vars=request.vars))

auth.settings.login_form = s3base.GooglePlusAccount()
from s3oauth import GooglePlusAccount
auth.settings.login_form = GooglePlusAccount()
form = auth()

return dict(form=form)
Expand Down
32 changes: 20 additions & 12 deletions controllers/member.py
Expand Up @@ -7,18 +7,18 @@
module = request.controller
resourcename = request.function

if not deployment_settings.has_module(module):
if not settings.has_module(module):
raise HTTP(404, body="Module disabled: %s" % module)

# =============================================================================
def index():
""" Dashboard """

module_name = deployment_settings.modules[module].name_nice
module_name = settings.modules[module].name_nice
response.title = module_name

item = None
if deployment_settings.has_module("cms"):
if settings.has_module("cms"):
table = s3db.cms_post
_item = db(table.module == module).select(table.id,
table.body,
Expand All @@ -42,7 +42,9 @@ def index():
_class="action-btn"))

if not item:
item = H2(module_name)
#item = H2(module_name)
# Just redirect to the list of Members
redirect(URL(f="membership"))

# tbc
report = ""
Expand All @@ -51,7 +53,14 @@ def index():
return dict(item=item, report=report)

# =============================================================================
# People
def membership_type():
"""
REST Controller
"""

output = s3_rest_controller()
return output

# =============================================================================
def membership():
"""
Expand All @@ -68,12 +77,12 @@ def prep(r):
vars = {"membership.id": r.id}
redirect(URL(f="person", vars=vars))
return True
response.s3.prep = prep
s3.prep = prep

output = s3_rest_controller(rheader=s3db.member_rheader)
return output

# -----------------------------------------------------------------------------
# =============================================================================
def person():
"""
Person Controller
Expand All @@ -93,7 +102,8 @@ def person():
action=s3db.pr_contacts)

# Upload for configuration (add replace option)
response.s3.importerPrep = lambda: dict(ReplaceOption=T("Remove existing data before import"))
s3.importerPrep = lambda: \
dict(ReplaceOption=T("Remove existing data before import"))

# Import pre-process
def import_prep(data):
Expand All @@ -103,14 +113,12 @@ def import_prep(data):
hook in s3mgr
"""

request = current.request

resource, tree = data
xml = s3mgr.xml
tag = xml.TAG
att = xml.ATTRIBUTE

if response.s3.import_replace:
if s3.import_replace:
if tree is not None:
root = tree.getroot()
expr = "/%s/%s[@%s='org_organisation']/%s[@%s='name']" % \
Expand Down Expand Up @@ -154,7 +162,7 @@ def prep(r):
s3mgr.configure("member_membership",
insertable = False)
return True
response.s3.prep = prep
s3.prep = prep

output = s3_rest_controller("pr", resourcename,
native=False,
Expand Down
1 change: 0 additions & 1 deletion models/00_settings.py
Expand Up @@ -137,7 +137,6 @@
_settings.password_min_length = 4
_settings.expiration = 28800 # seconds

# Authentication options
_settings.facebook = settings.get_auth_facebook()
_settings.google = settings.get_auth_google()

Expand Down
2 changes: 1 addition & 1 deletion modules/eden/asset.py
Expand Up @@ -177,7 +177,7 @@ def model(self):
label = T("Supplier")),
Field("purchase_date", "date",
label = T("Purchase Date"),
requires = IS_NULL_OR(IS_DATE(format = s3_date_format)),
requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
represent = s3_date_represent,
widget = S3DateWidget()),
Field("purchase_price", "double",
Expand Down
4 changes: 2 additions & 2 deletions modules/eden/climate.py
Expand Up @@ -314,13 +314,13 @@ def model(self):
),
station_id(),
Field("date_from", "date",
requires = IS_DATE(format = s3_date_format),
requires = IS_DATE(format=s3_date_format),
widget = S3DateWidget(),
default = utcnow,
required = True
),
Field("date_to", "date",
requires = IS_DATE(format = s3_date_format),
requires = IS_DATE(format=s3_date_format),
widget = S3DateWidget(),
default = utcnow,
required = True
Expand Down
2 changes: 1 addition & 1 deletion modules/eden/cr.py
Expand Up @@ -215,7 +215,7 @@ def cr_shelter_service_represent(shelter_service_ids):
length=64, # Mayon compatibility
requires = IS_NOT_EMPTY(),
label = T("Shelter Name")),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile = True)),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile=True)),
shelter_type_id(), # e.g. NGO-operated, Government evacuation center, School, Hospital -- see Agasti opt_camp_type.)
shelter_service_id(), # e.g. medical, housing, food, ...
location_id(),
Expand Down
8 changes: 4 additions & 4 deletions modules/eden/doc.py
Expand Up @@ -108,11 +108,11 @@ def model(self):
person_id(label=T("Author"),
comment=person_comment(T("Author"),
T("The Author of this Document (optional)"))),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile = True)),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile=True)),
Field("date", "date",
label = T("Date Published"),
represent = s3_date_represent,
requires = IS_NULL_OR(IS_DATE(format = s3_date_format)),
requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
widget = S3DateWidget()
),
location_id(),
Expand Down Expand Up @@ -192,12 +192,12 @@ def model(self):
label = T("Image Type"),
represent = lambda opt: doc_image_type_opts.get(opt, UNKNOWN_OPT)),
person_id(label=T("Author")),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile = True)),
organisation_id(widget = S3OrganisationAutocompleteWidget(default_from_profile=True)),
location_id(),
Field("date", "date",
label = T("Date Taken"),
represent = s3_date_represent,
requires = IS_NULL_OR(IS_DATE(format = s3_date_format)),
requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
widget = S3DateWidget()
),
comments(),
Expand Down

0 comments on commit f83dee2

Please sign in to comment.