Permalink
Browse files

Merge branch 'master' of git://github.com/graeme-f/eden

  • Loading branch information...
2 parents 9a17472 + 46e81c3 commit d532d89c6548b421806dcba13779ec484ef4a18d @flavour committed Oct 8, 2012
View
2 VERSION
@@ -1 +1 @@
-d83784e (2012-10-08 14:55:22)
+9a17472 (2012-10-08 16:24:48)
View
48 controllers/vulnerability.py
@@ -609,7 +609,7 @@ def submitted_repr(id):
Return the initial of the first name and the complete last name
"""
if not id:
- repr_text = current.messages.NONE
+ repr_text = T("Imported data")
else:
table = db.pr_person
row = db(table.id == id).select(table.first_name,
@@ -626,8 +626,11 @@ def approved_repr(id):
"""
Return the initials of the first and the last name
"""
- if not id:
+
+ if id is None:
repr_text = T("Approval pending")
+ elif id == 0:
+ repr_text = T("Approved")
else:
table = db.pr_person
row = db(table.id == id).select(table.first_name,
@@ -646,11 +649,12 @@ def action_repr(id):
"""
Return the action button for this row
"""
- if not id:
+
+ if id is None:
repr_text = current.messages.NONE
else:
row = s3db.stats_group[id]
- if row.approved_by:
+ if row.approved_by != None:
repr_text = A(T("View"),
_id = id,
_class = "viewButton",
@@ -966,6 +970,7 @@ def approveReport(id):
query = (s3db.stats_data.group_id == id)
resource = s3db.resource("stats_data", filter=query, unapproved=True)
resource.approve()
+ s3task.async("stats_group_clean")
return True
rec_instance = record.stats_group_instance
if rec_instance == "doc_image":
@@ -974,6 +979,12 @@ def approveReport(id):
resource = s3db.resource("doc_image", filter=query, unapproved=True)
resource.approve()
return True
+ elif rec_instance == "doc_document":
+ query = (sgtable.id == id) &\
+ (s3db.doc_document.source_id == sgtable.source_id)
+ resource = s3db.resource("doc_document", filter=query, unapproved=True)
+ resource.approve()
+ return True
return False
# -----------------------------------------------------------------------------
@@ -1025,12 +1036,18 @@ def report():
reportDetails = getReportDetails(id, buttonsRequired=buttonsRequired)
data = json.dumps(reportDetails)
elif request.args(0) == "approve":
- id = request.post_vars.id
- if approveReport(id):
- report = reportDataTable(request)
- data = json.dumps(report)
+ # Check authorization
+ permitted = current.auth.s3_has_permission
+ authorised = permitted("approve", "stats_group")
+ if not authorised:
+ data = json.dumps(str(T("You are not permitted to approve documents")))
else:
- data = json.dumps(str(T("Failed to approve")))
+ id = request.post_vars.id
+ if approveReport(id):
+ report = reportDataTable(request)
+ data = json.dumps(report)
+ else:
+ data = json.dumps(str(T("Failed to approve")))
elif request.args(0) == "decline":
id = request.post_vars.id
if declineReport(id):
@@ -1127,8 +1144,17 @@ def import_vul_part1():
response.headers["Content-Type"] = "application/json"
return json({"Error": str(T("Error File missing"))})
+ # Check authorization
+ permitted = current.auth.s3_has_permission
+ authorised = permitted("create", "vulnerability_data")
+ if not authorised:
+ response.headers["Content-Type"] = "application/json"
+ return json({"Error": str(T("You are not permitted to upload files"))})
+
from lxml import etree
+ from datetime import datetime
+ creator = auth.s3_logged_in_person()
output = s3_rest_controller("vulnerability", "data",
csv_stylesheet="data.xsl")
upload_id = output[0]
@@ -1174,8 +1200,8 @@ def import_vul_part1():
row = group[0]
group_dict = {}
group_dict["group"] = key
- group_dict["date"] = row["date"]
- group_dict["created_by"] = row["created_by"]
+ group_dict["date"] = datetime.strptime(row["date"], "%Y-%m-%d").strftime("%d-%b-%y")
+ group_dict["created_by"] = creator
loc = row["location_id"][1][12:] # strip location L#: from the tuid
loc = "%s %s" % (loc, loc_label)
group_dict["location"] = loc
View
14 models/tasks.py
@@ -175,6 +175,20 @@ def msg_search_subscription_notifications(frequency):
# -----------------------------------------------------------------------------
if settings.has_module("stats"):
+ def stats_group_clean(user_id=None):
+ """
+ Update the stats_aggregate table by calculating all the stats_group
+ records which have the dirty flag set to True
+ """
+ if user_id:
+ # Authenticate
+ auth.s3_impersonate(user_id)
+ # Run the Task
+ result = s3db.stats_group_clean()
+ return result
+
+ tasks["stats_group_clean"] = stats_group_clean
+
def stats_update_time_aggregate(data_id=None, user_id=None):
"""
Update the stats_aggregate table for the given stats_data record
View
534 modules/eden/stats.py
@@ -130,7 +130,6 @@ def model(self):
)
self.configure(tablename,
- onapprove = self.stats_data_onapprove,
requires_approval = True,
)
#----------------------------------------------------------------------
@@ -228,23 +227,6 @@ def rebuild_aggregates():
# ---------------------------------------------------------------------
@staticmethod
- def stats_data_onapprove(row):
- """
- When a stats_data record is approved then the related stats_aggregate
- fields need to be updated so that the results are kept up to date.
-
- This is done async as this can take some time
-
- Where appropriate add test cases to modules/unit_tests/eden/stats.py
- """
-
- if not current.auth.override:
- current.s3task.async("stats_update_time_aggregate",
- args = [row.data_id],
- )
-
- # ---------------------------------------------------------------------
- @staticmethod
def stats_rebuild_aggregates():
"""
This will delete all the stats_aggregate records and then
@@ -255,10 +237,12 @@ def stats_rebuild_aggregates():
- should be reworked to delete old data after new data has been added?
"""
- resource = current.s3db.resource("stats_aggregate")
+ s3db = current.s3db
+ resource = s3db.resource("stats_aggregate")
resource.delete()
+ current.db(s3db.stats_group.id > 0).update(dirty=True)
- current.s3task.async("stats_update_time_aggregate")
+ current.s3task.async("stats_group_clean")
# ---------------------------------------------------------------------
@classmethod
@@ -290,150 +274,138 @@ def stats_update_time_aggregate(cls, data_id=None):
s3db = current.s3db
dtable = s3db.stats_data
atable = s3db.stats_aggregate
+ gis_table = s3db.gis_location
stats_aggregated_period = cls.stats_aggregated_period
if not data_id:
query = (dtable.deleted != True) & \
(dtable.approved_by != None)
records = db(query).select()
- for record in records:
- cls.stats_update_time_aggregate(record)
return
+ elif isinstance(data_id, Rows):
+ records = data_id
elif not isinstance(data_id, Row):
- record = db(dtable.data_id == data_id).select(limitby=(0, 1)
- ).first()
+ records = db(dtable.data_id == data_id).select(limitby=(0, 1))
else:
- record = data_id
- data_id = record.data_id
-
- location_id = record.location_id
- parameter_id = record.parameter_id
- # Exit if either the location or the parameter is not valid
- if not location_id or not parameter_id:
- return
- (start_date, end_date) = stats_aggregated_period(record.date)
-
- # Get all the stats_data records for this location and parameter
- query = (dtable.location_id == location_id) & \
- (dtable.parameter_id == parameter_id) & \
- (dtable.deleted != True) & \
- (dtable.approved_by != None)
- data_rows = db(query).select()
-
- # Get each record and store them in a dict keyed on the start date of
- # the aggregated period. The value stored is a list containing the date
- # the data_id and the value. If a record already exists for the
- # reporting period then the most recent value will be stored.
- earliest_period = start_date
- (last_period, end_date) = stats_aggregated_period(None)
- data = dict()
- data[start_date]=Storage(date = record.date,
- id = data_id,
- value = record.value)
- for row in data_rows:
- if row.data_id == record.data_id:
- continue
- (start_date, end_date) = stats_aggregated_period(row.date)
- if start_date in data:
- if row.date <= data[start_date]["date"]:
- # The indicator on the row is of the same time period as
- # another which is already stored in data but it is earlier
- # so ignore this particular record
- continue
- elif data[start_date]["id"] == data_id:
- # The newly added indicator is the one currently stored
- # in data but a more recent value is held on the database
- # This will not change any of the aggregated data
- return
- if start_date < earliest_period:
- earliest_period = start_date
- # Store the record from the db in the data storage
- data[start_date] = Storage(date = row.date,
- id = row.data_id,
- value = row.value)
-
- # Get all the aggregate record for this parameter and location
- query = (atable.location_id == location_id) & \
- (atable.parameter_id == parameter_id) & \
- (atable.deleted != True)
- aggr_rows = db(query).select()
-
- aggr = dict()
- for row in aggr_rows:
- (start_date, end_date) = stats_aggregated_period(row.date)
- aggr[start_date] = Storage(mean = row.mean,
- id = row.id,
- type = row.agg_type,
- end_date = row.end_date)
-
- # Step through each period and check that aggr is correct
- last_data_period = earliest_period
- last_type_agg = False # The type of previous non-copy record was aggr
- last_data_value = None # The value of the previous aggr record
- # used to keep track of which periods the
- # aggr record has been changed on the database
- changed_periods = []
- for dt in rrule(YEARLY, dtstart=earliest_period, until=last_period):
- # calculate the end of the dt period.
- # (it will be None if this is the last period)
- dt = dt.date()
- if dt != last_period:
- (start_date, end_date) = stats_aggregated_period(dt)
- else:
- start_date = dt
- end_date = None
- if dt in aggr:
- # The query use to update aggr records
- query = (atable.id == aggr[dt]["id"])
- # Check that the stored aggr data is correct
- type = aggr[dt]["type"]
- if type == 2:
- # This is built using other location aggregates
- # so it can be ignored because only time or copy aggregates
- # are being calculated in this function
- last_type_agg = True
- last_data_value = aggr[dt]["mean"]
+ records = [data_id]
+ data_id = data_id.data_id
+
+ # Data Structures used for the OPTIMISATION steps
+ param_location_dict = {} # a list of locations for each parameter
+ location_dict = {} # a list of locations
+ loc_level_list = {} # a list of levels for each location
+
+ if current.deployment_settings.has_module("vulnerability"):
+ vulnerability = True
+ vulnerability_id_list = s3db.vulnerability_ids()
+ else:
+ vulnerability = False
+ vulnerability_id_list = []
+ for record in records:
+ location_id = record.location_id
+ parameter_id = record.parameter_id
+ # Exit if either the location or the parameter is not valid
+ if not location_id or not parameter_id:
+ return
+ (start_date, end_date) = stats_aggregated_period(record.date)
+
+ # Get all the stats_data records for this location and parameter
+ query = (dtable.location_id == location_id) & \
+ (dtable.parameter_id == parameter_id) & \
+ (dtable.deleted != True) & \
+ (dtable.approved_by != None)
+ data_rows = db(query).select()
+
+ # Get each record and store them in a dict keyed on the start date of
+ # the aggregated period. The value stored is a list containing the date
+ # the data_id and the value. If a record already exists for the
+ # reporting period then the most recent value will be stored.
+ earliest_period = start_date
+ (last_period, end_date) = stats_aggregated_period(None)
+ data = dict()
+ data[start_date]=Storage(date = record.date,
+ id = data_id,
+ value = record.value)
+ for row in data_rows:
+ if row.data_id == record.data_id:
continue
- elif type == 3:
- # This is a copy aggregate and can be ignored if there is
- # no data in the data dictionary and the last type was aggr
- if (dt not in data) and last_type_agg:
+ row_date = row.date
+ (start_date, end_date) = stats_aggregated_period(row_date)
+ if start_date in data:
+ if row_date <= data[start_date]["date"]:
+ # The indicator on the row is of the same time period as
+ # another which is already stored in data but it is earlier
+ # so ignore this particular record
continue
- # If there is data in the data dictionary for this period
- # then then aggregate record needs to be changed
- if dt in data:
- value = data[dt]["value"]
- last_data_value = value
- db(query).update(agg_type = 1, # time
- reported_count = 1, # one record
- ward_count = 1, # one ward
- min = value,
- max = value,
- mean = value,
- median = value,
- end_date = end_date,
- )
- changed_periods.append((start_date, end_date))
- # Check that the data currently stored is correct
- elif aggr[dt]["mean"] != last_data_value:
- value = last_data_value
- db(query).update(agg_type = 3, # copy
- reported_count = 1, # one record
- ward_count = 1, # one ward
- min = value,
- max = value,
- mean = value,
- median = value,
- end_date = end_date,
- )
- changed_periods.append((start_date, end_date))
- elif type == 1:
- # The value in the aggr should match the value in data
- if dt in data:
- value = data[dt]["value"]
- last_data_value = value
- if aggr[dt]["mean"] != value:
+ elif data[start_date]["id"] == data_id:
+ # The newly added indicator is the one currently stored
+ # in data but a more recent value is held on the database
+ # This will not change any of the aggregated data
+ return
+ if start_date < earliest_period:
+ earliest_period = start_date
+ # Store the record from the db in the data storage
+ data[start_date] = Storage(date = row_date,
+ id = row.data_id,
+ value = row.value)
+
+ # Get all the aggregate records for this parameter and location
+ query = (atable.location_id == location_id) & \
+ (atable.parameter_id == parameter_id) & \
+ (atable.deleted != True)
+ aggr_rows = db(query).select(atable.id,
+ atable.agg_type,
+ atable.date,
+ atable.end_date,
+ atable.mean)
+
+ aggr = dict()
+ for row in aggr_rows:
+ (start_date, end_date) = stats_aggregated_period(row.date)
+ aggr[start_date] = Storage(mean = row.mean,
+ id = row.id,
+ type = row.agg_type,
+ end_date = row.end_date)
+
+ # Step through each period and check that aggr is correct
+ last_data_period = earliest_period
+ last_type_agg = False # The type of previous non-copy record was aggr
+ last_data_value = None # The value of the previous aggr record
+ # used to keep track of which periods the
+ # aggr record has been changed on the database
+ changed_periods = []
+ for dt in rrule(YEARLY, dtstart=earliest_period, until=last_period):
+ # calculate the end of the dt period.
+ # (it will be None if this is the last period)
+ dt = dt.date()
+ if dt != last_period:
+ (start_date, end_date) = stats_aggregated_period(dt)
+ else:
+ start_date = dt
+ end_date = None
+ if dt in aggr:
+ # The query use to update aggr records
+ query = (atable.id == aggr[dt]["id"])
+ # Check that the stored aggr data is correct
+ type = aggr[dt]["type"]
+ if type == 2:
+ # This is built using other location aggregates
+ # so it can be ignored because only time or copy aggregates
+ # are being calculated in this function
+ last_type_agg = True
+ last_data_value = aggr[dt]["mean"]
+ continue
+ elif type == 3:
+ # This is a copy aggregate and can be ignored if there is
+ # no data in the data dictionary and the last type was aggr
+ if (dt not in data) and last_type_agg:
+ continue
+ # If there is data in the data dictionary for this period
+ # then then aggregate record needs to be changed
+ if dt in data:
+ value = data[dt]["value"]
+ last_data_value = value
db(query).update(agg_type = 1, # time
reported_count = 1, # one record
ward_count = 1, # one ward
@@ -444,70 +416,180 @@ def stats_update_time_aggregate(cls, data_id=None):
end_date = end_date,
)
changed_periods.append((start_date, end_date))
- # If the data is not there then it must have been deleted
- # So copy the value from the previous record
+ # Check that the data currently stored is correct
+ elif aggr[dt]["mean"] != last_data_value:
+ value = last_data_value
+ db(query).update(agg_type = 3, # copy
+ reported_count = 1, # one record
+ ward_count = 1, # one ward
+ min = value,
+ max = value,
+ mean = value,
+ median = value,
+ end_date = end_date,
+ )
+ changed_periods.append((start_date, end_date))
+ elif type == 1:
+ # The value in the aggr should match the value in data
+ if dt in data:
+ value = data[dt]["value"]
+ last_data_value = value
+ if aggr[dt]["mean"] != value:
+ db(query).update(agg_type = 1, # time
+ reported_count = 1, # one record
+ ward_count = 1, # one ward
+ min = value,
+ max = value,
+ mean = value,
+ median = value,
+ end_date = end_date,
+ )
+ changed_periods.append((start_date, end_date))
+ # If the data is not there then it must have been deleted
+ # So copy the value from the previous record
+ else:
+ value = last_data_value
+ db(query).update(agg_type = 3, # copy
+ reported_count = 1, # one record
+ ward_count = 1, # one ward
+ min = value,
+ max = value,
+ mean = value,
+ median = value,
+ end_date = end_date,
+ )
+ changed_periods.append((start_date, end_date))
+ # No aggregate record for this time period exists
+ # So one needs to be inserted
+ else:
+ if dt in data:
+ value = data[dt]["value"]
+ type = 1 # time
+ last_data_value = value
else:
value = last_data_value
- db(query).update(agg_type = 3, # copy
- reported_count = 1, # one record
- ward_count = 1, # one ward
- min = value,
- max = value,
- mean = value,
- median = value,
- end_date = end_date,
- )
- changed_periods.append((start_date, end_date))
- # No aggregate record for this time period exists
- # So one needs to be inserted
+ type = 3 # copy
+ atable.insert(parameter_id = parameter_id,
+ location_id = location_id,
+ agg_type = type,
+ reported_count = 1, # one record
+ ward_count = 1, # one ward
+ min = value,
+ max = value,
+ mean = value,
+ median = value,
+ date = start_date,
+ end_date = end_date,
+ )
+ changed_periods.append((start_date, end_date))
+ # End of loop through each time period
+
+ if changed_periods == []:
+ continue
+ # The following structures are used in the OPTIMISATION steps later
+ loc_level_list[location_id] = gis_table[location_id].level
+ if parameter_id not in param_location_dict:
+ param_location_dict[parameter_id] = {location_id : changed_periods}
+ elif location_id not in param_location_dict[parameter_id]:
+ param_location_dict[parameter_id][location_id] = changed_periods
else:
- if dt in data:
- value = data[dt]["value"]
- type = 1 # time
- last_data_value = value
+ # store the older of the changed periods (the end will always be None)
+ # Only need to check the start date of the first period
+ if changed_periods[0][0] < param_location_dict[parameter_id][location_id][0][0]:
+ param_location_dict[parameter_id][location_id] = changed_periods
+ if parameter_id in vulnerability_id_list:
+ if location_id not in location_dict:
+ location_dict[location_id] = changed_periods
else:
- value = last_data_value
- type = 3 # copy
- atable.insert(parameter_id = parameter_id,
- location_id = location_id,
- agg_type = type,
- reported_count = 1, # one record
- ward_count = 1, # one ward
- min = value,
- max = value,
- mean = value,
- median = value,
- date = start_date,
- end_date = end_date,
- )
- changed_periods.append((start_date, end_date))
+ # Store the older of the changed periods (the end will always be None)
+ # Only need to check the start date of the first period
+ if changed_periods[0][0] < location_dict[location_id][0][0]:
+ location_dict[location_id] = changed_periods
+
+ # End of loop through each stats_data record
+
+ # OPTIMISATION step 1
+ # The following code will get all the locations for which a parameter
+ # has been changed. This will remove duplicates which will occur when
+ # items are being imported for many communes in the same district.
+ # Take an import of 12 communes in the same district, without this the
+ # district will be updated 12 times, the province will be updated 12
+ # times and the country will be updated 12 times that is 33 unnecessary
+ # updates (for each time period) (i.e. 15 updates rather than 48)
+
+ # Now get all the parents
+ parents = {}
+ get_parents = current.gis.get_parents
+ for loc_id in location_dict.keys():
+ parents[loc_id] = get_parents(loc_id)
+ # Expand the list of locations for each parameter
+ parents_data = {}
+ for (param_id, loc_dict) in param_location_dict.items():
+ for (loc_id, periods) in loc_dict.items():
+ for p_loc_row in parents[loc_id]:
+ p_loc_id = p_loc_row.id
+ if param_id in parents_data:
+ if p_loc_id in parents_data[param_id]:
+ # store the older of the changed periods (the end will always be None)
+ # Only need to check the start date of the first period
+ if periods[0][0] < parents_data[param_id][p_loc_id][0][0][0]:
+ parents_data[param_id][p_loc_id][0] = periods
+ else:
+ parents_data[param_id][p_loc_id] = [periods,
+ loc_level_list[loc_id]
+ ]
+ else:
+ parents_data[param_id] = {p_loc_id : [periods,
+ loc_level_list[loc_id]
+ ]
+ }
+
+
+ # OPTIMISATION step 2
+ # The following code will get all the locations for which the
+ # resilence indicator needs to be recalculated. Without this
+ # the calculations will be triggered for each parameter and for each
+ # location unnecessarily.
+ # For example an import of 12 communes in the same district with data
+ # for the 10 parameters that make up the resilence calculation will trigger
+ # 480 updates, rather than the optimal 15, for each time period.
+ resilence_parents = {}
+ for (loc_id, periods) in location_dict.items():
+ resilence_parents[loc_id] = (periods, loc_level_list[loc_id], True)
+ for p_loc_row in parents[loc_id]:
+ p_loc_id = p_loc_row.id
+ if p_loc_id in resilence_parents:
+ # store the older of the changed periods (the end will always be None)
+ # Only need to check the start date of the first period
+ if periods[0][0] < resilence_parents[p_loc_id][0][0][0]:
+ resilence_parents[p_loc_id][0] = periods
+ else:
+ resilence_parents[p_loc_id] = [periods, loc_level_list[loc_id], False]
+ #print "%s %s %s %s" % (len(location_dict), len(parents), len(parents_data), len(resilence_parents))
# Now that the time aggregate types have been set up correctly,
# fire off requests for the location aggregates to be calculated
- parents = current.gis.get_parents(location_id)
async = current.s3task.async
- loc_level = s3db.gis_location[location_id].level
- if current.deployment_settings.has_module("vulnerability"):
- vulnerability = True
- else:
- vulnerability = False
- for (start_date, end_date) in changed_periods:
-
- s, e = str(start_date), str(end_date)
-
- # Calculate the aggregates for each parent location
- if parents:
- for location in parents:
+ for (param_id, loc_dict) in parents_data.items():
+ for (loc_id, (changed_periods,loc_level)) in loc_dict.items():
+ for (start_date, end_date) in changed_periods:
+ s, e = str(start_date), str(end_date)
async("stats_update_aggregate_location",
- args = [loc_level, location.id, parameter_id, s, e])
-
- if vulnerability and \
- (parameter_id in s3db.vulnerability_ids() or \
- parameter_id == s3db.vulnerability_resilience_id()):
- s3db.vulnerability_update_resilience(loc_level,
- location_id,
- start_date,
- end_date)
+ args = [loc_level, loc_id, param_id, s, e])
+ if vulnerability:
+ # Now calculate the resilence indicators
+ vulnerability_resilience = s3db.vulnerability_resilience
+ resilience_pid = s3db.vulnerability_resilience_id()
+ for (location_id, (period, loc_level,use_location)) in resilence_parents.items():
+ for (start_date, end_date) in changed_periods:
+ s, e = str(start_date), str(end_date)
+ vulnerability_resilience(loc_level,
+ location_id,
+ resilience_pid,
+ vulnerability_id_list,
+ start_date,
+ end_date,
+ use_location)
# ---------------------------------------------------------------------
@staticmethod
@@ -882,6 +964,7 @@ class S3StatsGroupModel(S3Model):
"stats_group_id",
"stats_group_type_id",
"stats_source_id",
+ "stats_group_clean",
]
def model(self):
@@ -994,6 +1077,13 @@ def model(self):
s3_date(label = T("Date Published")),
self.gis_location_id(),
group_type_id(),
+ # Used to indicate if the record has not yet
+ # been used in aggregate calculations
+ Field("dirty", "boolean",
+ #label = T("Dirty"),
+ default=True,
+ readable=False,
+ writable=False),
#Field("reliability",
# label=T("Reliability")),
#Field("review",
@@ -1025,6 +1115,7 @@ def model(self):
stats_group_type_id = group_type_id,
stats_group_id = group_id,
stats_source_id = source_id,
+ stats_group_clean = self.stats_group_clean,
)
# -------------------------------------------------------------------------
@@ -1082,6 +1173,35 @@ def stats_group_duplicate(item):
item.id = duplicate.id
item.method = item.METHOD.UPDATE
+ # ---------------------------------------------------------------------
+ @staticmethod
+ def stats_group_clean():
+ """
+ This will get all the "dirty" approved stats_group records and from
+ the related stats_data records calculate the stats_aggregate records.
+ """
+
+ s3db = current.s3db
+ db = current.db
+ gtable = s3db.stats_group
+ dtable = s3db.stats_data
+
+ query = (gtable.deleted != True) & \
+ (gtable.dirty == True) & \
+ (gtable.approved_by != None) & \
+ (gtable.id == dtable.group_id)
+ data_list = db(query).select(dtable.id,
+ dtable.parameter_id,
+ dtable.date,
+ dtable.location_id,
+ dtable.value)
+ S3StatsModel.stats_update_time_aggregate(data_list)
+
+ query = (gtable.deleted != True) & \
+ (gtable.dirty == True) & \
+ (gtable.approved_by != None)
+ db(query).update(dirty=False)
+
# -------------------------------------------------------------------------
@staticmethod
def stats_source_duplicate(item):
View
50 modules/eden/vulnerability.py
@@ -46,7 +46,7 @@ class S3VulnerabilityModel(S3Model):
"vulnerability_data",
"vulnerability_resilience_id",
"vulnerability_ids",
- "vulnerability_update_resilience",
+ "vulnerability_resilience",
]
resilience_pid = None # id of the resilience indicator
@@ -192,7 +192,6 @@ def model(self):
return Storage(
vulnerability_resilience_id = self.vulnerability_resilience_id,
vulnerability_ids = self.vulnerability_ids,
- vulnerability_update_resilience = self.vulnerability_update_resilience,
vulnerability_resilience = self.vulnerability_resilience,
)
@@ -243,53 +242,6 @@ def vulnerability_ids():
return S3VulnerabilityModel.indicator_pids
- # -------------------------------------------------------------------------
- @staticmethod
- def vulnerability_update_resilience(loc_level,
- location_id,
- start_date,
- end_date):
- """
- When a vulnerability_data record is created or updated then the
- aggregated indicators and aggregated data needs to be recalculated.
-
- This means that indicators will be calculated for the location and
- all parent locations. The indicators updated will be for those in
- the same aggregated time period.
-
- This is done async as this can take some time, and is triggered by
- stats_data_onapprove()
-
- Where appropriate add test cases to modules/unit_tests/eden/stats.py
- """
-
- # Get the list of parameter_ids that are to be used
- resilience_pid = S3VulnerabilityModel.vulnerability_resilience_id()
- if resilience_pid is None:
- return
-
- indicator_pids = S3VulnerabilityModel.vulnerability_ids()
-
- fn = S3VulnerabilityModel.vulnerability_resilience
- fn(loc_level,
- location_id,
- resilience_pid,
- indicator_pids,
- start_date,
- end_date,
- use_location = True,
- )
- parents = current.gis.get_parents(location_id)
- for location in parents:
- # Calculate the aggregates for each parent
- fn(loc_level,
- location.id,
- resilience_pid,
- indicator_pids,
- start_date,
- end_date,
- use_location = False,
- )
# -------------------------------------------------------------------------
@staticmethod
View
9 modules/s3/s3xml.py
@@ -1108,9 +1108,12 @@ def record(self, table, element,
continue
if f == self.APPROVED:
# Override default-approver:
- if "approved_by" in table and \
- element.get(f, "true").lower() == "false":
- record["approved_by"] = None
+ if "approved_by" in table:
+ if element.get(f, "true").lower() == "false":
+ record["approved_by"] = None
+ else:
+ if table["approved_by"].default == None:
+ auth.permission.set_default_approver(table)
continue
if f in self.IGNORE_FIELDS or f in skip:
continue
View
1 modules/unit_tests/eden/stats.py
@@ -97,6 +97,7 @@ def approve_record(self, record):
resource.approve()
resource = s3db.resource("stats_data", id=record.data_id, unapproved=True)
resource.approve()
+ s3db.stats_update_time_aggregate(resource.select())
def testStats_aggregate(self):
"""
View
7 private/templates/IFRC_Train/tasks.cfg
@@ -157,9 +157,14 @@ stats,group_type,Vulnerability/stats_group_type.csv,group_type.xsl
# Add sample locations, the indicators and data
vulnerability,aggregated_indicator,Vulnerability/aggregated_indicator.csv,aggregated_indicator.xsl
vulnerability,indicator,Vulnerability/indicator.csv,indicator.xsl
+vulnerability,data,Vulnerability/vulnerability_data_short.csv,data.xsl
vulnerability,data,Vulnerability/vulnerability_data.csv,data.xsl
+#vulnerability,data,Vulnerability/vulnerability_data_historical.csv,data.xsl
+#vulnerability,data,Vulnerability/vulnerability_data_long.csv,data.xsl
# Demographics (needs to be after Vulnerability)
stats,demographic,IFRC/stats_demographic.csv,demographic.xsl
-stats,demographic_data,Vulnerability/demographic_data.csv,demographic_data.xsl
+#stats,demographic_data,Vulnerability/demographic_data_short.csv,demographic_data.xsl
+#stats,demographic_data,Vulnerability/demographic_data.csv,demographic_data.xsl
+#stats,demographic_data,Vulnerability/demographic_data_long.csv,demographic_data.xsl
#*,stats_rebuild_aggregates,
# END -------------------------------------------------------------------------
View
88 private/templates/IFRC_Train/users.csv
@@ -1,42 +1,46 @@
-First Name,Last Name,Email,Password,Role,Organisation
-Test,User,test@ifrc.org,eden,"inv_editor/0,project_editor/0,staff_editor/0,vol_editor/0,survey_editor/0,member_editor/0,vulnerability_editor/0",International Federation of Red Cross and Red Crescent Societies
-Adriana,Macedo,adriana.macedo@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Duarte,Botelheiro,duarte.botelheiro@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Beatriz,de Carvalho,beatriz.decarvalho@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Yakobus,Sereno,yakobus.serena@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Liliana,Otilia,liliana.otilia@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Eduardo,dos Santos,eduardo.dossantos@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Margarida,Martins,margarida.martins@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
-Eeru,Hykka,eeru.hykka@punainenristi.fi,eden,,Finnish Red Cross
-Asset,Reader,asset_reader@example.com,eden,asset_reader/0,International Federation of Red Cross and Red Crescent Societies
-Asset,Data Entry,asset_data_entry@example.com,eden,asset_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Asset,Editor,asset_editor@example.com,eden,asset_editor/0,International Federation of Red Cross and Red Crescent Societies
-Asset,Super Editor,asset_super@example.com,eden,asset_super/0,International Federation of Red Cross and Red Crescent Societies
-Warehouse,Reader,inv_reader@example.com,eden,inv_reader/0,International Federation of Red Cross and Red Crescent Societies
-Warehouse,Data Entry,inv_data_entry@example.com,eden,inv_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Warehouse,Editor,inv_editor@example.com,eden,inv_editor/0,International Federation of Red Cross and Red Crescent Societies
-Warehouse,Super Editor,inv_super@example.com,eden,inv_super/0,International Federation of Red Cross and Red Crescent Societies
-Incident,Reader,irs_reader@example.com,eden,irs_reader/0,International Federation of Red Cross and Red Crescent Societies
-Incident,Data Entry,irs_data_entry@example.com,eden,irs_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Incident,Editor,irs_editor@example.com,eden,irs_editor/0,International Federation of Red Cross and Red Crescent Societies
-Incident,Super Editor,irs_super@example.com,eden,irs_super/0,International Federation of Red Cross and Red Crescent Societies
-Members,Reader,member_reader@example.com,eden,member_reader/0,International Federation of Red Cross and Red Crescent Societies
-Members,Data Entry,member_data_entry@example.com,eden,member_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Members,Editor,member_editor@example.com,eden,member_editor/0,International Federation of Red Cross and Red Crescent Societies
-Members,Super Editor,member_super@example.com,eden,member_super/0,International Federation of Red Cross and Red Crescent Societies
-Project,Reader,project_reader@example.com,eden,project_reader/0,International Federation of Red Cross and Red Crescent Societies
-Project,Data Entry,project_data_entry@example.com,eden,project_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Project,Editor,project_editor@example.com,eden,project_editor/0,International Federation of Red Cross and Red Crescent Societies
-Project,Super Editor,project_super@example.com,eden,project_super/0,International Federation of Red Cross and Red Crescent Societies
-Staff,Reader,staff_reader@example.com,eden,staff_reader/0,International Federation of Red Cross and Red Crescent Societies
-Staff,Data Entry,staff_data_entry@example.com,eden,staff_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Staff,Editor,staff_editor@example.com,eden,staff_editor/0,International Federation of Red Cross and Red Crescent Societies
-Staff,Super Editor,staff_super@example.com,eden,staff_super/0,International Federation of Red Cross and Red Crescent Societies
-Volunteer,Reader,vol_reader@example.com,eden,vol_reader/0,International Federation of Red Cross and Red Crescent Societies
-Volunteer,Data Entry,vol_data_entry@example.com,eden,vol_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Volunteer,Editor,vol_editor@example.com,eden,vol_editor/0,International Federation of Red Cross and Red Crescent Societies
-Volunteer,Super Editor,vol_super@example.com,eden,vol_super/0,International Federation of Red Cross and Red Crescent Societies
-Assessment,Reader,survey_reader@example.com,eden,survey_reader/0,International Federation of Red Cross and Red Crescent Societies
-Assessment,Data Entry,survey_data_entry@example.com,eden,survey_data_entry/0,International Federation of Red Cross and Red Crescent Societies
-Assessment,Editor,survey_editor@example.com,eden,survey_editor/0,International Federation of Red Cross and Red Crescent Societies
-Assessment,Super Editor,survey_super@example.com,eden,survey_super/0,International Federation of Red Cross and Red Crescent Societies
+First Name,Last Name,Email,Password,Role,Organisation
+Test,User,test@ifrc.org,eden,"inv_editor/0,project_editor/0,staff_editor/0,vol_editor/0,survey_editor/0,member_editor/0,vulnerability_editor/0",International Federation of Red Cross and Red Crescent Societies
+Adriana,Macedo,adriana.macedo@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Duarte,Botelheiro,duarte.botelheiro@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Beatriz,de Carvalho,beatriz.decarvalho@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Yakobus,Sereno,yakobus.serena@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Liliana,Otilia,liliana.otilia@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Eduardo,dos Santos,eduardo.dossantos@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Margarida,Martins,margarida.martins@redcross.tl,eden,"inv_editor,project_editor,staff_editor,vol_editor,survey_editor,member_editor,vulnerability_editor",Timor-Leste Red Cross Society
+Eeru,Hykka,eeru.hykka@punainenristi.fi,eden,,Finnish Red Cross
+Asset,Reader,asset_reader@example.com,eden,asset_reader/0,International Federation of Red Cross and Red Crescent Societies
+Asset,Data Entry,asset_data_entry@example.com,eden,asset_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Asset,Editor,asset_editor@example.com,eden,asset_editor/0,International Federation of Red Cross and Red Crescent Societies
+Asset,Super Editor,asset_super@example.com,eden,asset_super/0,International Federation of Red Cross and Red Crescent Societies
+Warehouse,Reader,inv_reader@example.com,eden,inv_reader/0,International Federation of Red Cross and Red Crescent Societies
+Warehouse,Data Entry,inv_data_entry@example.com,eden,inv_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Warehouse,Editor,inv_editor@example.com,eden,inv_editor/0,International Federation of Red Cross and Red Crescent Societies
+Warehouse,Super Editor,inv_super@example.com,eden,inv_super/0,International Federation of Red Cross and Red Crescent Societies
+Incident,Reader,irs_reader@example.com,eden,irs_reader/0,International Federation of Red Cross and Red Crescent Societies
+Incident,Data Entry,irs_data_entry@example.com,eden,irs_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Incident,Editor,irs_editor@example.com,eden,irs_editor/0,International Federation of Red Cross and Red Crescent Societies
+Incident,Super Editor,irs_super@example.com,eden,irs_super/0,International Federation of Red Cross and Red Crescent Societies
+Members,Reader,member_reader@example.com,eden,member_reader/0,International Federation of Red Cross and Red Crescent Societies
+Members,Data Entry,member_data_entry@example.com,eden,member_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Members,Editor,member_editor@example.com,eden,member_editor/0,International Federation of Red Cross and Red Crescent Societies
+Members,Super Editor,member_super@example.com,eden,member_super/0,International Federation of Red Cross and Red Crescent Societies
+Project,Reader,project_reader@example.com,eden,project_reader/0,International Federation of Red Cross and Red Crescent Societies
+Project,Data Entry,project_data_entry@example.com,eden,project_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Project,Editor,project_editor@example.com,eden,project_editor/0,International Federation of Red Cross and Red Crescent Societies
+Project,Super Editor,project_super@example.com,eden,project_super/0,International Federation of Red Cross and Red Crescent Societies
+Staff,Reader,staff_reader@example.com,eden,staff_reader/0,International Federation of Red Cross and Red Crescent Societies
+Staff,Data Entry,staff_data_entry@example.com,eden,staff_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Staff,Editor,staff_editor@example.com,eden,staff_editor/0,International Federation of Red Cross and Red Crescent Societies
+Staff,Super Editor,staff_super@example.com,eden,staff_super/0,International Federation of Red Cross and Red Crescent Societies
+Volunteer,Reader,vol_reader@example.com,eden,vol_reader/0,International Federation of Red Cross and Red Crescent Societies
+Volunteer,Data Entry,vol_data_entry@example.com,eden,vol_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Volunteer,Editor,vol_editor@example.com,eden,vol_editor/0,International Federation of Red Cross and Red Crescent Societies
+Volunteer,Super Editor,vol_super@example.com,eden,vol_super/0,International Federation of Red Cross and Red Crescent Societies
+Assessment,Reader,survey_reader@example.com,eden,survey_reader/0,International Federation of Red Cross and Red Crescent Societies
+Assessment,Data Entry,survey_data_entry@example.com,eden,survey_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Assessment,Editor,survey_editor@example.com,eden,survey_editor/0,International Federation of Red Cross and Red Crescent Societies
+Assessment,Super Editor,survey_super@example.com,eden,survey_super/0,International Federation of Red Cross and Red Crescent Societies
+Vulnerability,Reader,vul_reader@example.com,eden,vulnerability_reader/0,International Federation of Red Cross and Red Crescent Societies
+Vulnerability,Data Entry,vul_data_entry@example.com,eden,vulnerability_data_entry/0,International Federation of Red Cross and Red Crescent Societies
+Vulnerability,Editor,vul_editor@example.com,eden,vulnerability_editor/0,International Federation of Red Cross and Red Crescent Societies
+Vulnerability,Super Editor,vul_super@example.com,eden,vulnerability_super/0,International Federation of Red Cross and Red Crescent Societies
View
1,333 private/templates/Vulnerability/demographic_data.csv
1,269 additions, 64 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
5,132 private/templates/Vulnerability/demographic_data_long.csv
5,132 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
58 private/templates/Vulnerability/demographic_data_short.csv
@@ -0,0 +1,58 @@
+Demographic,Value,L1,L2,L3,Country,Date,Source Name,Source URL
+Population,923198,,,,TL,2004-07-01,Timor-Leste 2004 Population and Housing Census,http://dne.mof.gov.tl/census/index.htm
+Population,8574,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,8362,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,7926,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,6214,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,9015,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,8454,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,8544,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Population,7381,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,4234,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,4179,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,3951,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,3073,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,4497,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,4219,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,4254,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Male,3673,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,4340,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,4183,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,3975,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,3141,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,4518,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,4235,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,4290,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Female,3708,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,428,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,2706,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,421,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,1329,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,1315,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,2672,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,2989,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Over 60,224,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,1718,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,1819,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,1210,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,1138,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,1072,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,273,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,216,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Under 5,608,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1285,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1860,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1310,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1003,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,2378,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1593,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1699,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households,1945,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,67,Thanh Hóa,Bá Thước,Lũng Cao,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,141,Thanh Hóa,Bá Thước,Lương Nội,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,184,Thanh Hóa,Bá Thước,Lương Trung,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,75,Thanh Hóa,Cẩm Thủy,Cẩm Lương,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,230,Thanh Hóa,Đông Sơn,Rừng Thông,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,191,Thanh Hóa,Hà Trung,Hà Châu,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,98,Thanh Hóa,Hà Trung,Hà Long,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
+Households below poverty line,274,Thanh Hóa,Hà Trung,Hà Tiến,VN,1999-04-01,Vietnam 1999 Population and Housing Census,http://www.gso.gov.vn/default_en.aspx?tabid=476&idmid=4&ItemID=1841
View
2,092 private/templates/Vulnerability/vulnerability_data.csv
1,951 additions, 141 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
21 private/templates/Vulnerability/vulnerability_data_extra_2.csv
@@ -0,0 +1,21 @@
+Indicator,Description,Value,Country,Date,L1,L2,L3
+Indicator One,,1,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Two,,2,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Three,,3,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Four,,3,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Five,,1,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Six,,2,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Seven,,3,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Eight,,1,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Nine,,2,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Ten,,2,VN,30/11/2011,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator One,,1,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Two,,1,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Three,,4,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Four,,3,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Five,,3,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Six,,3,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Seven,,4,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Eight,,2,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Nine,,2,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
+Indicator Ten,,1,VN,30/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông
View
12,671 private/templates/Vulnerability/vulnerability_data_historical.csv
12,671 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
7,331 private/templates/Vulnerability/vulnerability_data_long.csv
7,331 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
141 private/templates/Vulnerability/vulnerability_data_short.csv
@@ -0,0 +1,141 @@
+Indicator,Description,Value,Country,Date,L1,L2,L3,Name,Approved
+Indicator One,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Two,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Three,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Four,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Five,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Six,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Seven,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Eight,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Nine,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Ten,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator One,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Two,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Three,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Four,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Five,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Six,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Seven,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Eight,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Nine,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator Ten,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lũng Cao,,
+Indicator One,,2,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Two,,2,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Three,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Four,,2,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Five,,5,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Six,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Seven,,5,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Eight,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Nine,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator Ten,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lũng Cao,,false
+Indicator One,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Two,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Three,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Four,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Five,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Six,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Seven,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Eight,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Nine,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Ten,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator One,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Two,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Three,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Four,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Five,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Six,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Seven,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Eight,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Nine,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator Ten,,2,VN,30/11/2011,Thanh Hóa,Bá Thước,Lương Nội,,
+Indicator One,,2,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Two,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Three,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Four,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Five,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Six,,2,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Seven,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Eight,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Nine,,3,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator Ten,,4,VN,31/05/2012,Thanh Hóa,Bá Thước,Lương Nội,,false
+Indicator One,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Two,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Three,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Four,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Five,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Six,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Seven,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Eight,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Nine,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Ten,,1,VN,30/11/2009,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator One,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Two,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Three,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Four,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Five,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Six,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Seven,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Eight,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Nine,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator Ten,,2,VN,31/12/2011,Thanh Hóa,Bá Thước,Lương Trung,,
+Indicator One,,2,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Two,,4,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Three,,2,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Four,,4,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Five,,3,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Six,,3,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Seven,,5,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Eight,,3,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Nine,,5,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator Ten,,3,VN,30/06/2012,Thanh Hóa,Bá Thước,Lương Trung,,false
+Indicator One,,2,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Two,,2,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Three,,5,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Four,,4,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Five,,3,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Six,,3,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Seven,,5,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Eight,,4,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Nine,,2,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator Ten,,3,VN,31/05/2012,Thanh Hóa,Cẩm Thủy,Cẩm Lương,,false
+Indicator One,,4,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Two,,5,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Three,,3,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Four,,4,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Five,,3,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Six,,2,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Seven,,5,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Eight,,4,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Nine,,5,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator Ten,,3,VN,31/05/2012,Thanh Hóa,Đông Sơn,Rừng Thông,,false
+Indicator One,,2,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Two,,3,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Three,,3,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Four,,3,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Five,,5,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Six,,3,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Seven,,5,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Eight,,4,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Nine,,5,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator Ten,,4,VN,30/06/2012,Thanh Hóa,Hà Trung,Hà Châu,,false
+Indicator One,,2,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Two,,2,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Three,,2,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Four,,2,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Five,,3,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Six,,2,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Seven,,5,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Eight,,4,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Nine,,3,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator Ten,,3,VN,31/07/2012,Thanh Hóa,Hà Trung,Hà Long,,false
+Indicator One,,2,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Two,,2,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Three,,4,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Four,,4,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Five,,3,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Six,,2,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Seven,,4,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Eight,,4,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Nine,,5,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
+Indicator Ten,,4,VN,31/05/2012,Thanh Hóa,Hà Trung,Hà Tiến,,false
View
30 static/formats/s3csv/stats/demographic_data.xsl
@@ -129,7 +129,10 @@
</xsl:choose>
</xsl:variable>
- <resource name="stats_demographic_data" approved="$approved">
+ <resource name="stats_demographic_data">
+ <xsl:attribute name="approved">
+ <xsl:value-of select="$approved"/>
+ </xsl:attribute>
<data field="value"><xsl:value-of select="col[@field='Value']"/></data>
<data field="date"><xsl:value-of select="col[@field='Date']"/></data>
<!-- Bad to hardcode a created_by to an ID in an .xsl!
@@ -184,23 +187,26 @@
<xsl:variable name="date" select="col[@field='Date']"/>
<xsl:variable name="source" select="col[@field='Source Name']"/>
+ <xsl:variable name="approved">
+ <xsl:choose>
+ <xsl:when test="col[@field='Approved']='false'">
+ <xsl:text>false</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>true</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
<resource name="stats_group">
<xsl:attribute name="tuid">
<xsl:value-of select="concat('stats_group/',$location,'/',$date,'/',$source)"/>
</xsl:attribute>
+ <xsl:attribute name="approved">
+ <xsl:value-of select="$approved"/>
+ </xsl:attribute>
<data field="date"><xsl:value-of select="$date"/></data>
<data field="created_by">1</data>
- <xsl:choose>
- <xsl:when test="$status='Pending'">
- <data field="approved_by">0</data>
- </xsl:when>
- <xsl:when test="$status='Approved'">
- <data field="approved_by">1</data>
- </xsl:when>
- <xsl:otherwise>
- <data field="approved_by">0</data>
- </xsl:otherwise>
- </xsl:choose>
<!-- Link to Location -->
<xsl:call-template name="LocationReference"/>
View
10 static/formats/s3csv/vulnerability/data.xsl
@@ -128,7 +128,10 @@
</xsl:choose>
</xsl:variable>
- <resource name="vulnerability_data" approved="$approved">
+ <resource name="vulnerability_data">
+ <xsl:attribute name="approved">
+ <xsl:value-of select="$approved"/>
+ </xsl:attribute>
<data field="value"><xsl:value-of select="col[@field='Value']"/></data>
<data field="date"><xsl:value-of select="$date"/></data>
@@ -191,7 +194,10 @@
</xsl:choose>
</xsl:variable>
- <resource name="stats_group" approved="$approved">
+ <resource name="stats_group">
+ <xsl:attribute name="approved">
+ <xsl:value-of select="$approved"/>
+ </xsl:attribute>
<xsl:attribute name="tuid">
<xsl:value-of select="concat('stats_group/',$locationPath,'/',$date)"/>
</xsl:attribute>
View
19 static/scripts/S3/s3.vulnerability.js
@@ -2533,14 +2533,16 @@ function openReportRow(className) {
if (shownReport != -1) {
hideReportDetails(shownReport);
}
- if ($('.' + className).html().indexOf('(0)') == -1) {
- accordionRow(0, 'level_1', className);
- } else if ($('.group_011').html().indexOf('(0)') == -1) {
- accordionRow(0, 'level_1', 'group_011');
- } else if ($('.group_012').html().indexOf('(0)') == -1) {
- accordionRow(0, 'level_1', 'group_012');
- } else {
- accordionRow(0, 'level_1', 'group_013');
+ if ($('.' + className)) {
+ if ($('.' + className).html().indexOf('(0)') == -1) {
+ accordionRow(0, 'level_1', className);
+ } else if ($('.group_011').html().indexOf('(0)') == -1) {
+ accordionRow(0, 'level_1', 'group_011');
+ } else if ($('.group_012').html().indexOf('(0)') == -1) {
+ accordionRow(0, 'level_1', 'group_012');
+ } else {
+ accordionRow(0, 'level_1', 'group_013');
+ }
}
}
@@ -2820,6 +2822,7 @@ function displaySubmitDataIndicators() {
$('#submitDataUpload').html($('#submitDataUpload').html());
$('#submitDataContent .reviewIndicatorsView h3').html(S3.i18n.review + " <span class='currentPage'>" + page + '</span> ' + S3.i18n.of + " <span class='totalPages'>" + total_pages + '<span>');
$('.reviewIndicatorsView h4 mark').html(page_data['location']);
+ $('.reviewIndicatorsView h4 date').html(page_data['date']);
$('.reviewIndicatorsView .indicatorReviewTable tbody tr').each(function() {
var indicator = $(this).find('td.indicatorLabels').html().substr(14);
var rating = page_data['data'][indicator];
View
9 static/scripts/S3/s3.vulnerability.min.js
@@ -125,7 +125,7 @@ function getFilteredReport(){var a={};a.location_id=$("#l3_reports").val()?$("#l
function prepareReport(a){$("#dateFromReports").datepicker({dateFormat:"yy-mm-dd",changeYear:!0,changeMonth:!0,maxDate:"+0d",minDate:"-20y"});$("#dateToReports").datepicker({dateFormat:"yy-mm-dd",changeYear:!0,changeMonth:!0,maxDate:"+0d",minDate:"-20y"});$(".rowForApproval").hide();$(".rowForApproval").prev().find(".closeReviewButton").hide();$(".rowForApproval").prev().find(".reviewButton").show();$(".headerRow.activeSection td.arrowCell .arrow").html("&rarr;");$(".headerRow.activeSection").removeClass("activeSection");
$("."+rep_section+"Header").addClass("activeSection");$(".headerRow.activeSection .arrow").html("&darr;");$(".activeContent").hide();$(".activeContent").removeClass("activeContent");$(".activeSection").next().addClass("activeContent");$(".activeSection").parent().next().addClass("activeContent");$(".activeContent").css("display","block");$(".approvalScreen").hide();$("#lightbox, #reportsSection").fadeIn(300);$("#table-container").empty();a?($("#table-container").append(a.report),fnInitDataTable($("#report"),
0,!0),formatTable(a),openReportRow("group_011")):$("#numberReports").html(S3.i18n.no_entries_found);resizeReports()}function displayReport(a){$("#table-container").empty();a?($("#table-container").append(a),fnInitDataTable($("#report"),0,!0),formatTable(a),openReportRow("group_011")):$("#numberReports").html(S3.i18n.no_entries_found);resizeReports()}
-function openReportRow(a){-1!=shownReport&&hideReportDetails(shownReport);-1==$("."+a).html().indexOf("(0)")?accordionRow(0,"level_1",a):-1==$(".group_011").html().indexOf("(0)")?accordionRow(0,"level_1","group_011"):-1==$(".group_012").html().indexOf("(0)")?accordionRow(0,"level_1","group_012"):accordionRow(0,"level_1","group_013")}
+function openReportRow(a){-1!=shownReport&&hideReportDetails(shownReport);$("."+a)&&(-1==$("."+a).html().indexOf("(0)")?accordionRow(0,"level_1",a):-1==$(".group_011").html().indexOf("(0)")?accordionRow(0,"level_1","group_011"):-1==$(".group_012").html().indexOf("(0)")?accordionRow(0,"level_1","group_012"):accordionRow(0,"level_1","group_013"))}
function formatTable(){$("#report").addClass("reportsTable");$("#report").addClass("headerTable");$(".group").each(function(){$(this).addClass("headerLabel")});$("#report th");$("#report tr").each(function(){$(this).hasClass("even")&&$(this).addClass("gray");var a=$(this).find("td:first");0==a.length&&(a=$(this).find("th:first"));a.addClass("date");a=a.next();a.addClass("communeName");a=a.next();a.addClass("type");a=a.next();a.addClass("submittedBy");a=a.next();a.addClass("status");a=a.next();a.addClass("action")});
$("#numberReports").html($("#reportCount").val());$(".expandable").click(function(){-1!=shownReport&&hideReportDetails(shownReport);thisAccordionRow(0,this)})}function showReportDetails(a){$.getJSON("report/review",{id:a}).done(function(b){displayReportDetails(a,b)}).fail(function(){alert("error")})}function viewReportDetails(a){$.getJSON("report/view",{id:a}).done(function(b){displayReportDetails(a,b)}).fail(function(){alert("error")})}
function hideReportDetails(a){var b=$("#"+a).parent().parent();$("#show"+a).remove();$(b).find(".reviewButton").show();$(b).find(".viewButton").show();$(b).find(".closeReviewButton").hide()}
@@ -134,9 +134,10 @@ function displayThanks(a,b){$(".approvalScreen .thanks").html(a);$(".approvalScr
function processReportDetails(){id=this.name.substr(7);$("#table-container").empty();hideReportDetails(id);var a=$("#form"+id).serialize(),b=getFilteredReport();b.id=id;b.report=a;$("#"+id).parent().parent();$(this).hasClass("approveButton")?(displayThanks(S3.i18n.approval_request_submitted,null),$.ajax({type:"POST",url:"report/approve",data:b}).done(function(a){$(".approvalScreen").hide();displayThanks(S3.i18n.thankyou_for_your_approval,5E3);displayReport(a)}).fail(function(){alert("error");$(".approvalScreen").hide()})):
(displayThanks(S3.i18n.reject_request_submitted,null),$.ajax({type:"POST",url:"report/decline",data:b}).done(function(a){$(".approvalScreen").hide();displayThanks(S3.i18n.submission_has_been_declined,5E3);displayReport(a)}).fail(function(){alert("error");$(".approvalScreen").hide()}))}
function uploadSubmitDataIndicators(){var a=new FormData($("#uploadIndicatorsForm")[0]);a.append("action","vulnerability_part1");a.append("approach","ajax");$.ajax({url:"submitData/import.aadata",type:"POST",data:a,cache:!1,contentType:!1,processData:!1}).done(function(a){a.Error?alert(a.Error):(submitDataJobID=a.upload_id,submitDataItemIDs=a.items,submitedData=a.data,submitedDataPage=0,$(".indicatorsStart").fadeOut(300),displaySubmitDataIndicators())}).fail(function(){alert("error")})}
-function displaySubmitDataIndicators(){submitedData&&(total_pages=submitedData.length,page_data=submitedData[submitedDataPage],page=submitedDataPage+1);$("#submitDataUpload").html($("#submitDataUpload").html());$("#submitDataContent .reviewIndicatorsView h3").html(S3.i18n.review+" <span class='currentPage'>"+page+"</span> "+S3.i18n.of+" <span class='totalPages'>"+total_pages+"<span>");$(".reviewIndicatorsView h4 mark").html(page_data.location);$(".reviewIndicatorsView .indicatorReviewTable tbody tr").each(function(){var a=
-$(this).find("td.indicatorLabels").html().substr(14),a=page_data.data[a];$(this).find("input[value='"+a+"']").attr("checked",true)});$(".reviewIndicatorsView.firstPage").fadeIn(300);$("#submitDataFilters").animate({"background-color":"#f7941d"},500);$("#submitDataFilters h3").hide(300);$("#submissionToggle").hide(300);1==page&&($("#submitDataFooter mark, #submitDataFooter .reviewNextButton").fadeIn(300),$(".backButton").hide());1<page&&!$(".backButton").is(":visible")&&$(".backButton").fadeIn(300);
-page==total_pages?($(".reviewNextButton").hide(),$(".submitAllButton").show()):($(".reviewNextButton").show(),$(".submitAllButton").hide())}function nextSubmitDataReview(){submitedDataPage+=1;total_pages=submitedData.length;submitedDataPage>=total_pages&&(submitedDataPage=total_pages-1);displaySubmitDataIndicators()}function backSubmitDataReview(){submitedDataPage-=1;0>submitedDataPage&&(submitedDataPage=0);displaySubmitDataIndicators()}
+function displaySubmitDataIndicators(){submitedData&&(total_pages=submitedData.length,page_data=submitedData[submitedDataPage],page=submitedDataPage+1);$("#submitDataUpload").html($("#submitDataUpload").html());$("#submitDataContent .reviewIndicatorsView h3").html(S3.i18n.review+" <span class='currentPage'>"+page+"</span> "+S3.i18n.of+" <span class='totalPages'>"+total_pages+"<span>");$(".reviewIndicatorsView h4 mark").html(page_data.location);$(".reviewIndicatorsView h4 date").html(page_data.date);
+$(".reviewIndicatorsView .indicatorReviewTable tbody tr").each(function(){var a=$(this).find("td.indicatorLabels").html().substr(14),a=page_data.data[a];$(this).find("input[value='"+a+"']").attr("checked",true)});$(".reviewIndicatorsView.firstPage").fadeIn(300);$("#submitDataFilters").animate({"background-color":"#f7941d"},500);$("#submitDataFilters h3").hide(300);$("#submissionToggle").hide(300);1==page&&($("#submitDataFooter mark, #submitDataFooter .reviewNextButton").fadeIn(300),$(".backButton").hide());
+1<page&&!$(".backButton").is(":visible")&&$(".backButton").fadeIn(300);page==total_pages?($(".reviewNextButton").hide(),$(".submitAllButton").show()):($(".reviewNextButton").show(),$(".submitAllButton").hide())}function nextSubmitDataReview(){submitedDataPage+=1;total_pages=submitedData.length;submitedDataPage>=total_pages&&(submitedDataPage=total_pages-1);displaySubmitDataIndicators()}
+function backSubmitDataReview(){submitedDataPage-=1;0>submitedDataPage&&(submitedDataPage=0);displaySubmitDataIndicators()}
function submitImportSubmitData(){details={approach:"ajax",action:"vulnerability_part2",job:submitDataJobID,mode:"Inclusive",selected:JSON.stringify(submitDataItemIDs)};$.ajax({url:"submitData/import",type:"POST",data:details}).done(function(){$(".reviewIndicatorsView").fadeOut(300);$("#indicatorsSubmissionViews .thankyou").fadeIn(300);$("#submitDataFooter div, #submitDataFooter mark").fadeOut(300);$("#submitDataFooter .submitMoreButton").fadeIn(300)}).fail(function(){alert("error")})}
function moreSubmitData(){$(".thankyou, #submitDataFooter .submitMoreButton").fadeOut(300);$("#submitDataFilters").animate({"background-color":"#c6c6c6"},500);$("#submitDataFilters h3").fadeIn(300);$("#submissionToggle").fadeIn(300);$("#submitDataContent .dataUploadContainer h4").html(S3.i18n.select_data_type);$("#submitDataContent .dataUploadContainer h3, .delete, .reviewTitling").hide();$("#indicatorsSubmissionViews").is(":visible")?($("#uploadIndicatorsForm").html($("#uploadIndicatorsForm").html()),
$("#submitDataContent .indicatorsStart").fadeIn(300),$("#submitDataContent .indicatorsStart p").filter(":first").show()):($("#newSubmissionRegions, #dataSubmissionRegion .submissionContent").empty(),$("#dataSubmissionRegion").removeClass("mapSubmission imageSubmission otherSubmission demographicsSubmission vcaSubmission loaded").removeAttr("style"),$("#dataSubmissionRegion input").attr("disabled",!1).attr("checked",!1),$("#dataAndReportsSubmissionViews .dataUploadContainer").fadeIn(300),$(".fileType, .labelFile, .remove, .imgDesc, .fakePlaceholder, .labelHangRight, .checkHangRight").fadeIn(300),
View
2 views/vulnerability/submit_data.html
@@ -70,7 +70,7 @@
</div>
<div class='reviewIndicatorsView firstPage'>
<h3>{{=T("Review")}} <span class='currentPage'>1</span> {{=T("of")}} <span class='totalPages'>3</span></h3>
- <h4>{{=T("Please review indicator ratings for")}} <mark>Hoa Tam Commune.</mark></h4>
+ <h4>{{=T("Please review indicator ratings for")}} <mark>Hoa Tam Commune.</mark> on <date>8-Oct-2012<date></h4>
<section class='indicatorReviewTable'>
<table class='indicatorsTable'>
<thead>

0 comments on commit d532d89

Please sign in to comment.