def __call__(self): T = current.T db = current.db s3db = current.s3db request = current.request response = current.response s3 = response.s3 output = {} output["title"] = response.title = current.deployment_settings.get_system_name() # Map auth = current.auth is_logged_in = auth.is_logged_in() callback = None if is_logged_in: # Show the User's Coalition's Polygon org_group_id = auth.user.org_group_id if org_group_id: # Lookup Coalition Name table = s3db.org_group row = db(table.id == org_group_id).select(table.name, limitby=(0, 1) ).first() if row: callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='%s'){layer.setVisibility(true)}}''' % row.name if not callback: # Show all Coalition Polygons callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='All Coalitions'){layer.setVisibility(true)}} ''' gis = current.gis config = gis.get_config() config.zoom = 8 map = gis.show_map(width=770, height=295, callback=callback, catalogue_layers=True, collapsed=True, save=False, ) output["map"] = map # Description of available data from s3db.cms import S3CMS for item in response.menu: item["cms"] = S3CMS.resource_content(module = item["c"], resource = item["f"]) # Site Activity Log resource = s3db.resource("s3_audit") resource.add_filter(FS("~.method") != "delete") orderby = "s3_audit.timestmp desc" list_fields = ["id", "method", "timestmp", "user_id", "tablename", "record_id", ] #current.deployment_settings.ui.customise_s3_audit() db.s3_audit.user_id.represent = s3_auth_user_represent_name list_id = "log" datalist, numrows, ids = resource.datalist(fields=list_fields, start=None, limit=4, list_id=list_id, orderby=orderby, layout=s3.render_log) # Placeholder filter_form = DIV(_class="filter_form") if numrows == 0: # Empty table or just no match? from s3 import S3CRUD table = resource.table if "deleted" in table: available_records = db(table.deleted != True) else: available_records = db(table._id > 0) if available_records.select(table._id, limitby=(0, 1)).first(): msg = DIV(S3CRUD.crud_string(resource.tablename, "msg_no_match"), _class="empty") else: msg = DIV(S3CRUD.crud_string(resource.tablename, "msg_list_empty"), _class="empty") data = msg else: # Render the list ajaxurl = URL(c="default", f="audit", args="datalist_f.dl") popup_url = URL(c="default", f="audit", args="datalist.popup") dl = datalist.html(ajaxurl=ajaxurl, pagesize=4, popup_url=popup_url, popup_title=T("Updates"), ) data = dl if is_logged_in and org_group_id: # Add a Filter filter_widgets = [S3OptionsFilter("user_id$org_group_id", label = "", # Can't just use "" as this is then omitted from rendering options = {"*": T("All"), org_group_id: T("My Community"), }, cols = 2, multiple = False, ), ] filter_submit_url = URL(c="default", f="index") filter_ajax_url = URL(c="default", f="audit", args=["filter.options"]) filter_form = S3FilterForm(filter_widgets, filter_manager = False, formstyle = filter_formstyle, clear = False, submit = True, ajax = True, url = filter_submit_url, ajaxurl = filter_ajax_url, _class = "filter-form", _id = "%s-filter-form" % list_id ) filter_form = filter_form.html(resource, request.get_vars, target=list_id, ) output["updates"] = data output["filter_form"] = filter_form # Add JavaScript appname = request.application debug = s3.debug scripts_append = s3.scripts.append if debug: # Infinite Scroll doesn't make sense here, but currently required by dataLists.js scripts_append("/%s/static/scripts/jquery.infinitescroll.js" % appname) scripts_append("/%s/static/scripts/jquery.viewport.js" % appname) scripts_append("/%s/static/scripts/S3/s3.dataLists.js" % appname) else: scripts_append("/%s/static/scripts/S3/s3.dataLists.min.js" % appname) self._view(THEME, "index.html") return output
def __call__(self): request = current.request response = current.response output = {} output[ "title"] = response.title = current.deployment_settings.get_system_name( ) view = path.join(request.folder, "private", "templates", THEME, "views", "index.html") try: # Pass view as file not str to work in compiled mode response.view = open(view, "rb") except IOError: from gluon.http import HTTP raise HTTP("404", "Unable to open Custom View: %s" % view) T = current.T # This will presumably be modified according to how the update data is stored / retrieved updates = [ { "user": "******", "profile": URL("static", "themes", args=["CRMT", "users", "1.jpeg"]), "action": "Added a %s", "type": "Organization", "name": "Helping Hands", "url": URL(""), }, { "user": "******", "profile": URL("static", "themes", args=["CRMT", "users", "2.jpeg"]), "action": "Saved a %s", "type": "Filter", "name": "My Organization Resources", "url": URL(""), }, { "user": "******", "profile": URL("static", "themes", args=["CRMT", "users", "3.jpeg"]), "action": "Edited a %s", "type": "Risk", "name": "Wirefires", "url": URL(""), }, #{"user": "******", # "profile": URL("static", "themes", args = ["CRMT", "users", "4.jpeg"]), # "action": "Saved a %s", # "type": "Map", # "url": URL(""), #}, { "user": "******", "profile": URL("static", "themes", args=["CRMT", "users", "5.jpeg"]), "action": "Add a %s", "type": "Evacuation Route", "name": "Main St", "url": URL(""), }, ] # Function for converting action, type & name to update content # (Not all updates will have a specific name associated with it, so the link will be on the type) def generate_update(action, type, name, url): if item.get("name"): return TAG[""](action % type, BR(), A(name, _href=url)) else: return TAG[""](action % A(type, _href=url)) output["updates"] = [ dict(user=item["user"], profile=item["profile"], update=generate_update( item["action"], item["type"], item.get("name"), item["url"], )) for item in updates ] # Map auth = current.auth callback = None if auth.is_logged_in(): # Show the User's Coalition's Polygon org_group_id = auth.user.org_group_id if org_group_id: # Lookup Coalition Name db = current.db table = current.s3db.org_group query = (table.id == org_group_id) row = db(query).select(table.name, limitby=(0, 1)).first() if row: callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='%s'){layer.setVisibility(true)}}''' % row.name if not callback: # Show all Coalition Polygons callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='All Coalitions'){layer.setVisibility(true)}} ''' map = current.gis.show_map( width=770, height=270, callback=callback, catalogue_layers=True, collapsed=True, save=False, ) output["map"] = map # Button to go full-screen fullscreen = A( I(_class="icon icon-fullscreen"), _href=URL(c="gis", f="map_viewing_client"), _class="gis_fullscreen_map-btn fright", # If we need to support multiple maps on a page #_map="default", _title=T("View full screen"), ) output["fullscreen"] = fullscreen s3 = response.s3 if s3.debug: script = "/%s/static/scripts/S3/s3.gis.fullscreen.js" % request.application else: script = "/%s/static/scripts/S3/s3.gis.fullscreen.min.js" % request.application s3.scripts.append(script) from s3db.cms import S3CMS for item in response.menu: item["cms"] = S3CMS.resource_content(module=item["c"], resource=item["f"]) return output
def __call__(self): response = current.response output = {} output["title"] = response.title = current.deployment_settings.get_system_name() view = path.join(current.request.folder, "private", "templates", THEME, "views", "index.html") try: # Pass view as file not str to work in compiled mode response.view = open(view, "rb") except IOError: from gluon.http import HTTP raise HTTP("404", "Unable to open Custom View: %s" % view) application = current.request.application T = current.T # This will presumably be modified according to how the update data is stored / retrieved updates = [ {"user": "******", "profile": URL("static", "themes", args = ["CRMT", "users", "1.jpeg"]), "action": "Added a %s", "type": "Organization", "name": "Helping Hands", "url": URL(""), }, {"user": "******", "profile": URL("static", "themes", args = ["CRMT", "users", "2.jpeg"]), "action": "Saved a %s", "type": "Filter", "name": "My Organization Resources", "url": URL(""), }, {"user": "******", "profile": URL("static", "themes", args = ["CRMT", "users", "3.jpeg"]), "action": "Edited a %s", "type": "Risk", "name": "Wirefires", "url": URL(""), }, #{"user": "******", # "profile": URL("static", "themes", args = ["CRMT", "users", "4.jpeg"]), # "action": "Saved a %s", # "type": "Map", # "url": URL(""), #}, {"user": "******", "profile": URL("static", "themes", args = ["CRMT", "users", "5.jpeg"]), "action": "Add a %s", "type": "Evacuation Route", "name": "Main St", "url": URL(""), }, ] # Function for converting action, type & name to update content # (Not all updates will have a specific name associated with it, so the link will be on the type) def generate_update(action, type, name, url): if item.get("name"): return TAG[""](action % type, BR(), A(name, _href=url) ) else: return TAG[""](action % A(type, _href=url) ) output["updates"] = [dict(user = item["user"], profile = item["profile"], update = generate_update(item["action"], item["type"], item.get("name"), item["url"], ) ) for item in updates] # Map auth = current.auth callback = None if auth.is_logged_in(): # Show the User's Coalition's Polygon org_group_id = auth.user.org_group_id if org_group_id: # Lookup Coalition Name db = current.db table = current.s3db.org_group query = (table.id == org_group_id) row = db(query).select(table.name, limitby=(0, 1)).first() if row: callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='%s'){layer.setVisibility(true)}}''' % row.name if not callback: # Show all Coalition Polygons callback = '''S3.gis.show_map(); var layer,layers=S3.gis.maps.default_map.layers; for(var i=0,len=layers.length;i<len;i++){ layer=layers[i]; if(layer.name=='All Coalitions'){layer.setVisibility(true)}} ''' map = current.gis.show_map(width=770, height=270, callback=callback, catalogue_layers=True, collapsed=True, save=False, ) output["map"] = map from s3db.cms import S3CMS for item in current.response.menu: item["cms"] = S3CMS.resource_content(module = item["c"], resource = item["f"]) return output