Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Vulnerability reports & submit data

DataTable bug
import person- blood type and emergency contact
  • Loading branch information...
commit 4aff4a595a5fa833cba0e2e47ee73ef2f494d432 1 parent a1ee30c
graeme authored
View
167 controllers/vulnerability.py
@@ -166,8 +166,15 @@ def index():
)
s3.report = report
+ user_id = auth.s3_logged_in_person()
+ person = s3db.pr_person[user_id]
+ user_name = "%s %s" % (person.first_name, person.last_name)
+ now = request.utcnow
+ today = now.strftime("%d-%b-%y")
response.view = "vulnerability/map.html"
- return dict(indicators=indicators)
+ return dict(indicators=indicators,
+ user_name = user_name,
+ today = today)
# -----------------------------------------------------------------------------
def init():
@@ -520,6 +527,8 @@ def reportFilter(filter_request):
sgtable = s3db.stats_group
sgtype = s3db.stats_group_type
+ gistable = s3db.gis_location
+ prtable = s3db.pr_person
query = (sgtable.deleted != True) &\
(sgtable.group_type_id == sgtype.id)
try:
@@ -537,31 +546,28 @@ def reportFilter(filter_request):
query &= (sgtable.date >= filter_request["from_date"])
if filter_request["to_date"]:
query &= (sgtable.date <= filter_request["to_date"])
- indicator = None
+ indicator = (sgtype.name == "stats_vca")
if "indicator" in filter_request:
- indicator = (sgtype.name == "vulnerability_indicator")
+ indicator |= (sgtype.name == "vulnerability_indicator")
if "demographics" in filter_request:
- if indicator:
- indicator |= (sgtype.name == "stats_demographic")
- else:
- indicator = (sgtype.name == "stats_demographic")
+ indicator |= (sgtype.name == "stats_demographic")
if "map" in filter_request:
- if indicator:
- indicator |= (sgtype.name == "stats_map")
- else:
- indicator = (sgtype.name == "stats_map")
+ indicator |= (sgtype.name == "stats_map")
if "images" in filter_request:
- if indicator:
- indicator |= (sgtype.name == "stats_image")
- else:
- indicator = (sgtype.name == "stats_image")
+ indicator |= (sgtype.name == "stats_image")
if "reports" in filter_request:
- if indicator:
- indicator |= (sgtype.name == "stats_other")
- else:
- indicator = (sgtype.name == "stats_other")
- if indicator:
- query &= indicator
+ indicator |= (sgtype.name == "stats_other")
+ query &= indicator
+ if "myReports" in filter_request:
+ user = auth.s3_logged_in_person()
+ query &= ((sgtable.approved_by == user) | (sgtable.created_by == user))
+ if "text" in filter_request and filter_request["text"] != "":
+ text = "%%%s%%" % filter_request["text"].lower()
+ query &= (sgtable.location_id == gistable.id)
+ query &= (sgtable.created_by == prtable.id)
+ query &= ((gistable.name.lower().like(text))
+ | (prtable.first_name.lower().like(text))
+ | (prtable.last_name.lower().like(text)))
return query
# End of reportFilter ------------------------------------------------
@@ -663,11 +669,12 @@ def action_repr(id):
sgtable.approved_by.represent = approved_repr
sgtable.id.represent = action_repr
- filter_request = request.post_vars
- filter = reportFilter(filter_request)
# Ensure that we also get the records awaiting for approval
resource = s3db.resource("stats_group", unapproved=True)
- resource.add_filter(filter)
+ filter_request = request.post_vars
+ if filter_request:
+ filter = reportFilter(filter_request)
+ resource.add_filter(filter)
filteredrows = resource.count()
#############################################################
# Note if list_fields is changed here then it also needs
@@ -723,6 +730,7 @@ def action_repr(id):
report = dt.html(filteredrows,
filteredrows,
"report",
+ dt_displayLength = filteredrows,
dt_pagination = "false",
dt_bFilter = "false",
dt_sDom = "t",
@@ -774,6 +782,7 @@ def getReportDetails(id, buttonsRequired):
limitby=(0, 1)).first()
reportType = rows.stats_group_type.name
reportSource_id = rows.stats_group.source_id
+ valid = True
if reportType == "vulnerability_indicator":
# Get the data for this report
vdtable = s3db.vulnerability_data
@@ -863,39 +872,60 @@ def getReportDetails(id, buttonsRequired):
ditable = s3db.doc_image
query = (ditable.source_id == reportSource_id)
record = db(query).select(limitby=(0, 1)).first()
- size = (250, 250)
- image = s3db.pr_image_represent(record.file, size=size)
- size = s3db.pr_image_size(image, size)
- desc = DIV(record.comments, _class="imageDesc")
- filename = record.name
- url_small = URL(c="default", f="download", args=image)
- alt = record.comments if record.comments else filename
- thumb = IMG(_src=url_small,
- _alt=alt,
- _width=size[0],
- _height=size[1]
- )
- url_full = URL(c="default", f="download", args=record.file)
- download = A(T("Download"), _class="download", _href=url_full)
- view = A(T("View full size"),
- _class="download",
- _href=URL(c="vulnerability", f="view_image", args=record.id),
- _target="blank")
- table = TABLE(_class = "imageTable")
- table.append(TR(TD(thumb, _colspan=4)))
- table.append(TR(TD(desc),
- TD(download),
- TD(DIV(" | ", _class="divider")),
- TD(view),
- _class="mapRow"))
+ if record:
+ size = (250, 250)
+ image = s3db.pr_image_represent(record.file, size=size)
+ size = s3db.pr_image_size(image, size)
+ desc = DIV(record.comments, _class="imageDesc")
+ filename = record.name
+ url_small = URL(c="default", f="download", args=image)
+ alt = record.comments if record.comments else filename
+ thumb = IMG(_src=url_small,
+ _alt=alt,
+ _width=size[0],
+ _height=size[1]
+ )
+ url_full = URL(c="default", f="download", args=record.file)
+ download = A(T("Download"), _class="download", _href=url_full)
+ view = A(T("View full size"),
+ _class="download",
+ _href=URL(c="vulnerability", f="view_image", args=record.id),
+ _target="blank")
+ table = TABLE(_class = "imageTable")
+ table.append(TR(TD(thumb, _colspan=4)))
+ table.append(TR(TD(desc),
+ TD(download),
+ TD(DIV(" | ", _class="divider")),
+ TD(view),
+ _class="mapRow"))
+ else:
+ valid = False
+ elif reportType == "stats_other" or reportType == "stats_vca":
+ doctable = s3db.doc_document
+ query = (doctable.source_id == reportSource_id)
+ record = db(query).select(limitby=(0, 1)).first()
+ if record:
+ desc = DIV(record.name, _class="imageDesc")
+ url = URL(c="default", f="download", args=record.file)
+ download = A(T("Download"), _class="download", _href=url)
+ table = TABLE(_class = "imageTable")
+ table.append(TR(TD(desc),
+ TD(download),
+ _class="mapRow"))
+ else:
+ valid = False
else:
- return "No data available"
+ valid = False
# Place the table in a form and attach the buttons (if required)
form = FORM(_id = "form%s" % id)
- form.append(table)
+ if valid:
+ form.append(table)
+ else:
+ form.append(DIV(T("No data available"),_class="mapRow"))
if buttonsRequired:
- form.append(INPUT(_type = "button", _name = "Approve%s" % id,
- _value = "Approve", _class = "approveButton"))
+ if valid:
+ form.append(INPUT(_type = "button", _name = "Approve%s" % id,
+ _value = "Approve", _class = "approveButton"))
form.append(INPUT(_type = "button", _name = "Decline%s" % id,
_value = "Decline", _class = "declineButton"))
return str(form)
@@ -1086,13 +1116,14 @@ def import_vul_part1():
Controller to manage the first phase of the import of vulnerability indicators
"""
+ from gluon.serializers import json
try:
file = request.vars.file.file
except:
- return T("Error File missing")
+ response.headers["Content-Type"] = "application/json"
+ return json({"Error": str(T("Error File missing"))})
from lxml import etree
- from gluon.serializers import json
output = s3_rest_controller("vulnerability", "data",
csv_stylesheet="data.xsl")
@@ -1186,11 +1217,13 @@ def import_image(action):
"""
Controller to import a report
"""
-
- di_table = s3db.doc_image
+ if action == "map" or action == "image":
+ doc_table = s3db.doc_image
+ else:
+ doc_table = s3db.doc_document
sgtable = s3db.stats_group
sgt_table = s3db.stats_group_type
- di_file = di_table.file
+ di_file = doc_table.file
file = request.vars.file
real_filename = file.filename
new_filename = di_file.store(file, real_filename)
@@ -1198,15 +1231,15 @@ def import_image(action):
creator = auth.s3_logged_in_person()
location_id = request.vars.location
desc = request.vars.desc
- di_id = di_table.insert(file = new_filename,
- name = real_filename,
- date = date,
- comments = desc,
- location_id = location_id,
- created_by = creator
- )
- s3db.update_super(di_table, dict(id=di_id))
- source_id = di_table[di_id].source_id
+ doc_id = doc_table.insert(file = new_filename,
+ name = real_filename,
+ date = date,
+ comments = desc,
+ location_id = location_id,
+ created_by = creator
+ )
+ s3db.update_super(doc_table, dict(id=doc_id))
+ source_id = doc_table[doc_id].source_id
if action == "map":
group = "stats_map"
elif action == "image":
View
2  modules/eden/pr.py
@@ -2807,7 +2807,7 @@ def model(self):
}
# http://docs.oasis-open.org/emergency/edxl-have/cs01/xPIL-types.xsd
- pr_blood_type_opts = ("A+", "A-", "B+", "B-", "AB+", "AB-", "0+", "0-")
+ pr_blood_type_opts = ("A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-")
pr_eye_color_opts = {
1: T("blue"),
View
6 modules/eden/stats.py
@@ -1184,6 +1184,12 @@ def group(self):
if approved is None:
return "Approval pending"
else:
+ sgtype = current.s3db.stats_group_type
+ query = (self.stats_group.group_type_id == sgtype.id)
+ r = current.db(query).select(sgtype.name,
+ limitby = (0, 1)).first()
+ if (r.name == "stats_vca"):
+ return "VCA Report"
# @todo: add conditional branch for VCA report
return "Report"
View
34 private/templates/IFRC_Train/volunteers.csv
@@ -1,17 +1,17 @@
-"Sex","First Name","Last Name","Email","Mobile Phone","Organisation","Branch","Office Phone","Office","Job Title","Home Address","Home Country","Home L1","Home L2","Home L3","Home Lat","Home Lon"
-"Mr.","Natalino","Amaral","natalino.amaral@yahoo.com","+(670) 2906-8755","Timor-Leste Red Cross Society",,,,,"Tasqolo","TL","Bobonaro","Bobonaro","Lour",-9.06795,125.35758
-"Ms.","Isabel","Zacarias","isabel.zacarias@hotmail.com","+(670) 6276-9280","Timor-Leste Red Cross Society",,,,,"Couguira","TL","Baucau","Laga","Tequino Mata",-8.49722,126.60278
-"Ms.","Beatriz","Albuquequer","beatriz.albuquequer@gmail.com","+(670) 4639-3551","Timor-Leste Red Cross Society",,,,,"Hedamea","TL","Ermera","Hatolia","Hatolia",-8.82409,125.32266
-"Mr.","Marcelino","Otilia","marcelino.otilia@yahoo.com","+(670) 6004-8196","Timor-Leste Red Cross Society",,,,,"Mautobalau","TL","Aileu","Aileu Vila","Seloi Craic",-8.71296,125.48791
-"Mr.","Marcelo","Polainos","marcelo.polainos@hotmail.com","+(670) 4327-7315","Timor-Leste Red Cross Society",,,,,"Charano","TL","Lautém","Lospalos","Cacavem",-8.59469,126.88854
-"Mr.","Justiano","Macedo","justiano.macedo@gmail.com","+(670) 2611-9149","Timor-Leste Red Cross Society",,,,,"Caunua","TL","Manatuto","Barique/Natarbora","Barique",-8.84709,126.06484
-"Ms.","Soraia","Moises","soraia.moises@yahoo.com","+(670) 5295-1204","Timor-Leste Red Cross Society",,,,,"Sarlala","TL","Aileu","Aileu Vila","Seloi Craic",-8.67454,125.5507
-"Mr.","Lucio","Horta","lucio.horta@hotmail.com","+(670) 8371-2372","Timor-Leste Red Cross Society",,,,,"Vatalara","TL","Lautém","Lospalos","Cacavem",-8.56221,126.89902
-"Ms.","Claudia","Gohan","claudia.gohan@gmail.com","+(670) 7358-3044","Timor-Leste Red Cross Society",,,,,"Raimaten","TL","Bobonaro","Maliana","Lahomea",-8.9884,125.22017
-"Ms.","Adriana","Ramos","adriana.ramos@yahoo.com","+(670) 1818-7216","Timor-Leste Red Cross Society",,,,,"Hatomanuc","TL","Manatuto","Laclubar","Manelima",-8.79088,125.93067
-"Ms.","Elly","de Carvalho","elly.decarvalho@hotmail.com","+(670) 6166-3906","Timor-Leste Red Cross Society",,,,,"Fatucahi","TL","Manufahi","Fatuberliu","Fatucahi",-9.03412,125.98864
-"Mr.","Orlando","Fahik Batak","orlando.fahikbatak@gmail.com","+(670) 4169-1104","Timor-Leste Red Cross Society",,,,,"Betoria","TL","Viqueque","Uatucarbau","Irabin de Baixo",-8.74656,126.69775
-"Mr.","Yakobus","Maia","yakobus.maia@yahoo.com","+(670) 7187-1430","Timor-Leste Red Cross Society",,,,,"Lelalai","TL","Baucau","Quelicai","Lelalai",-8.65705,126.51793
-"Mr.","Abrao","Moio","abrao.moio@hotmail.com","+(670) 7391-9251","Timor-Leste Red Cross Society",,,,,"Banitur","TL","Liquiçá","Liquiçá","Leoteala",-8.68995,125.29288
-"Ms.","Mariana","Sereno","mariana.sereno@gmail.com","+(670) 9459-1197","Timor-Leste Red Cross Society",,,,,"Manufahi","TL","Manatuto","Soibada","Manufahi",-8.83087,125.9218
-"Mr.","Andreia","Gorette","andreia.gorette@yahoo.com","+(670) 3436-2535","Timor-Leste Red Cross Society",,,,,"Aimerulu","TL","Ermera","Hatolia","Hatolia",-8.81285,125.32802
+"Sex","First Name","Last Name","Email","Mobile Phone","Organisation","Branch","Office Phone","Office","Job Title","Home Address","Home Country","Home L1","Home L2","Home L3","Home Lat","Home Lon","Blood Type","Emergency Contact Name","Emergency Contact Relationship","Emergency Contact Phone"
+"Mr.","Natalino","Amaral","natalino.amaral@yahoo.com","+(670) 2906-8755","Timor-Leste Red Cross Society",,,,,"Tasqolo","TL","Bobonaro","Bobonaro","Lour",-9.06795,125.35758,"A+","Elly Ramos","Spouse","+(670) 2906-8703"
+"Ms.","Isabel","Zacarias","isabel.zacarias@hotmail.com","+(670) 6276-9280","Timor-Leste Red Cross Society",,,,,"Couguira","TL","Baucau","Laga","Tequino Mata",-8.49722,126.60278,"O-",,,
+"Ms.","Beatriz","Albuquequer","beatriz.albuquequer@gmail.com","+(670) 4639-3551","Timor-Leste Red Cross Society",,,,,"Hedamea","TL","Ermera","Hatolia","Hatolia",-8.82409,125.32266,"A-",,,
+"Mr.","Marcelino","Otilia","marcelino.otilia@yahoo.com","+(670) 6004-8196","Timor-Leste Red Cross Society",,,,,"Mautobalau","TL","Aileu","Aileu Vila","Seloi Craic",-8.71296,125.48791,"O+",,,
+"Mr.","Marcelo","Polainos","marcelo.polainos@hotmail.com","+(670) 4327-7315","Timor-Leste Red Cross Society",,,,,"Charano","TL","Lautém","Lospalos","Cacavem",-8.59469,126.88854,"O-",,,
+"Mr.","Justiano","Macedo","justiano.macedo@gmail.com","+(670) 2611-9149","Timor-Leste Red Cross Society",,,,,"Caunua","TL","Manatuto","Barique/Natarbora","Barique",-8.84709,126.06484,"O+",,,
+"Ms.","Soraia","Moises","soraia.moises@yahoo.com","+(670) 5295-1204","Timor-Leste Red Cross Society",,,,,"Sarlala","TL","Aileu","Aileu Vila","Seloi Craic",-8.67454,125.5507,"A+",,,
+"Mr.","Lucio","Horta","lucio.horta@hotmail.com","+(670) 8371-2372","Timor-Leste Red Cross Society",,,,,"Vatalara","TL","Lautém","Lospalos","Cacavem",-8.56221,126.89902,"AB+",,,
+"Ms.","Claudia","Gohan","claudia.gohan@gmail.com","+(670) 7358-3044","Timor-Leste Red Cross Society",,,,,"Raimaten","TL","Bobonaro","Maliana","Lahomea",-8.9884,125.22017,"B-",,,
+"Ms.","Adriana","Ramos","adriana.ramos@yahoo.com","+(670) 1818-7216","Timor-Leste Red Cross Society",,,,,"Hatomanuc","TL","Manatuto","Laclubar","Manelima",-8.79088,125.93067,"A+",,,
+"Ms.","Elly","de Carvalho","elly.decarvalho@hotmail.com","+(670) 6166-3906","Timor-Leste Red Cross Society",,,,,"Fatucahi","TL","Manufahi","Fatuberliu","Fatucahi",-9.03412,125.98864,"O-",,,
+"Mr.","Orlando","Fahik Batak","orlando.fahikbatak@gmail.com","+(670) 4169-1104","Timor-Leste Red Cross Society",,,,,"Betoria","TL","Viqueque","Uatucarbau","Irabin de Baixo",-8.74656,126.69775,"A-",,,
+"Mr.","Yakobus","Maia","yakobus.maia@yahoo.com","+(670) 7187-1430","Timor-Leste Red Cross Society",,,,,"Lelalai","TL","Baucau","Quelicai","Lelalai",-8.65705,126.51793,"O+",,,
+"Mr.","Abrao","Moio","abrao.moio@hotmail.com","+(670) 7391-9251","Timor-Leste Red Cross Society",,,,,"Banitur","TL","Liquiçá","Liquiçá","Leoteala",-8.68995,125.29288,"O-",,,
+"Ms.","Mariana","Sereno","mariana.sereno@gmail.com","+(670) 9459-1197","Timor-Leste Red Cross Society",,,,,"Manufahi","TL","Manatuto","Soibada","Manufahi",-8.83087,125.9218,"A+",,,
+"Mr.","Andreia","Gorette","andreia.gorette@yahoo.com","+(670) 3436-2535","Timor-Leste Red Cross Society",,,,,"Aimerulu","TL","Ermera","Hatolia","Hatolia",-8.81285,125.32802,"O+",,,
View
3  private/templates/Vulnerability/views/layout.html
@@ -40,9 +40,10 @@
</div>
</section>
<![endif]-->
+<div id='lightbox'></div>
<div role='main' id='vulnerability'>
{{include}}
</div>
{{include "scripts.html"}}
</body>
-</html>
+</html>
View
2  static/formats/s3csv/hrm/person.csv
@@ -1 +1 @@
-"Organisation","Branch","PersonType","Sex","First Name","Middle Name","Last Name","Initials","DOB","Father Name","Mother Name","Religion","National ID","Passport No","Passport Country","Passport Expiry Date","Job Title","Start Date","Email","Mobile Phone","Office Phone","Skype","Callsign","Office","Department","Office Country","Office City","Office Street address","Office Postcode","Office Lat","Office Lon","Exact Coord?","Home Address","Home Postcode","Home Country","Home L1","Home L2","Home L3","Home L4","Home Lat","Home Lon","Teams","Projects","Permanent Address","Permanent Postcode","Permanent Country","Permanent L1","Permanent L2","Permanent L3","Permanent L4","Permanent Lat","Permanent Lon","Education Level","Degree Name","Major","Grade","Year","Institute"
+"Organisation","Branch","PersonType","Sex","First Name","Middle Name","Last Name","Initials","DOB","Father Name","Mother Name","Religion","Blood Type","National ID","Passport No","Passport Country","Passport Expiry Date","Job Title","Start Date","Email","Mobile Phone","Office Phone","Skype","Callsign","Emergency Contact Name","Emergency Contact Relationship","Emergency Contact Phone","Office","Department","Office Country","Office City","Office Street address","Office Postcode","Office Lat","Office Lon","Exact Coord?","Home Address","Home Postcode","Home Country","Home L1","Home L2","Home L3","Home L4","Home Lat","Home Lon","Teams","Projects","Permanent Address","Permanent Postcode","Permanent Country","Permanent L1","Permanent L2","Permanent L3","Permanent L4","Permanent Lat","Permanent Lon","Education Level","Degree Name","Major","Grade","Year","Institute"
View
25 static/formats/s3csv/hrm/person.xsl
@@ -29,6 +29,7 @@
Father Name....................optional.....person father name
Mother Name....................optional.....person mother name
Religion.......................optional.....person religion
+ Blood Type.....................optional.....pr_physical_description blood_type
National ID....................optional.....person identity type = 2, value
Passport No....................optional.....person identity type = 1, value
Passport Country...............optional.....person identity
@@ -38,6 +39,9 @@
Office Phone...................optional.....office phone number
Skype..........................optional.....person skype ID
Callsign.......................optional.....person Radio Callsign
+ Emergency Contact Name.........optional.....pr_contact_emergency name
+ Emergency Contact Relationship.optional.....pr_contact_emergency relationship
+ Emergency Contact Phone........optional.....pr_contact_emergency phone
Home Address...................optional.....person home address
Home Postcode..................optional.....person home address postcode
Home Lat.......................optional.....person home address latitude
@@ -445,6 +449,13 @@
<data field="religion"><xsl:value-of select="$religion"/></data>
</xsl:if>
+
+ <xsl:if test="col[@field='Blood Type']!=''">
+ <resource name="pr_physical_description">
+ <data field="blood_type"><xsl:value-of select="col[@field='Blood Type']"/></data>
+ </resource>
+ </xsl:if>
+
<!-- Identity Information -->
<xsl:call-template name="IdentityInformation"/>
@@ -725,6 +736,20 @@
</resource>
</xsl:if>
+ <xsl:if test="col[@field='Emergency Contact Name']!=''">
+ <resource name="pr_contact_emergency">
+ <data field="name">
+ <xsl:value-of select="col[@field='Emergency Contact Name']/text()"/>
+ </data>
+ <data field="relationship">
+ <xsl:value-of select="col[@field='Emergency Contact Relationship']/text()"/>
+ </data>
+ <data field="phone">
+ <xsl:value-of select="col[@field='Emergency Contact Phone']/text()"/>
+ </data>
+ </resource>
+ </xsl:if>
+
</xsl:template>
<!-- ****************************************************************** -->
View
4 static/formats/s3csv/vulnerability/data.xsl
@@ -188,9 +188,9 @@
</xsl:attribute>
<data field="date"><xsl:value-of select="$date"/></data>
<xsl:if test="$status='Approved'">
- <data field="approved_by">1</data>
+ <data field="approved_by">0</data>
</xsl:if>
- <data field="created_by">1</data>
+ <data field="created_by">0</data>
<!-- Link to Location -->
<reference field="location_id" resource="gis_location">
View
28 static/scripts/S3/s3.dataTables.js
@@ -122,9 +122,11 @@ function accordionRow(t, level, groupid) {
// Get the level being opened
var lvlOpened = level.substr(6);
// Get a list of levels from the table
- groupLevel = getElementClass($(tableId[t]), 'level_');
+ theTableID = tableId[t];
+ theTableObj = $(theTableID);
+ groupLevel = getElementClass(theTableObj, 'level_');
// The table should have a list of all the level_# that it supports
- var classList = $(tableId[t]).attr('class').split(/\s+/);
+ var classList = theTableObj.attr('class').split(/\s+/);
$.each( classList, function(index, groupLevel){
if (groupLevel.substr(0, 6) == 'level_'){
var lvlNo = groupLevel.substr(6);
@@ -642,6 +644,7 @@ $(document).ready(function() {
item = getElementClass($(nTrs[i]), 'group_');
sublevel = 'sublevel' + item.substr(6);
sLastGroup = '';
+ groupPrefix = '';
for (var gpCnt = 0; gpCnt < prefixID.length; gpCnt++) {
try {
groupPrefix += oSettings.aoData[ oSettings.aiDisplay[dataCnt] ]._aData[prefixID[gpCnt]] + "_";
@@ -691,6 +694,24 @@ $(document).ready(function() {
}
} // end of loop through for each table
+ function setSpecialSortRules(t){
+ var titles = aoTableConfig[t]['groupTitles'];
+ var order = Array();
+ var fname = 'group-title-' + t;
+ var limit = titles[0].length;
+ for (var cnt=0; cnt < limit; cnt++) {
+ title = titles[0][cnt][0];
+ order[title] = cnt;
+ }
+ jQuery.fn.dataTableExt.oSort[fname + '-asc'] = function(x,y) {
+ return ((order[x] < order[y]) ? -1 : ((order[x] > order[y]) ? 1 : 0));
+ };
+ jQuery.fn.dataTableExt.oSort[fname + '-desc'] = function(x,y) {
+ return ((order[x] < order[y]) ? 1 : ((order[x] > order[y]) ? -1 : 0));
+ };
+ ColumnSettings[t][aoTableConfig[t]['group'][0][0]] = { "sType": fname };
+ }
+
function initDataTable(oTable, t, bReplace) {
var config_id = tableId[t] + '_configurations'
if ($(config_id).length > 0) {
@@ -700,6 +721,9 @@ $(document).ready(function() {
return;
}
aoTableConfig[t]['groupTitles'] = config['groupTitles'];
+ if (config['groupTitles'].length > 0){
+ setSpecialSortRules(t);
+ }
aoTableConfig[t]['groupTotals'] = config['groupTotals'];
aoTableConfig[t]['displayLength'] = config['displayLength'];
oDataTable[t] = $(oTable).dataTable({
View
105 static/scripts/S3/s3.vulnerability.js
@@ -554,25 +554,7 @@ $(document).ready(function() {
resizeReports();
});
- $('#filterSubmit').click(function() {
- displayThanks(S3.i18n.loading_report_details, null);
- $('#table-container').empty();
- hideReportDetails(id);
- var data = getFilteredReport();
- $.ajax({
- type: 'POST',
- url: 'report/filter',
- data: data
- }).done(function(data) {
- $('.approvalScreen').hide();
- displayReport(data);
- }).fail(function() {
- // @ToDo: Something meaningful
- alert('error');
- $('.approvalScreen').hide();
- });
- });
-
+ $('#filterSubmit, .panelSearchSubmit').click(filterReport);
$('#l3_datas').change(indicatorsCheckCommune);
$('#submitIndicators').click(function() {showSubmitData('indicators');});
$('#submitReports').click(function() {showSubmitData('reports');});
@@ -2398,12 +2380,53 @@ function showReports(pSection) {
url: 'report/'
}).done(function(data) {
prepareReport(data);
+ if (pSection == "pending"){
+ accordionRow(0, 'level_1', 'group_011');
+ }else if (pSection == "VCA"){
+ accordionRow(0, 'level_1', 'group_012');
+ } else {
+ accordionRow(0, 'level_1', 'group_013');
+ }
+ }).fail(function() {
+ // @ToDo: Something meaningful
+ alert('error');
+ });
+}
+
+function toggleReports(filter) {
+ switch(filter) {
+ case 'myReports':
+ $('.allReports').removeClass('active').html("<a href=\"javascript:toggleReports('allReports')\" title='All Reports'>" + S3.i18n.all_reports.toUpperCase() + "</a>");
+ $('.myReports').addClass('active').html(S3.i18n.my_reports.toUpperCase());
+ break;
+ case 'allReports':
+ $('.myReports').removeClass('active').html("<a href=\"javascript:toggleReports('myReports')\" title='My Reports'>" + S3.i18n.my_reports.toUpperCase() + "</a>")
+ $('.allReports').addClass('active').html(S3.i18n.all_reports.toUpperCase());
+ break;
+ }
+ filterReport();
+}
+
+function filterReport() {
+ displayThanks(S3.i18n.loading_report_details, null);
+ $('#table-container').empty();
+ hideReportDetails(id);
+ var data = getFilteredReport();
+ $.ajax({
+ type: 'POST',
+ url: 'report/filter',
+ data: data
+ }).done(function(data) {
+ $('.approvalScreen').hide();
+ displayReport(data);
}).fail(function() {
// @ToDo: Something meaningful
alert('error');
+ $('.approvalScreen').hide();
});
}
+
function getFilteredReport() {
// Collect all the data from the filter panel and store it in data
// Pass data back to the server in a simple ajax call.
@@ -2439,6 +2462,9 @@ function getFilteredReport() {
if ($('#demographicsCheckbox').is(':checked')) {
data['demographics'] = true;
}
+ data['text'] = $('#reportTextSearch').val();
+ if ($('#reportsToggle .active').hasClass('myReports'))
+ data['myReports'] = true;
return data;
}
@@ -2660,18 +2686,6 @@ function processReportDetails() {
}
}
-function toggleReports(filter) {
- switch(filter) {
- case 'myReports':
- $('.allReports').removeClass('active').html("<a href=\"javascript:toggleReports('allReports')\" title='All Reports'>" + S3.i18n.all_reports.toUpperCase() + "</a>");
- $('.myReports').addClass('active').html(S3.i18n.my_reports.toUpperCase());
- break;
- case 'allReports':
- $('.myReports').removeClass('active').html("<a href=\"javascript:toggleReports('myReports')\" title='My Reports'>" + S3.i18n.my_reports.toUpperCase() + "</a>")
- $('.allReports').addClass('active').html(S3.i18n.all_reports.toUpperCase());
- break;
- }
-}
/*
// Submit data
function selectSubmitDataType() {
@@ -2738,11 +2752,6 @@ function sillyProgressBarLoadScript(selector) {
function uploadSubmitDataIndicators() {
var formData = new FormData($('#uploadIndicatorsForm')[0]);
- if (!formData['file']) {
- // @ToDo Show an i18n nice error message
- alert('Please, select a file');
- return;
- }
formData.append('action', 'vulnerability_part1');
formData.append('approach', 'ajax');
$.ajax({
@@ -2766,12 +2775,16 @@ function uploadSubmitDataIndicators() {
contentType: false,
processData: false
}).done(function(data) {
- submitDataJobID = data['upload_id'];
- submitDataItemIDs = data['items'];
- submitedData = data['data'];
- submitedDataPage = 0;
- $('.indicatorsStart').fadeOut(300);
- displaySubmitDataIndicators();
+ if (data['Error']) {
+ alert(data['Error']);
+ } else {
+ submitDataJobID = data['upload_id'];
+ submitDataItemIDs = data['items'];
+ submitedData = data['data'];
+ submitedDataPage = 0;
+ $('.indicatorsStart').fadeOut(300);
+ displaySubmitDataIndicators();
+ }
}).fail(function() {
// @ToDo: Something meaningful
alert('error');
@@ -2803,7 +2816,7 @@ function displaySubmitDataIndicators() {
}
// Clear the file input field
$('#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>');
+ $('#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 indicator = $(this).find('td.indicatorLabels').html().substr(14);
@@ -2992,6 +3005,7 @@ function moreSubmitData() {
$('#submitDataContent .dataUploadContainer h4').html(S3.i18n.select_data_type);
$('#submitDataContent .dataUploadContainer h3, .delete, .reviewTitling').hide();
if ($('#indicatorsSubmissionViews').is(':visible')) {
+ $('#uploadIndicatorsForm').html($('#uploadIndicatorsForm').html());
$('#submitDataContent .indicatorsStart').fadeIn(300);
$('#submitDataContent .indicatorsStart p').filter(':first').show();
} else {
@@ -2999,8 +3013,8 @@ function moreSubmitData() {
$('#dataSubmissionRegion').removeClass('mapSubmission imageSubmission otherSubmission demographicsSubmission vcaSubmission loaded').removeAttr('style');
$('#dataSubmissionRegion input').attr('disabled', false).attr('checked', false);
// @ToDo: Where are these used? Global scope?
- numberSubmissions = 2;
- numberSubmissionsDeleted = 0;
+ //numberSubmissions = 2;
+ //numberSubmissionsDeleted = 0;
//$('.dataSubmissionRegion.generic').removeAttr('style')
$('#dataAndReportsSubmissionViews .dataUploadContainer').fadeIn(300);
$('.fileType, .labelFile, .remove, .imgDesc, .fakePlaceholder, .labelHangRight, .checkHangRight').fadeIn(300);
@@ -3013,6 +3027,7 @@ function moreSubmitData() {
function indicatorsCheckCommune() {
switch($('#l3_datas').val()) {
case null:
+ case "":
$('#submitOnlineButton').addClass('disabled');
$('#submitDataContent .indicatorsStart p').filter(':first').show(200);
$('#selectCommune').show(200);
View
1  views/vulnerability/map.html
@@ -262,4 +262,3 @@ <h2 class='eleven'>{{=T("OVERALL RESILIENCE")}}</h2>
{{include "vulnerability/analysis.html"}}
{{include "vulnerability/report.html"}}
{{include "vulnerability/submit_data.html"}}
-<div id='lightbox'></div>
View
4 views/vulnerability/report.html
@@ -74,9 +74,9 @@
<div class='myReports'><a href="javascript:toggleReports('myReports')" title='My Reports'>{{=T("MY REPORTS")}}</a></div>
</div>
<div class='panelSearch'>
- <input class='rounded' type='text' name='reportsSearch' />
+ <input id='reportTextSearch' class='rounded' type='text' name='reportsSearch' />
<div class='panelSearchSubmit'></div>
</div>
<div class='closePanel'></div>
</section>
-</section>
+</section>
View
11 views/vulnerability/submit_data.html
@@ -11,10 +11,10 @@
<div id='submitReports'>{{=T("Data/Reports")}}</div>
</div>
<h4>{{=T("Name")}}</h4>
- <div class='changeUser'>{{=T("Not you?")}}</div>
- <p class='username'>Yumi Endo</p>
+ <div class='changeUser'>{{=A(T("Not you?"), _href="/%s/default/user/logout" % current.request.application)}}</div>
+ <p class='username'>{{=user_name}}</p>
<h4>{{=T("Date of submission")}}</h4>
- <p class='today'>8/13/2012</p>
+ <p class='today'>{{=today}}</p>
</section>
<section class='locationFilters'>
<span id='l0_data'>
@@ -48,19 +48,20 @@
<div class='indicatorsButton filter disabled' id='submitOnlineButton'>{{=T("Submit online")}}</div>
<p>{{=T("or")}}</p>
<form id='uploadIndicatorsForm' enctype='multipart/form-data'>
- <div class='uploadFile' id='submitDataUpload'><input name='file' type='file'/></div>
+ <input class='uploadFile' id='submitDataUpload' name='file' type='file'/>
<div class='indicatorsButton filter' id='uploadIndicatorsButton'>{{=T("Upload indicators")}}</div>
</form>
<div class='downloadLinkCSV'>
<a href='/{{=appname}}/static/formats/s3csv/vulnerability/data.csv' title='Template CSV File'>{{=T("Download.CSV formatted Template")}}</a>&nbsp;&nbsp;&nbsp;&#124;&nbsp;&nbsp;&nbsp;<a href='uploadGuide.pdf' title='How to upload indicators from a file' target='_blank'>{{=T("Guide")}}</a>
</div>
</div>
+ <!---
<div class='loadingView'>
<p>{{=T("Checking your file...")}}</p>
<div class='progressBar'></div>
<div class='fileName'>HoaAn.csv</div>
<a class='cancel' href="javascript:$('#indicatorSubmissionViews .loadingFile').fadeOut(300); $('#indicatorSubmissionViews .indicatorStart').fadeIn(300);" title='Cancel image'>{{=T("Cancel")}}</a>
- </div>
+ </div>-->
<div class='loadingErrorView'>
<h3>{{=T("There is a problem with your file.")}}</h3>
<p>Explain what the problem is here</p>
Please sign in to comment.
Something went wrong with that request. Please try again.