Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/michaelhowden/eden
Browse files Browse the repository at this point in the history
  • Loading branch information
flavour committed Jul 2, 2014
2 parents d88806e + b5682a2 commit 76b6ee9
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 38 deletions.
120 changes: 101 additions & 19 deletions private/templates/OCHAROCCA/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"KG",
"TJ",
"TM",
"UA"
"UZ",
]

Expand Down Expand Up @@ -175,11 +176,11 @@
# =============================================================================
# Menu
current.response.menu = [
{"name": T("Places"),
"c": "gis",
"f": "location",
"icon": "globe",
},
#{"name": T("Places"),
# "c": "gis",
# "f": "location",
# "icon": "globe",
# },
{"name": T("Demographics"),
"c": "stats",
"f": "demographic_data",
Expand All @@ -201,11 +202,11 @@
"f": "event",
"icon": "bolt",
},
{"name": T("Facilities"),
"c": "org",
"f": "facility",
"icon": "home",
},
#{"name": T("Facilities"),
# "c": "org",
# "f": "facility",
# "icon": "home",
# },
]
for item in current.response.menu:
item["url"] = URL(item["c"],
Expand Down Expand Up @@ -235,6 +236,9 @@
{"name": T("Turkmenistan"),
"code": "tm"
},
{"name": T("Ukraine"),
"code": "ua"
},
{"name": T("Uzbekistan"),
"code": "uz"
}
Expand All @@ -247,6 +251,7 @@
def customise_gis_location_controller(**attr):
"""
Customise org_organisation resource
- CRD Strings
- List Fields
- Form
- Filter
Expand All @@ -269,6 +274,16 @@ def customise_gis_location_controller(**attr):
"filterby": "tag",
"filterfor": ("PCode",),
},
gis_location_lat_lon_source = {"name": "lat_lon_source",
"joinby": "location_id",
"filterby": "tag",
"filterfor": ("LatLon Source",),
},
gis_location_lat_lon_date = {"name": "lat_lon_date",
"joinby": "location_id",
"filterby": "tag",
"filterfor": ("LatLon Date",),
},
)

from s3.s3widgets import S3MultiSelectWidget
Expand All @@ -290,17 +305,30 @@ def customise_gis_location_controller(**attr):
multiple = False,
fields = [("", "value")],
),
S3SQLInlineComponent(
"lat_lon_source",
label = T("Lat/Lon Source"),
multiple = False,
fields = [("", "value")],
),
S3SQLInlineComponent(
"lat_lon_date",
label = T("Lat/Lon Date"),
multiple = False,
fields = [("", "value")],
),
#"pcode.value",
"parent",
)

s3db.gis_location.level.represent = lambda level: current.gis.get_location_hierarchy(level) if level else current.messages.NONE

field = s3db.gis_location.inherited
field.label = T("Mapped?")
field.represent = lambda inherited: T("No") if inherited else T("Yes")

filter_widgets = s3db.get_config("gis_location",
"filter_widgets")

# Remove L2 & L3 filters
# NB Fragile: dependent on filters defined in gis/location controller
filter_widgets.pop()
Expand All @@ -323,6 +351,42 @@ def customise_gis_location_controller(**attr):

settings.customise_gis_location_controller = customise_gis_location_controller

# -----------------------------------------------------------------------------
def customise_gis_location_resource(r, tablename):
"""
Customise gis_location resource
- List Fields
- CRUD Strings
- Form
- Filter
- Report
Runs after controller customisation
But runs before prep
"""
s3db = current.s3db

if r.interactive:
if r.vars.get("location.level__ne"):
s3.crud_strings["gis_location"] = Storage(
title_list = T("Administrative Areas"),
)
else:
s3.crud_strings["gis_location"] = Storage(
#label_create = T("Record Disaster"),
#title_display = T("Disaster Details"),
title_list = T("Locations")
)
#Remove level column & filter
list_fields = s3db.get_config("gis_location","list_fields")
list_fields.remove("level")
filter_widgets = s3db.get_config("gis_location",
"filter_widgets")

# NB Fragile: dependent on filters defined in gis/location controller
filter_widgets.pop(1)

settings.customise_gis_location_resource = customise_gis_location_resource

# -----------------------------------------------------------------------------
def customise_event_event_controller(**attr):

Expand Down Expand Up @@ -427,7 +491,7 @@ def customise_event_event_resource(r, tablename):
*impact_crud_form_fields
)

list_fields = ["name",
list_fields = [#"name",
"event_type_id",
]
lappend = list_fields.append
Expand Down Expand Up @@ -470,10 +534,34 @@ def customise_event_event_resource(r, tablename):

settings.customise_event_event_resource = customise_event_event_resource

def represent_year(date):
if date:
return date.strftime("%Y")
else:
return ""

# -----------------------------------------------------------------------------
def customise_vulnerability_data_resource(r, tablename):
def customise_stats_demographic_data_resource(r, tablename):
"""
Customise event_event resource
- Configure fields
Runs after controller customisation
But runs before prep
"""

s3db = current.s3db
db = current.db
table = r.table

table.date.label = T("Year")
table.date.represent = represent_year

settings.customise_stats_demographic_data_resource = customise_stats_demographic_data_resource

# -----------------------------------------------------------------------------
def customise_vulnerability_data_resource(r, tablename):
"""
Customise vulnerability_data resource
- List Fields
- CRUD Strings
- Form
Expand Down Expand Up @@ -509,12 +597,6 @@ def represent_indicator(id):

table.parameter_id.represent = represent_indicator

def represent_year(date):
if date:
return date.strftime("%Y")
else:
return ""

table.date.label = T("Year")
table.date.represent = represent_year
table.end_date.label = T("Until")
Expand Down
20 changes: 10 additions & 10 deletions private/templates/OCHAROCCA/gis_hierarchy.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
UUID,Country,L1,L2,L3,L4,L5,Edit L1
SITE_DEFAULT,,"State / Province","County / District","City / Town / Village","Village / Suburb",,
,AM,Province,Community,Settlement,,
,AZ,Economic Region,"District (Rayon)",,,,
,GE,"Region / Republic",District,,,,
,KG,"Oblast / State City","District (Rayon) / Oblast City","Town / Village Group","Village",,
,KZ,Province,District,,,,
,TJ,Province,District,Jamoat,Village,,
,TM,Province,District,,,,
,UZ,Province,District,,,,
UUID,Country,L1,L2,L3,L4,L5,Edit L1
SITE_DEFAULT,,Admin 1,Admin 2,Admin 3,Admin 4,Admin 5,
,AM,Province (Admin 1),Community (Admin 2),Settlement (Admin 3),,,
,AZ,Economic Region (Admin 1),District (Rayon) (Admin 2),,,,
,GE,Region / Republic (Admin 1),District (Admin 2),,,,
,KG,Oblast / State City (Admin 1),District (Rayon) / Oblast City (Admin 2),Town / Village Group (Admin 3),Village (Admin 4),,
,KZ,Province (Admin 1),District (Admin 2),,,,
,TJ,Province (Admin 1),District (Admin 2),Jamoat (Admin 3),Village (Admin 4),,
,TM,Province (Admin 1),District (Admin 2),,,,
,UZ,Province (Admin 1),District (Admin 2),,,,
2 changes: 1 addition & 1 deletion private/templates/OCHAROCCA/views/_summary.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{try:}}{{=H2(title)}}{{except:}}{{pass}}
<a href='{{=URL(args="import")}}' class='btn btn-primary summary-create' type='button'><i class='icon-plus'></i> {{=T("Import")}}</a>
<a href='{{=URL(args="import")}}' id='show-add-btn' class='btn btn-primary summary-import' type='button'><i class='icon-plus'></i> {{=T("Import")}}</a>
<div id='summary-common'>
{{try:}}{{for section in common:}}{{=section}}{{pass}}{{except:}}{{pass}}
<div id='filter-form' class='form-container'>
Expand Down
7 changes: 7 additions & 0 deletions private/templates/OCHAROCCA/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
<a class='brand' href='/{{=appname}}/default/index'><img src="/{{=appname}}/static/themes/OCHAROCCA/img/UN-OCHA-Logo_hor-blu660-block.jpg" style="height:28px;margin:0 0 -20px 0" alt=""/></a>
<div class='nav-collapse collapse'>
<ul class='nav'>
<li role='menuitem'>
<li class='dropdown'><a href='#' class='dropdown-toggle' data-toggle='dropdown'><i class='icon-globe'></i><b class='caret'></b></a>
<ul class='dropdown-menu'>
<li><a href='/{{=appname}}/gis/location/summary?location.level__ne=None'><i class='icon-sitemap'></i> {{=T("Administrative Areas")}}</a></li>
<li><a href='/{{=appname}}/gis/location/summary?location.level=None'><i class='icon-map-marker'></i> {{=T("Locations")}}</a></li>
</ul>
</li>
{{for opt in response.menu:}}
<li role='menuitem'>
<a href='{{=opt["url"]}}' tabindex='-1' class='menu-item'> <i class='icon-{{=opt["icon"]}}'></i> {{=opt["name"]}}</a>
Expand Down
9 changes: 7 additions & 2 deletions static/formats/s3csv/event/event.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Events - CSV Import Stylesheet
CSV fields:
Name....................event_event.name
Name OR Reference.......event_event.name
Type....................event_event.event_type_id or event_event_type.parent
SubType.................event_event.event_type_id or event_event_type.parent
SubSubType..............event_event.event_type_id
Expand Down Expand Up @@ -190,7 +190,12 @@
</xsl:call-template>
</xsl:variable>
<xsl:variable name="EventName">
<xsl:value-of select="col[@field='Name']"/>
<xsl:if test="col[@field='Name']!=''">
<xsl:value-of select="col[@field='Name']"/>
</xsl:if>
<xsl:if test="col[@field='Reference']!=''">
<xsl:value-of select="col[@field='Reference']"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="Type">
<xsl:value-of select="col[@field='Type']"/>
Expand Down
11 changes: 10 additions & 1 deletion static/formats/s3csv/stats/demographic_data.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Demo:XXXX......................required.....demographic.name (Demographic = XX in column name, value = cell in row. Multiple allowed)
Date...........................optional.....demographic_data.date
Year...........................optional.....demographic_data.date
Source.........................optional.....doc_document.name
Source URL.....................optional.....doc_document.url
Country........................optional.....gis_location.L0
Expand Down Expand Up @@ -181,6 +182,7 @@

<xsl:variable name="value" select="col[@field='Value']"/>
<xsl:variable name="date" select="col[@field='Date']"/>
<xsl:variable name="year" select="col[@field='Year']"/>
<xsl:variable name="source" select="col[@field='Source']"/>
<xsl:variable name="location">
<xsl:call-template name="LocationUid"/>
Expand Down Expand Up @@ -227,7 +229,14 @@
<xsl:value-of select="$tuid"/>
</xsl:with-param>
<xsl:with-param name="date">
<xsl:value-of select="$date"/>
<xsl:choose>
<xsl:when test="$date!=''">
<xsl:value-of select="$date"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$year"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="source">
<xsl:value-of select="$source"/>
Expand Down
1 change: 1 addition & 0 deletions static/formats/s3csv/vulnerability/data.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
L3.............................optional.....gis_location.L3
L4.............................optional.....gis_location.L4
L5.............................optional.....gis_location.L5(not supported in Vulnerability module yet)
Location.......................optional.....gis_location.name
Approved.......................optional.....vulnerability_data.approved_by
Set to 'false' to not approve records.
Note this only works for prepop or users with acl.APPROVE rights
Expand Down
13 changes: 9 additions & 4 deletions static/themes/OCHAROCCA/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ a {
color: #444444;
}

h2 {
float: left;
}

h3 {
margin: 0;
padding:0;
Expand Down Expand Up @@ -133,8 +137,6 @@ h3 {
padding: 5px 2px;
}



.thumbnail {
background: url('../../img/semi_white_75.png') !important;
/*
Expand All @@ -156,7 +158,7 @@ h3 {
float: left
}
*/
#list-btn-add {
.summary-import {
margin: 15px 0 0 15px;
}

Expand Down Expand Up @@ -203,7 +205,7 @@ h3 {
}

.country {
width: 9%;
width: 7.6%;
margin: 0 1.25%;
padding: 10px 0.5% 5px;
background: #66B2FF;
Expand All @@ -223,6 +225,9 @@ h3 {
height: 20px;
}

.country.tm h3 {
font-size: 15px;
}
/*
.link h3:hover,
.country:hover,
Expand Down
1 change: 0 additions & 1 deletion static/themes/bootstrap/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ a.delete-btn {
padding: 1px 6px;
margin-bottom: 0;
*margin-left: .3em;
margin-right: -2px;
font-size: 10.5px;
line-height: 20px;
*line-height: 20px;
Expand Down

0 comments on commit 76b6ee9

Please sign in to comment.