Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #301 #302 - Involved and Vehicles data #338

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 52 additions & 44 deletions static/js/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,6 @@ var MarkerView = Backbone.View.extend({
this.$el.find("." + value).text(fields[field] + ": " + localization[field][this.model.get(value)]);
}
},
localize_inv : function(field,value) {
// localizes involved data
if (this.model.has(value) && this.model.get(value)!="" &&
inv_dict[field][this.model.get(value)]!=undefined) {
this.$el.find("." + value).text(fields[field] + ": " + inv_dict[field][this.model.get(value)]);
}
},
localize_veh : function(field,value) {
// localizes vehicles data
if (this.model.has(value) && this.model.get(value)!="" &&
veh_dict[field][this.model.get(value)]!=undefined) {
this.$el.find("." + value).text(fields[field] + ": " + veh_dict[field][this.model.get(value)]);
}
},
localize_num : function(field,value) {
// localizes interger data values
if (this.model.has(value) && this.model.get(value)!="" &&
fields[field]!=undefined) {
this.$el.find("." + value).text(fields[field] + ": " + this.model.get(value));
}
},

render : function() {

Expand Down Expand Up @@ -101,28 +80,6 @@ var MarkerView = Backbone.View.extend({
this.localize("OFEN_HAZIYA","cross_mode");
this.localize("MEKOM_HAZIYA","cross_location");
this.localize("KIVUN_HAZIYA","cross_direction");
// Involved fields: TODO: add AJAX calls to get dictionary required fields (INVOLVED + VEHICLES)
this.localize_inv("SUG_MEORAV","involved_type");
this.localize_num("SHNAT_HOZAA","license_aquiring_date");
this.localize_num("KVUZA_GIL","age_group"); // Dictionary.csv - Table 92
this.localize_inv("MIN","sex");
this.localize_inv("SUG_REHEV_NASA_LMS","car_type");
this.localize_inv("EMZAE_BETIHUT","safety_measures");
this.localize_num("SEMEL_YISHUV_MEGURIM","home_city"); // Cities.csv - "SEMEL"
this.localize_inv("HUMRAT_PGIA","injured_severity");
this.localize_inv("SUG_NIFGA_LMS","injured_type");
this.localize_inv("PEULAT_NIFGA_LMS","injured_position");
this.localize_num("KVUTZAT_OHLUSIYA_LMS","population_type"); // Dictionary.csv - Table 66
// Vehicles fields:
this.localize_num("NEFAH","engine_volume"); // Dictionary.csv - Table 111
this.localize_num("SHNAT_YITZUR","manufacturing_year");
this.localize_num("KIVUNE_NESIA","driving_directions"); // Dictionary.csv - Table 28
this.localize_veh("MATZAV_REHEV","vehicle_status");
this.localize_veh("SHIYUH_REHEV_LMS","vehicle_attribution");
this.localize_veh("SUG_REHEV_LMS","vehicle_type");
this.localize_num("MEKOMOT_YESHIVA_LMS","seats"); // Dictionary.csv - Table 112
this.localize_num("MISHKAL_KOLEL_LMS","total_weight");


this.$el.find(".creation-date").text("תאריך: " +
moment(this.model.get("created")).format("LLLL"));
Expand Down Expand Up @@ -154,8 +111,59 @@ var MarkerView = Backbone.View.extend({
return "/?marker=" + this.model.get("id") + "&" + app.getCurrentUrlParams();
},
clickMarker : function() {
that = this;
$.get("/markers/" + this.model.get("id"), function (data) {
//alert(data);
data = JSON.parse(data);

var localize_data = function(field,value,dataType) {
if (dataType === "invs") {
if (inv_dict[field] != undefined && inv_dict[field][data[i][value]] != undefined) {
text_line = "<p style=margin:0>" + fields[field] + ": " + inv_dict[field][data[i][value]] + "</p>";
that.$el.append(text_line);
}
}else if (dataType === "vehs"){
if (veh_dict[field] != undefined && veh_dict[field][data[i][value]] != undefined) {
text_line = "<p style=margin:0>" + fields[field] + ": " + veh_dict[field][data[i][value]] + "</p>";
that.$el.append(text_line);
}
}else if (dataType === "nums") {
if ([data[i][value]] != 0) {
text_line = "<p style=margin:0>" + fields[field] + ": " + data[i][value] + "</p>";
that.$el.append(text_line);
}
}
}
var j = 1;
for (i in data) {
if (data[i]["sex"] != undefined) {
text_line = "<p style=margin:0><strong>פרטי אדם מעורב" + " " + (i*1+1) + "</strong></p>"
that.$el.append(text_line);
localize_data("SUG_MEORAV","involved_type","invs");
localize_data("SHNAT_HOZAA","license_acquiring_date","nums");
localize_data("KVUZA_GIL","age_group","nums");
localize_data("MIN","sex","invs");
localize_data("SUG_REHEV_NASA_LMS","car_type","invs");
localize_data("EMZAE_BETIHUT","safety_measures","invs");
localize_data("HUMRAT_PGIA","injured_severity","invs");
localize_data("SUG_NIFGA_LMS","injured_type","invs");
localize_data("PEULAT_NIFGA_LMS","injured_position","invs");
localize_data("KVUTZAT_OHLUSIYA_LMS","population_type","nums");
that.$el.append("<p></p>");
}else{
text_line = "<p style=margin:0><strong>פרטי רכב מעורב" + " " + (j) + "</strong></p>"
that.$el.append(text_line);
localize_data("SUG_REHEV_LMS","vehicle_type","vehs");
localize_data("NEFAH","engine_volume","nums");
localize_data("SHNAT_YITZUR","manufacturing_year","nums");
localize_data("KIVUNE_NESIA","driving_directions","nums");
localize_data("MATZAV_REHEV","vehicle_status","vehs");
localize_data("SHIYUH_REHEV_LMS","vehicle_attribution","vehs");
localize_data("MEKOMOT_YESHIVA_LMS","seats","nums");
localize_data("MISHKAL_KOLEL_LMS","total_weight","nums");
that.$el.append("<p></p>");
j++;
}
}
});
this.highlight();
app.closeInfoWindow();
Expand Down
21 changes: 1 addition & 20 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,26 +272,7 @@ <h4 class="title"></h4>
<p class="mainStreet" style="margin:0"></p>
<p class="secondaryStreet" style="margin:0"></p>
<p class="junction" style="margin:0"></p>
<p class="involved_type" style="margin:0"></p>
<p class="license_aquiring_date" style="margin:0"></p>
<p class="age_group" style="margin:0"></p>
<p class="sex" style="margin:0"></p>
<p class="car_type" style="margin:0"></p>
<p class="safety_measures" style="margin:0"></p>
<p class="home_city" style="margin:0"></p>
<p class="injury_severity" style="margin:0"></p>
<p class="injured_type" style="margin:0"></p>
<p class="injured_position" style="margin:0"></p>
<p class="population_type" style="margin:0"></p>
<p class="engine_volume" style="margin:0"></p>
<p class="manufacturing_year" style="margin:0"></p>
<p class="driving_directions" style="margin:0"></p>
<p class="vehicle_status" style="margin:0"></p>
<p class="vehicle_attribution" style="margin:0"></p>
<p class="vehicle_type" style="margin:0"></p>
<p class="seats" style="margin:0"></p>
<p class="total_weight" style="margin:0"></p>

<p></p>
</div>


Expand Down
4 changes: 2 additions & 2 deletions templates/sendemail.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% if current_user.is_authenticated() %}
<div dir="rtl" style="
display: inline-block;
position: fixed;
position: absolute;
left: 0;
right: 0;
width: 300px;
Expand Down Expand Up @@ -57,4 +57,4 @@ <h1>שליחת אימייל למשתמשים רשומים:</h1>
{% endif %}
</div>
</div>
{% endblock body %}
{% endblock body %}