diff --git a/Procfile b/Procfile index 411c51ff4..1f3532241 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: ddtrace-run gunicorn floodrelief.wsgi --timeout 600 +web: gunicorn floodrelief.wsgi --timeout 600 worker: python redis_worker.py diff --git a/README.md b/README.md index eb7d754d5..65aacb181 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status - Travis][0]][1] [![Open Source Helpers](https://www.codetriage.com/ieeekeralasection/rescuekerala/badges/users.svg)](https://www.codetriage.com/ieeekeralasection/rescuekerala) -

The Website for co-ordinating the rehabilitation of the people affected in the 2018 Kerala Floods.

+

The Website for co-ordinating the rehabilitation of the people affected in the Kerala Floods.

[![Join Kerala Rescue Slack channel](https://i.imgur.com/V7jxjak.png)](http://bit.ly/Keralarescuechat) @@ -30,38 +30,7 @@ [^top](#table-of-contents) #### Docker -
- -These instructions will get you a copy of the Docker project up and running on your local machine for development and testing purposes. - - -### Using Docker - -- Only pre-requisite is having docker and docker-compose installed -- Execute `sh docker.sh` in this directory (if you do not have permissions on the `docker.sh`, do `chmod +x docker.sh`) -- Server will start running at `localhost:8000` -- `Ctrl+C` to stop - -#### Troubleshooting Docker -* Incompatible docker version - - > ERROR: Version in "./docker-compose.yaml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1. -For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/ - - -**Fix** - -Update your docker toolkit - -* Insufficient permissions -> ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running? -If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. - - -**Fix** - -Run it with sudo - `sudo sh docker.sh` -
+- Check out this [Wiki](https://github.com/IEEEKeralaSection/rescuekerala/wiki/Using-Docker) to see how to run docker for this project. #### [Python 3](https://www.python.org/downloads/) @@ -120,9 +89,13 @@ https://github.com/vigneshhari/keralarescue_test_settings for local testing.
4. Install dependencies. + +``` +pip3 install -r requirements_debug.txt +``` + - pip3 install -r requirements.txt - pip3 install -r requirements_debug.txt +
@@ -218,6 +191,8 @@ You can help us with verifying user submitted request from our [Ushahidi volunte #### Contribution Guidelines Check out this [Wiki](https://github.com/IEEEKeralaSection/rescuekerala/wiki/Contribution-Guidelines) for our contribution guidelines. +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. +
Testing PRs @@ -281,3 +256,6 @@ has the bug number in the branch name.

+ +### Flood Map +You can find the repo for the Flood Map here : https://github.com/aswinmohanme/kerala-flood-map diff --git a/docker-compose.yaml b/docker-compose.yaml index 8ffc2b92f..5b634ba78 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,6 +5,8 @@ services: db: image: postgres restart: always + ports: + - 5432:5432 redis: image: redis diff --git a/floodrelief/settings.py b/floodrelief/settings.py index 4bb1d6582..4695a010b 100644 --- a/floodrelief/settings.py +++ b/floodrelief/settings.py @@ -72,7 +72,6 @@ def get_list(text): 'rest_framework', 'rest_framework.authtoken', 'rest_auth', - 'ddtrace.contrib.django', ] if DEBUG: @@ -94,7 +93,7 @@ def get_list(text): MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] DEBUG_TOOLBAR_PANELS = [ - 'debug_toolbar.panels.timer.TimerDebugPanel', + 'debug_toolbar.panels.timer.TimerPanel', 'pympler.panels.MemoryPanel', 'debug_toolbar.panels.versions.VersionsPanel', 'debug_toolbar.panels.settings.SettingsPanel', @@ -230,7 +229,7 @@ def get_list(text): S3_URL = "https://{}.s3.ap-south-1.amazonaws.com".format(bucket_name,) -if os.environ.get('USE_S3'): +if os.environ.get('USE_S3','').lower() == "true" : AWS_STORAGE_BUCKET_NAME=bucket_name AWS_ACCESS_KEY_ID=os.environ.get("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY=os.environ.get("AWS_SECRET_ACCESS_KEY") diff --git a/mainapp/admin.py b/mainapp/admin.py index d788d1bd6..b82472985 100644 --- a/mainapp/admin.py +++ b/mainapp/admin.py @@ -9,7 +9,8 @@ from mainapp.redis_queue import bulk_csv_upload_queue from mainapp.csvimporter import import_inmate_file from .models import Request, Volunteer, Contributor, DistrictNeed, DistrictCollection, DistrictManager, vol_categories, \ - RescueCamp, Person, NGO, Announcements, DataCollection , PrivateRescueCamp , CollectionCenter, CsvBulkUpload, RequestUpdate + RescueCamp, Person, NGO, Announcements, DataCollection , PrivateRescueCamp , CollectionCenter, CsvBulkUpload, RequestUpdate, \ + Hospital """ Helper function for streaming csv downloads @@ -65,14 +66,17 @@ class RequestAdmin(admin.ModelAdmin): list_filter = ('district', 'status','dateadded') def mark_as_completed(self, request, queryset): + self.message_user(request, "Marked selected requests as completed.") queryset.update(status='sup') return def mark_as_new(self, request, queryset): + self.message_user(request, "Marked selected requests as new.") queryset.update(status='new') return def mark_as_ongoing(self, request, queryset): + self.message_user(request, "Marked selected requests as ongoing.") queryset.update(status='pro') return @@ -214,6 +218,7 @@ class PersonAdmin(admin.ModelAdmin): list_display = ('name', 'camped_at', 'added_at', 'phone', 'age', 'gender', 'camped_at_district', 'camped_at_taluk') ordering = ('-added_at',) list_filter = ('camped_at__district', 'camped_at__taluk') + search_fields = ['camped_at__district', 'camped_at__name', 'name'] def camped_at_taluk(self, instance): return instance.camped_at.taluk @@ -252,7 +257,8 @@ def save_model(self, request, obj, form, change): ) autocomplete_fields = ['camp'] readonly_fields = ['is_completed', 'failure_reason'] - list_display = ['name','camp','is_completed'] + list_display = ['name', 'camp', 'is_completed'] + search_fields = ['camp__name'] admin.site.register(Request, RequestAdmin) admin.site.register(Volunteer, VolunteerAdmin) @@ -267,5 +273,4 @@ def save_model(self, request, obj, form, change): admin.site.register(Announcements, AnnouncementAdmin) admin.site.register(Person, PersonAdmin) admin.site.register(DataCollection, DataCollectionAdmin) -admin.site.register(CsvBulkUpload, CsvBulkUploadAdmin) -admin.site.register(RequestUpdate, RequestUpdateAdmin) +admin.site.register(Hospital) diff --git a/mainapp/csvimporter.py b/mainapp/csvimporter.py index 045936acb..0db0cf614 100644 --- a/mainapp/csvimporter.py +++ b/mainapp/csvimporter.py @@ -18,10 +18,9 @@ def parsedate(str): return datetime.datetime.strptime(str, "%d/%m/%Y" ) return None except : - print(str) return None -def import_inmate_file(csvid): +def import_inmate_file(csvid, is_recovery=False): import django django.setup() @@ -51,6 +50,7 @@ def import_inmate_file(csvid): empty = 0 header = ["name" , "phone" , "address" , "notes" , "district" , "checkin_date" , "checkout_date" , "gender" , "age" ] for i in header: + if(datum.get(i, "") == None):empty+=1;continue if(datum.get(i, "").strip() == ""):empty+=1 if(empty == len(header)): continue @@ -62,12 +62,15 @@ def import_inmate_file(csvid): elif(datum.get("gender", "")[0] == "f" or datum.get("gender", "")[0] == "F"): gender = 1 age = '-1' - if(datum.get("age", "").strip() != ""): - age = datum.get("age", "").strip() - + if(datum.get("age", "") != None): + if(datum.get("age", "").strip() != ""): + age = datum.get("age", "").strip() + district = "" + if(datum.get("district", "") != None): + district = district.lower() Person( - name = datum.get("name", ""), + name = datum.get("name", "")[:50], phone = datum.get("phone", ""), age = int(float(age)), gender = gender, @@ -79,8 +82,12 @@ def import_inmate_file(csvid): checkin_date = parsedate(datum.get("checkin_date", None)), checkout_date = parsedate(datum.get("checkout_date", None)) ).save() - CsvBulkUpload.objects.filter(id = csvid).update(is_completed = True) - CsvBulkUpload.objects.filter(id = csvid).update(failure_reason = '') + + if is_recovery: + csv_name = CsvBulkUpload.objects.get(id=csvid).name + CsvBulkUpload.objects.filter(id = csvid).update(is_completed = True, failure_reason = '', name="rec-"+csv_name[:15]) + else: + CsvBulkUpload.objects.filter(id = csvid).update(is_completed = True, failure_reason = '') except Exception as e: CsvBulkUpload.objects.filter(id = csvid).update(failure_reason=(getattr(e, 'message', repr(e)))) diff --git a/mainapp/management/recover_csv.py b/mainapp/management/recover_csv.py new file mode 100644 index 000000000..bc64af941 --- /dev/null +++ b/mainapp/management/recover_csv.py @@ -0,0 +1,15 @@ +from mainapp.models import CsvBulkUpload +from mainapp.redis_queue import bulk_csv_upload_queue +from mainapp.csvimporter import import_inmate_file + +incompleted_csv_imports = CsvBulkUpload.objects.filter(is_completed=False, failure_reason__icontains="long") + + +for csv in incompleted_csv_imports: + bulk_csv_upload_queue.enqueue( + import_inmate_file, csv.pk, True + ) + + +#For Shell Testing +#exec(open('mainapp/management/recover_csv.py').read()) diff --git a/mainapp/migrations/0092_auto_20180828_1407.py b/mainapp/migrations/0092_auto_20180828_1407.py new file mode 100644 index 000000000..7070a7def --- /dev/null +++ b/mainapp/migrations/0092_auto_20180828_1407.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-08-28 08:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0091_merge_20180825_1236'), + ] + + operations = [ + migrations.AlterField( + model_name='request', + name='is_request_for_others', + field=models.BooleanField(default=False, verbose_name='Requesting for others - മറ്റൊരാൾക്ക് വേണ്ടി അപേക്ഷിക്കുന്നു '), + ), + ] diff --git a/mainapp/migrations/0093_auto_20180902_1802.py b/mainapp/migrations/0093_auto_20180902_1802.py new file mode 100644 index 000000000..3de5cacdf --- /dev/null +++ b/mainapp/migrations/0093_auto_20180902_1802.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-09-02 12:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0092_auto_20180828_1407'), + ] + + operations = [ + migrations.AlterField( + model_name='person', + name='name', + field=models.CharField(max_length=51, verbose_name='Name - പേര്'), + ), + ] diff --git a/mainapp/migrations/0094_auto_20180902_2329.py b/mainapp/migrations/0094_auto_20180902_2329.py new file mode 100644 index 000000000..3cecbb597 --- /dev/null +++ b/mainapp/migrations/0094_auto_20180902_2329.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-09-02 17:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0093_auto_20180902_1802'), + ] + + operations = [ + migrations.AlterField( + model_name='person', + name='phone', + field=models.CharField(blank=True, max_length=14, null=True, verbose_name='Mobile - മൊബൈൽ'), + ), + ] diff --git a/mainapp/migrations/0095_hospital.py b/mainapp/migrations/0095_hospital.py new file mode 100644 index 000000000..e2ae6fc32 --- /dev/null +++ b/mainapp/migrations/0095_hospital.py @@ -0,0 +1,26 @@ +# Generated by Django 2.1.2 on 2019-08-09 07:07 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0094_auto_20180902_2329'), + ] + + operations = [ + migrations.CreateModel( + name='Hospital', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('officer', models.CharField(max_length=100)), + ('designation', models.CharField(max_length=250)), + ('landline', models.CharField(max_length=14, validators=[django.core.validators.RegexValidator(code='invalid_mobile', message='Please Enter 10/11 digit mobile number or landline as 0', regex='^((\\+91|91|0)[\\- ]{0,1})?[456789]\\d{9}$')])), + ('mobile', models.CharField(max_length=14, validators=[django.core.validators.RegexValidator(code='invalid_mobile', message='Please Enter 10/11 digit mobile number or landline as 0', regex='^((\\+91|91|0)[\\- ]{0,1})?[456789]\\d{9}$')])), + ('email', models.EmailField(max_length=254)), + ], + ), + ] diff --git a/mainapp/models.py b/mainapp/models.py index 4fb962691..759e6eedb 100644 --- a/mainapp/models.py +++ b/mainapp/models.py @@ -132,8 +132,7 @@ class Request(models.Model): latlng_accuracy = models.CharField(max_length=100, verbose_name='GPS Accuracy - GPS കൃത്യത ', blank=True) # If it is enabled no need to consider lat and lng is_request_for_others = models.BooleanField( - verbose_name='Requesting for others - മറ്റൊരാൾക്ക് വേണ്ടി അപേക്ഷിക്കുന്നു ', default=False, - help_text="If this is checked, enter other's location from the \'Enter location manually\' button at the bottom") + verbose_name='Requesting for others - മറ്റൊരാൾക്ക് വേണ്ടി അപേക്ഷിക്കുന്നു ', default=False) needwater = models.BooleanField(verbose_name='Water - വെള്ളം') needfood = models.BooleanField(verbose_name='Food - ഭക്ഷണം') @@ -174,6 +173,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 += "\nRescue Action :\n {}".format(self.detailrescue) if(len(self.needothers.strip()) != 0): out += "\nOther Needs :\n {}".format(self.needothers) return out @@ -450,8 +451,8 @@ def __str__(self): class Person(models.Model): - name = models.CharField(max_length=30,blank=False,null=False,verbose_name="Name - പേര്") - phone = models.CharField(max_length=11,null=True,blank=True,verbose_name='Mobile - മൊബൈൽ') + name = models.CharField(max_length=51,blank=False,null=False,verbose_name="Name - പേര്") + phone = models.CharField(max_length=14,null=True,blank=True,verbose_name='Mobile - മൊബൈൽ') age = models.IntegerField(null=True,blank=True,verbose_name="Age - പ്രായം") gender = models.IntegerField( choices = gender, @@ -673,3 +674,16 @@ def full_clean(self, *args, **kwargs): def __str__(self): return self.name + +class Hospital(models.Model): + name = models.CharField(max_length=200) + officer = models.CharField(max_length=100) + designation = models.CharField(max_length=250, verbose_name="Officer name") + phone_number_regex = RegexValidator(regex='^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$', message='Please Enter 10/11 digit mobile number or landline as 0', code='invalid_mobile') + landline = models.CharField(max_length=14, validators=[phone_number_regex]) + mobile = models.CharField(max_length=14, validators=[phone_number_regex]) + email = models.EmailField() + + def __str__(self): + return self.name + ' - ' + self.designation + \ No newline at end of file diff --git a/mainapp/templates/mainapp/camp_details.html b/mainapp/templates/mainapp/camp_details.html index 5038853ad..852875307 100644 --- a/mainapp/templates/mainapp/camp_details.html +++ b/mainapp/templates/mainapp/camp_details.html @@ -4,8 +4,8 @@ {% block content %}

diff --git a/mainapp/templates/mainapp/camp_requirements.html b/mainapp/templates/mainapp/camp_requirements.html index beea0b131..51532059c 100644 --- a/mainapp/templates/mainapp/camp_requirements.html +++ b/mainapp/templates/mainapp/camp_requirements.html @@ -4,8 +4,8 @@ {% block content %}

diff --git a/mainapp/templates/mainapp/camp_requirements_list.html b/mainapp/templates/mainapp/camp_requirements_list.html index 555d4c1c3..a4c8420fa 100644 --- a/mainapp/templates/mainapp/camp_requirements_list.html +++ b/mainapp/templates/mainapp/camp_requirements_list.html @@ -6,7 +6,7 @@ diff --git a/mainapp/templates/mainapp/collectioncenter_form.html b/mainapp/templates/mainapp/collectioncenter_form.html index d743c7f97..455a62fee 100644 --- a/mainapp/templates/mainapp/collectioncenter_form.html +++ b/mainapp/templates/mainapp/collectioncenter_form.html @@ -8,7 +8,7 @@ @@ -35,4 +35,4 @@

Collection Centers

{% block javascript %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/mainapp/templates/mainapp/collectioncenter_list.html b/mainapp/templates/mainapp/collectioncenter_list.html index 80e335453..c317a1afa 100644 --- a/mainapp/templates/mainapp/collectioncenter_list.html +++ b/mainapp/templates/mainapp/collectioncenter_list.html @@ -7,14 +7,14 @@
@@ -213,4 +213,4 @@

Collection Centers >  -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/mainapp/templates/mainapp/collectioncenter_state_select.html b/mainapp/templates/mainapp/collectioncenter_state_select.html index e6a2c48e2..ae124ca9b 100644 --- a/mainapp/templates/mainapp/collectioncenter_state_select.html +++ b/mainapp/templates/mainapp/collectioncenter_state_select.html @@ -8,7 +8,7 @@ @@ -21,14 +21,14 @@

keralarescue

ദുരിതാശ്വാസ പ്രവര്‍ത്തനങ്ങളും രക്ഷാ ദൗത്യങ്ങളും ഏകോപിപ്പിക്കാന്‍
Message from Hon. Chief Minister of Kerala

- + {% bootstrap_icon "home" %} Inside Kerala
- + {% bootstrap_icon "send" %} Outside Kerala
diff --git a/mainapp/templates/mainapp/coordinator_home.html b/mainapp/templates/mainapp/coordinator_home.html index 52514a7f7..915fd6952 100644 --- a/mainapp/templates/mainapp/coordinator_home.html +++ b/mainapp/templates/mainapp/coordinator_home.html @@ -5,8 +5,8 @@

@@ -48,13 +48,13 @@

{{ message }}

{{ item.count }}
- + {% bootstrap_icon "user" %} Register People - + {% bootstrap_icon "pencil" %} Requirements - + {% bootstrap_icon "pencil" %} Camp Details diff --git a/mainapp/templates/mainapp/hospitals.html b/mainapp/templates/mainapp/hospitals.html new file mode 100644 index 000000000..acdce61e1 --- /dev/null +++ b/mainapp/templates/mainapp/hospitals.html @@ -0,0 +1,82 @@ +{% extends 'base.html' %} +{% load bootstrap3 %} + +{% block content %} + + + + +

+ List of Hospitals +

+ +
+ +
+ {% if messages %} + {% for message in messages %} +

{{ message }}

+ {% endfor %} + {% endif %} +
+ +
+ {% bootstrap_form filter.form %} + +
+ + + + + + + + + + + + + {% for item in filter.qs %} + + + + + + + + + {% endfor %} + +
NameOfficerOfficer designationLandlineMobileEmail
{{ item.name }}{{ item.officer }}{{ item.designation }}{{ item.landline }}
{{ item.lsg_name }}
{{ item.mobile }}{{ item.email }}
+ +{% if filter.qs.paginator.num_pages > 1 %} + +{% endif %} + +{% endblock %} diff --git a/mainapp/templates/mainapp/login.html b/mainapp/templates/mainapp/login.html index 9a0422716..50f007e29 100644 --- a/mainapp/templates/mainapp/login.html +++ b/mainapp/templates/mainapp/login.html @@ -28,7 +28,7 @@

Coordinator Login

- Go Back + Go Back

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/request_form.html b/mainapp/templates/mainapp/request_form.html index 365203379..e8a9507b6 100644 --- a/mainapp/templates/mainapp/request_form.html +++ b/mainapp/templates/mainapp/request_form.html @@ -1,6 +1,35 @@ {% extends 'base.html' %} {% load bootstrap3 %} {% load static %} +{% block css %} + +{% endblock %} {% block content %} @@ -12,16 +41,10 @@

Request For Help

-

സഹായം അഭ്യർത്ഥിക്കാൻ

+

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

{% csrf_token %} {% bootstrap_form form %} - - Enter location manually - - {% buttons %}
+ + + + + - - + {% endblock %} diff --git a/mainapp/templates/mainapp/request_list.html b/mainapp/templates/mainapp/request_list.html index 93698c100..0510614ff 100644 --- a/mainapp/templates/mainapp/request_list.html +++ b/mainapp/templates/mainapp/request_list.html @@ -88,9 +88,10 @@

ഇതു വരെ ആവശ്യപ്പെട്ട Request Number - അപേക്ഷ നമ്പര്‍ District - ജില്ല Location - സ്ഥലം - Requestee - അപേക്ഷകന്‍റെ പേര + Requestee - അപേക്ഷകന്‍റെ പേര് Phone - ഫോണ്‍ നമ്പര്‍ Date - തീയതി + Elapsed Time - കഴിഞ്ഞു പോയ സമയം More details - കൂടുതൽ വിശദാംശങ്ങൾ Update @@ -108,7 +109,8 @@

ഇതു വരെ ആവശ്യപ്പെട്ട {{ req.requestee_phone }} {% endif %} {{ req.dateadded }} - More details + {{ req.dateadded|timesince }} + More details Update {% endfor %} 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..b12791c0a 100644 --- a/mainapp/templates/mainapp/volunteerview.html +++ b/mainapp/templates/mainapp/volunteerview.html @@ -52,10 +52,10 @@ } #requests-table td:nth-of-type(1):before { content: "District - ജില്ല"; } #requests-table td:nth-of-type(2):before { content: "Name - പേര"; } - #requests-table td:nth-of-type(3):before { content: "Location - സ്ഥലം"; } - #requests-table td:nth-of-type(4):before { content: "Organization - സംഘടന"; } - #requests-table td:nth-of-type(5):before { content: "Phone - ഫോണ്‍ നമ്പര്‍"; } - #requests-table td:nth-of-type(6):before { content: "Area - സന്നദ്ധസേവനം"; } + #requests-table td:nth-of-type(3):before { content: "Area - സന്നദ്ധസേവനം"; } + #requests-table td:nth-of-type(4):before { content: "Location - സ്ഥലം"; } + #requests-table td:nth-of-type(5):before { content: "Organization - സംഘടന"; } + #requests-table td:nth-of-type(6):before { content: "Phone - ഫോണ്‍ നമ്പര്‍"; } } @media only screen and (max-width: 420px) { #requests-table td { @@ -71,7 +71,7 @@ @@ -88,11 +88,11 @@

View Volunteers

District - ജില്ല Name - പേര + Area - സന്നദ്ധസേവനം {% if user.is_authenticated %} Location - സ്ഥലം Organization - സംഘടന {% endif %} - Area - സന്നദ്ധസേവനം @@ -100,11 +100,11 @@

View Volunteers

{{ req.get_district_display }} {{ req.name }} + {{ req.get_area_display }} {% if user.is_authenticated %} {{ req.address }} {{ req.organisation }} {% endif %} - {{ req.get_area_display }} {% endfor %} diff --git a/mainapp/urls.py b/mainapp/urls.py index 42247f077..fcd2a69fa 100644 --- a/mainapp/urls.py +++ b/mainapp/urls.py @@ -36,7 +36,7 @@ path('pcampdet/' , views.pcampdetails , name="privatecampdetails"), path('privatecc/' , views.privatecc , name="privatedetails"), # path('data/' , views.data , name="data"), - path('map/' , views.mapview , name="mapview"), + path('map/' , views.mapview , name="map"), path('dmodash/' , views.dmodash , name="DMODash"), path('dmoinfo/' , views.dmoinfo , name="DMOInfo" ), path('dmocsv/' , views.dmocsv , name="DMOCSV" ), @@ -62,4 +62,5 @@ path('consent_success/', views.ConsentSuccess.as_view(), name='consent_success'), url(r'c/(?P\d+)/(?P\d+)/$', views.VolunteerConsent.as_view(), name='volunteer_consent'), url('missing_and_finding_persons/', views.ReportFindPerson.as_view(), name='report_find_person'), + url('hospitals/', views.HospitalView.as_view(), name='hospitals') ] diff --git a/mainapp/views.py b/mainapp/views.py index 0b76491b0..227ef4187 100644 --- a/mainapp/views.py +++ b/mainapp/views.py @@ -19,6 +19,7 @@ from django.contrib import admin from django.shortcuts import redirect, get_object_or_404 from django.db.models import Count, QuerySet +from django.db.models import Case, When, Sum, F from django.core.cache import cache from django.conf import settings from django.contrib.auth.decorators import login_required @@ -30,7 +31,7 @@ import csv from dateutil import parser import calendar -from mainapp.models import CollectionCenter +from mainapp.models import CollectionCenter, Hospital from collections import OrderedDict @@ -481,30 +482,27 @@ def dmodist(request): return render(request , "dmodist.html" , {"camps" : d } ) def dmotal(request): - if(request.GET.get("district",-1) == -1):return render(request , "dmotal.html" ) - dist = request.GET.get("district",-1) - if(dist == "all"): data = RescueCamp.objects.filter(status='active').values('taluk').distinct() - else:data = RescueCamp.objects.filter(district = dist , status='active').values('taluk').distinct() - distmapper = {} - for i in districts: - distmapper[i[0]] = i[1] - d = [] - for taluk in data : - camps = 0 ;total_people = 0 ;total_male = 0 ; total_female = 0 ; total_infant = 0 ; total_medical = 0;district = "" - if(dist == "all"):RCdata = RescueCamp.objects.all().filter( taluk = taluk["taluk"] , status="active") - else:RCdata = RescueCamp.objects.all().filter( district = dist , taluk = taluk["taluk"] , status="active") - for i in RCdata: - camps+=1 - district = i.district - total_people += ifnonezero(i.total_people) - total_male += ifnonezero(i.total_males) - total_female += ifnonezero(i.total_females) - total_infant += ifnonezero(i.total_infants) - if(i.medical_req.strip() != ""):total_medical+=1 - - d.append( { "district" : distmapper[district] , "taluk" : taluk["taluk"] ,"total_camp" : camps , "total_people" : total_people , "total_male" : total_male , "total_female" : total_female , "total_infant" : total_infant , "total_medical" : total_medical } ) - return render(request , "dmotal.html" , {"camps" : d } ) - + dist = request.GET.get("district", -1) + if dist == -1: + return render(request, "dmotal.html") + camp_qs = RescueCamp.objects.filter(status='active') + if dist != "all": + data = camp_qs.filter(district=dist) + distmapper = dict(districts) + camps_by_taluk = camp_qs.values('taluk').annotate( + total_people=Sum('total_people'), total_male=Sum('total_males'), + total_female=Sum('total_females'), total_infant=Sum('total_infants'), + total_medical=Count(Case( + # Empty strings with or w/o spaces. + When(medical_req__regex=r'^[ ]*$', then=1), + # Null strings. + When(medical_req__isnull=True, then=1))), + total_camp=Count('id'), district=Value(distmapper[dist], CharField()) + ).annotate( + # We wanted non-empty, non-null strings but counted the opposite. Reverse now. + total_medical=F('total_camp')-F('total_medical') + ) + return render(request, "dmotal.html", {"camps": list(camps_by_taluk)}) def dmocsv(request): if("district" not in request.GET.keys()):return HttpResponseRedirect("/") @@ -522,7 +520,6 @@ def dmocsv(request): ] writer.writerow(row) - return response def ifnonezero(val): @@ -530,21 +527,29 @@ def ifnonezero(val): return val def dmoinfo(request): - data = [] - for i in districts: - req = 0 ; reqo = 0 ; reqd = 0 ; con = 0 ; cons = 0 ; vol = 0 - reqquery = Request.objects.all().filter(district = i[0]) - req = reqquery.count() - reqo = reqquery.filter( status = "pro" ).count() - reqd = reqquery.filter(status = "sup").count() - contquery = Contributor.objects.all().filter(district = i[0]) - con = contquery.count() - cons =contquery.filter(status = "ful").count() - vol = Volunteer.objects.all().filter(district = i[0]).count() - - data.append({ "district" : i[1], "req" : req , "reqo" : reqo , "reqd" : reqd , "con" : con , "cons" : cons , "vol" : vol}) - return render(request ,"dmoinfo.html",{"data" : data} ) + for dist_code, dist_name in districts: + req_summary = Request.objects.filter(district=dist_code).aggregate( + supplied=Count(Case(When(status="sup", then=1))), + progress=Count(Case(When(status="pro", then=1))), + total=Count('id'), + ) + con_summary = Contributor.objects.filter(district=dist_code).aggregate( + fullfilled=Count(Case(When(status="ful", then=1))), + total=Count('id'), + ) + vol = Volunteer.objects.filter(district=dist_code).count() + data.append({ + "district": dist_name, + "req": req_summary['total'], + "reqo": req_summary['progress'], + "reqd": req_summary['supplied'], + "con": con_summary['total'], + "cons": con_summary['fullfilled'], + "vol": vol + }) + + return render(request ,"dmoinfo.html",{"data" : data}) def error(request): error_text = request.GET.get('error_text') @@ -834,6 +839,7 @@ def camp_requirements_list(request): data = paginator.get_page(page) return render(request, "mainapp/camp_requirements_list.html", {'filter': filter , 'data' : data}) + class RequestUpdateView(CreateView): model = RequestUpdate template_name='mainapp/request_update.html' @@ -899,6 +905,37 @@ def __init__(self, *args, **kwargs): if self.data == {}: self.queryset = self.queryset.none() +class HospitalViewFitler(django_filters.FilterSet): + class Meta: + model = Hospital + fields = OrderedDict() + fields['name'] = ['icontains'] + fields['designation'] = ['icontains'] + + + # def __init__(self, *args, **kwargs): + # super(HospitalViewFitler, self).__init__(*args, **kwargs) + # if self.data == {}: + # self.queryset = self.queryset.none() + + +class HospitalForm(forms.ModelForm): + class Meta: + model = Hospital + fields = ['name', 'designation'] + +class HospitalView(ListView): + model = Hospital + success_url = '/hospitals/' + paginate_by = 50 + template_name = 'mainapp/hospitals.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['filter'] = HospitalViewFitler( + self.request.GET, queryset=Hospital.objects.all() + ) + return context class CollectionCenterListView(ListView): model = CollectionCenter diff --git a/requirements.txt b/requirements.txt index a5843f030..da68b261d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ dj-database-url==0.5.0 -Django==2.1 +django==2.1.2 django-bootstrap3==10.0.1 django-environ==0.4.5 django-filter==2.0.0 diff --git a/requirements_debug.txt b/requirements_debug.txt index ae7dc1058..f87022541 100644 --- a/requirements_debug.txt +++ b/requirements_debug.txt @@ -1,2 +1,2 @@ -django_debug_toolbar +django_debug_toolbar==1.11 pympler diff --git a/static/css/style.css b/static/css/style.css index 0d7b20c80..fceed6a5d 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -53,26 +53,26 @@ a.home-button:hover{ background: #333333; color:#FFFFFF; } - a.home-button .glyphicon{ - font-size: 5rem; - display: block; - margin-bottom: 10px; - } - a.home-button .text{ - font-size: 2rem; - font-weight: 500; - text-transform: uppercase; - display:inline-block; - } - a.home-button .ml{ - margin-top:7px; - padding-top:7px; - border-top: 1px dotted #555555; - font-size: 1.4rem; - font-weight: bold; - text-transform: uppercase; - display:inline-block; - } +a.home-button .glyphicon{ + font-size: 5rem; + display: block; + margin-bottom: 10px; +} +a.home-button .text{ + font-size: 1.5rem; + font-weight: 500; + text-transform: uppercase; + display:inline-block; +} +a.home-button .ml{ + margin-top:7px; + padding-top:7px; + border-top: 1px dotted #555555; + font-size: 1.4rem; + font-weight: bold; + text-transform: uppercase; + display:inline-block; +} p.home-info{ font-size: 1.6rem; font-weight: 500; @@ -286,8 +286,8 @@ table thead tr th { .card.priority-high{border-color:#ef7831;} .card.priority-high .card-priority{background-color:#ef7831;} -.card.priority-medium{border-color:#7ab754;} - .card.priority-medium .card-priority{background-color:#7ab754;} +.card.priority-medium{border-color:#ffc107;} + .card.priority-medium .card-priority{background-color:#ffc107;} .card.priority-low{border-color:#286090;} .card.priority-low .card-priority{background-color:#286090;} diff --git a/templates/announcements.html b/templates/announcements.html index cee1c414c..7e64588bd 100644 --- a/templates/announcements.html +++ b/templates/announcements.html @@ -15,7 +15,7 @@ {% for req in pinned_data %}
- {{ req.description | safe | linebreaks }}
+ {{ req.description | safe | urlize | linebreaks }}
Very Important
{% bootstrap_icon "time" %} {{ req.dateadded }} @@ -23,13 +23,14 @@ {% endfor %}
- Priority : High Medium Low + Priority : High Medium Low
{% for req in data %}
+ {% bootstrap_icon "time" %} {{ req.dateadded }} {{ req.get_priority_display.upper }} priority

- {{ req.description | safe }}
+ {{ req.description | safe | urlize }}
{% if req.image %} {% bootstrap_icon "eye-open" %} View Image @@ -39,7 +40,6 @@ class="btn btn-default card-link">{% bootstrap_icon "download" %} Download {% endif %}
- {% bootstrap_icon "time" %} {{ req.dateadded }}
{% endfor %}
diff --git a/templates/base.html b/templates/base.html index 8325e3c7d..f15477ef6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -53,7 +53,7 @@ - +
@@ -78,15 +78,19 @@