From 346547add9741344a8558a0c7e57847c71783792 Mon Sep 17 00:00:00 2001 From: Aswin Mohan Date: Fri, 17 Aug 2018 00:13:19 +0530 Subject: [PATCH 01/56] Update ReadMe with the FloodMap Repo Link --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e9039eef5..547195b44 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,6 @@ are working on it. ### By fixing bugs or by adding features Please find issues that we need help [here](https://github.com/IEEEKeralaSection/rescuekerala/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). Go through the comments in the issue to check if someone else is already working on it. Don't forget to drop a comment when you start working on it. + +### Flood Map +You can find the repo for the Flood Map here : https://github.com/aswinmohanme/kerala-flood-map From f6947520a89c400d16fcc97b794360838cd738f9 Mon Sep 17 00:00:00 2001 From: Rajeesh Punathil Date: Fri, 17 Aug 2018 15:46:37 +0530 Subject: [PATCH 02/56] Optmized RequestAdmin actions: * 3 admin actions were looping over chosen queryset and hitting the DB for each of the objects in it. Replaced the code with a single queryset update. --- mainapp/admin.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mainapp/admin.py b/mainapp/admin.py index a42b129f1..e461ffef2 100644 --- a/mainapp/admin.py +++ b/mainapp/admin.py @@ -10,18 +10,18 @@ class RequestAdmin(admin.ModelAdmin): list_display = ('district', 'location', 'requestee_phone', 'status','summarise') def Mark_as_completed(self, request, queryset): - for i in queryset: - Request.objects.all().filter(id = i.id).update(status = "sup") + self.message_user(request, "Marked selected requests as completed.") + queryset.update(status="sup") return def Mark_as_new(self, request, queryset): - for i in queryset: - Request.objects.all().filter(id = i.id).update(status = "new") + self.message_user(request, "Marked selected requests as new.") + queryset.update(status="new") return def Mark_as_ongoing(self, request, queryset): - for i in queryset: - Request.objects.all().filter(id = i.id).update(status = "pro") + self.message_user(request, "Marked selected requests as ongoing.") + queryset.update(status="pro") return def download_csv(self, request, queryset): @@ -101,4 +101,4 @@ class RescueCampAdmin(admin.ModelAdmin): admin.site.register(DistrictNeed) admin.site.register(DistrictCollection) admin.site.register(DistrictManager) -admin.site.register(RescueCamp,RescueCampAdmin) \ No newline at end of file +admin.site.register(RescueCamp,RescueCampAdmin) From 8fb1102f64db00aa71525909e114a2a11c38201e Mon Sep 17 00:00:00 2001 From: Rajeesh Punathil Date: Fri, 17 Aug 2018 16:38:09 +0530 Subject: [PATCH 03/56] Updated dmoinfo view to lower DB hits per request from 5 to 3. --- mainapp/views.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mainapp/views.py b/mainapp/views.py index b563e69e0..b68903977 100644 --- a/mainapp/views.py +++ b/mainapp/views.py @@ -12,7 +12,7 @@ from django.contrib.messages.views import SuccessMessageMixin from django.contrib.auth import logout from django.shortcuts import redirect -from django.db.models import Count +from django.db.models import Count, Case, When class CreateRequest(CreateView): model = Request @@ -159,12 +159,23 @@ def dmodash(request): def dmoinfo(request): if("district" not in request.GET.keys()):return HttpResponseRedirect("/") dist = request.GET.get("district") - reqserve = Request.objects.all().filter(status = "sup" , district = dist).count() - reqtotal = Request.objects.all().filter(district = dist).count() + req_summary = Request.objects.filter(district=dist).aggregate( + serve=Count(Case(When(status="sup", then=1))), + total=Count('id'), + ) volcount = Volunteer.objects.all().filter(district = dist).count() - conserve = Contributor.objects.all().filter(status = "ful" , district = dist).count() - contotal = Contributor.objects.all().filter(district = dist).count() - return render(request ,"dmoinfo.html",{"reqserve" : reqserve , "reqtotal" : reqtotal , "volcount" : volcount , "conserve" : conserve , "contotal" : contotal }) + con_summary = Contributor.objects.filter(district=dist).aggregate( + serve=Count(Case(When(status="ful", then=1))), + total=Count('id'), + ) + return render( + request ,"dmoinfo.html", + { + "reqserve" : req_summary['serve'], "reqtotal" : req_summary['total'], + "volcount" : volcount, + "conserve" : con_summary['serve'], "contotal" : con_summary['total'], + } + ) def logout_view(request): logout(request) From 80829385d8cfa7606faf9d4b024669b6cb3c21d0 Mon Sep 17 00:00:00 2001 From: Gautam Date: Sat, 18 Aug 2018 00:36:31 +0530 Subject: [PATCH 04/56] Update models.py Adding need rescue in summarise function --- mainapp/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mainapp/models.py b/mainapp/models.py index de1ee886d..e6a0138e7 100644 --- a/mainapp/models.py +++ b/mainapp/models.py @@ -103,6 +103,8 @@ def summarise(self): out += "\nToilet Requirements :\n {}".format(self.detailtoilet) if(self.needkit_util): out += "\nKit Requirements :\n {}".format(self.detailkit_util) + if(self.needrescue): + out += "\nKit Requirements :\n {}".format(self.detailrescue) if(len(self.needothers.strip()) != 0): out += "\nOther Needs :\n {}".format(self.needothers) return out From ea7e3d0a58e1b7704af40509528c6fbf6ab061e8 Mon Sep 17 00:00:00 2001 From: Gautam Date: Sat, 18 Aug 2018 01:28:29 +0530 Subject: [PATCH 05/56] Update models.py Adding rescue action in summarise --- mainapp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mainapp/models.py b/mainapp/models.py index e6a0138e7..4f05864da 100644 --- a/mainapp/models.py +++ b/mainapp/models.py @@ -104,7 +104,7 @@ def summarise(self): if(self.needkit_util): out += "\nKit Requirements :\n {}".format(self.detailkit_util) if(self.needrescue): - out += "\nKit Requirements :\n {}".format(self.detailrescue) + out += "\nRescue Action :\n {}".format(self.detailrescue) if(len(self.needothers.strip()) != 0): out += "\nOther Needs :\n {}".format(self.needothers) return out From 85d0f003ab5c4b306f1deb12c3a1e761cad60a91 Mon Sep 17 00:00:00 2001 From: Irshad P I Date: Sun, 19 Aug 2018 16:01:04 +0530 Subject: [PATCH 06/56] Implemented placepicker using Modals --- mainapp/templates/mainapp/request_form.html | 272 ++++++++++++++------ 1 file changed, 192 insertions(+), 80 deletions(-) diff --git a/mainapp/templates/mainapp/request_form.html b/mainapp/templates/mainapp/request_form.html index cacb2d400..a424d3e80 100644 --- a/mainapp/templates/mainapp/request_form.html +++ b/mainapp/templates/mainapp/request_form.html @@ -1,75 +1,111 @@ {% extends 'base.html' %} {% load bootstrap3 %} {% load static %} +{% block css %} + +{% endblock %} {% block content %}

Request For Help

സഹായം അഭ്യര്‍ഥിക്കാന്‍

-
- {% csrf_token %} - {% bootstrap_form form %} - - Enter location manually - - - - {% buttons %} - - {% endbuttons %} -
- - - - - - + - - + var showLocationPopup = function(coords) { + $('#place_picker_modal').modal('show'); + } + + function initializeModalMap(lat, lng, zoom) { + var mapOptions = { + zoom: zoom || 14, + center: new google.maps.LatLng(lat, lng), + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + modalMap = new google.maps.Map(document.getElementById('place_modal_map'), + mapOptions); + google.maps.event.addListener(modalMap,'center_changed', function() { + $('#id_latlng').val(modalMap.getCenter().lat() + ',' + modalMap.getCenter().lng()); + $('#manual_coordinates').val(modalMap.getCenter().lat() + ',' + modalMap.getCenter().lng()); + }); + $('
').addClass('centerMarker').appendTo(modalMap.getDiv()) + //do something onclick + .click(function() { + var that = $(this); + if (!that.data('win')) { + that.data('win', new google.maps.InfoWindow({ + content: 'this is the center' + })); + that.data('win').bindTo('position', modalMap, 'center'); + } + that.data('win').open(modalMap); + }); + } + function refreshMap(lat, lng, zoom){ + var mapOptions = { + zoom: zoom, + center: new google.maps.LatLng(lat, lng) + }; + modalMap.setOptions(mapOptions); + } + + function displayAddress(lat, lng) { + console.log(lat, lng); + $.get('https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=' + lat + '&lon=' + lng + '&zoom=18&addressdetails=1') + .done(function(response) { + if($('#id_latlng_display').length === 0){ + var inputElem = $(''); + $('#id_latlng').before(inputElem); + $('#id_latlng').hide(); + inputElem.click(showLocationPopup); + } + $('#id_latlng_display').val(response.display_name); + }) + .fail(function(err){ + console.log(err); + }); + } + + function loadManualGps() { + var str = $('#manual_coordinates').val(); + console.log(str); + var latLng = $('#manual_coordinates').val().split(','); + console.log(latLng, latLng[0], latLng[1]); + if(latLng.length === 2 && !isNaN(latLng[0]) && !isNaN(latLng[1])){ + refreshMap(latLng[0].trim(), latLng[1].trim(), 14); + displayAddress(latLng[0].trim(), latLng[1].trim()); + $('#id_latlng').val(latLng); + $('#id_latlng_accuracy').val('5 Meters'); + } + else{ + alert("Invalid GPS location, enter only comma seperated decimal coordinates!\n\nEg: 10.5276,76.2144"); + } + } + + + + {% endblock %} From ed6ac1d1ee33747fc700ade2e603f97f41ad05fd Mon Sep 17 00:00:00 2001 From: Irshad P I Date: Sun, 19 Aug 2018 20:56:14 +0530 Subject: [PATCH 07/56] Fixed map scroll issue, modal close issue, added single touch scroll, unified indentation --- mainapp/templates/mainapp/request_form.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mainapp/templates/mainapp/request_form.html b/mainapp/templates/mainapp/request_form.html index a424d3e80..dc9b5d903 100644 --- a/mainapp/templates/mainapp/request_form.html +++ b/mainapp/templates/mainapp/request_form.html @@ -20,7 +20,7 @@ cursor:pointer; } #place_modal_map{ - height: 30em; + height: 45vh; } {% endblock %} @@ -64,7 +64,7 @@

Allow Location - നിങ്ങളുടെ സ്ഥല - diff --git a/mainapp/templates/mainapp/missing_and_finding_persons.html b/mainapp/templates/mainapp/missing_and_finding_persons.html index 1f7d2e54f..f5af843da 100644 --- a/mainapp/templates/mainapp/missing_and_finding_persons.html +++ b/mainapp/templates/mainapp/missing_and_finding_persons.html @@ -18,7 +18,7 @@

- + {% bootstrap_icon "user" %} Person Finder
@@ -26,7 +26,7 @@
- + {% bootstrap_icon "user" %} Missing Persons
diff --git a/mainapp/templates/mainapp/missing_persons.html b/mainapp/templates/mainapp/missing_persons.html index 6d9c255a6..ef1b19c40 100644 --- a/mainapp/templates/mainapp/missing_persons.html +++ b/mainapp/templates/mainapp/missing_persons.html @@ -8,7 +8,7 @@
@@ -53,4 +53,4 @@

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/mainapp/templates/mainapp/ngo_form.html b/mainapp/templates/mainapp/ngo_form.html index c7fde105a..50e69349f 100644 --- a/mainapp/templates/mainapp/ngo_form.html +++ b/mainapp/templates/mainapp/ngo_form.html @@ -6,7 +6,7 @@ diff --git a/mainapp/templates/mainapp/ngo_list.html b/mainapp/templates/mainapp/ngo_list.html index 36e186c28..027f1393a 100644 --- a/mainapp/templates/mainapp/ngo_list.html +++ b/mainapp/templates/mainapp/ngo_list.html @@ -72,7 +72,7 @@ diff --git a/mainapp/templates/mainapp/pcamplist.html b/mainapp/templates/mainapp/pcamplist.html index 804093688..b71a78025 100644 --- a/mainapp/templates/mainapp/pcamplist.html +++ b/mainapp/templates/mainapp/pcamplist.html @@ -7,7 +7,7 @@ @@ -54,7 +54,7 @@

{{ message }}

diff --git a/mainapp/templates/mainapp/people.html b/mainapp/templates/mainapp/people.html index 6b22871ff..a72771550 100644 --- a/mainapp/templates/mainapp/people.html +++ b/mainapp/templates/mainapp/people.html @@ -7,7 +7,7 @@ diff --git a/mainapp/templates/mainapp/privaterescuecamp_form.html b/mainapp/templates/mainapp/privaterescuecamp_form.html index 1040cb367..90b6ee13e 100644 --- a/mainapp/templates/mainapp/privaterescuecamp_form.html +++ b/mainapp/templates/mainapp/privaterescuecamp_form.html @@ -8,7 +8,7 @@ diff --git a/mainapp/templates/mainapp/relief_camps.html b/mainapp/templates/mainapp/relief_camps.html index f6e8f1b53..67c67989d 100644 --- a/mainapp/templates/mainapp/relief_camps.html +++ b/mainapp/templates/mainapp/relief_camps.html @@ -32,7 +32,7 @@

- + {% bootstrap_icon "home" %} Relief Camps List
@@ -40,7 +40,7 @@

- + {% bootstrap_icon "list" %} Supply Requirements
diff --git a/mainapp/templates/mainapp/relief_camps_list.html b/mainapp/templates/mainapp/relief_camps_list.html index 1908e068c..e05dd87e2 100644 --- a/mainapp/templates/mainapp/relief_camps_list.html +++ b/mainapp/templates/mainapp/relief_camps_list.html @@ -6,7 +6,7 @@
diff --git a/mainapp/templates/mainapp/volunteer_form.html b/mainapp/templates/mainapp/volunteer_form.html index 7a343813b..6f2ca0707 100644 --- a/mainapp/templates/mainapp/volunteer_form.html +++ b/mainapp/templates/mainapp/volunteer_form.html @@ -6,7 +6,7 @@ diff --git a/mainapp/templates/mainapp/volunteerview.html b/mainapp/templates/mainapp/volunteerview.html index 8f79f4056..4f961d4b4 100644 --- a/mainapp/templates/mainapp/volunteerview.html +++ b/mainapp/templates/mainapp/volunteerview.html @@ -71,7 +71,7 @@ diff --git a/templates/base.html b/templates/base.html index 8325e3c7d..70dd745fa 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,7 +53,7 @@ - +

@@ -78,7 +78,7 @@