Kaynağa Gözat

find places

tum 4 yıl önce
ebeveyn
işleme
ad01fc0d19
100 değiştirilmiş dosya ile 21728 ekleme ve 7 silme
  1. BIN
      .DS_Store
  2. 1 2
      Dockerfile
  3. BIN
      app/.DS_Store
  4. BIN
      app/backend/.DS_Store
  5. 0 0
      app/backend/__init__.py
  6. 0 0
      app/backend/__pycache__/__init__.cpython-39.pyc
  7. BIN
      app/backend/__pycache__/admin.cpython-39.pyc
  8. 0 0
      app/backend/__pycache__/apps.cpython-39.pyc
  9. BIN
      app/backend/__pycache__/models.cpython-39.pyc
  10. BIN
      app/backend/__pycache__/urls.cpython-39.pyc
  11. BIN
      app/backend/__pycache__/views.cpython-39.pyc
  12. 35 2
      backend/admin.py
  13. 0 0
      app/backend/apps.py
  14. 0 0
      app/backend/migrations/0001_initial.py
  15. 0 0
      app/backend/migrations/0002_hospital_geolocation.py
  16. 0 0
      app/backend/migrations/0003_alter_hospital_address.py
  17. 0 0
      app/backend/migrations/0004_alter_hospital_location.py
  18. 0 0
      app/backend/migrations/0005_hospital_address_text.py
  19. 0 0
      app/backend/migrations/0006_bed_patient.py
  20. 0 0
      app/backend/migrations/0007_auto_20210718_0249.py
  21. 0 0
      app/backend/migrations/0008_auto_20210718_0659.py
  22. 0 0
      app/backend/migrations/0009_auto_20210718_0702.py
  23. 0 0
      app/backend/migrations/0010_auto_20210718_0713.py
  24. 0 0
      app/backend/migrations/0011_auto_20210718_0722.py
  25. 0 0
      app/backend/migrations/0012_patient_comment.py
  26. 0 0
      app/backend/migrations/0013_patientlog.py
  27. 0 0
      app/backend/migrations/0014_alter_patientlog_bed.py
  28. 0 0
      app/backend/migrations/0015_alter_patientlog_bed.py
  29. 0 0
      app/backend/migrations/0016_auto_20210718_1031.py
  30. 0 0
      app/backend/migrations/0017_ambulance_driver.py
  31. 0 0
      app/backend/migrations/0018_ambulance_color.py
  32. 0 0
      app/backend/migrations/0019_ambulanceticket.py
  33. 0 0
      app/backend/migrations/0020_driver_status.py
  34. 0 0
      app/backend/migrations/0021_auto_20210719_0014.py
  35. 0 0
      app/backend/migrations/0022_auto_20210719_0024.py
  36. 0 0
      app/backend/migrations/0023_place.py
  37. 22 0
      app/backend/migrations/0024_points.py
  38. 28 0
      app/backend/migrations/0025_auto_20210721_1145.py
  39. 23 0
      app/backend/migrations/0026_auto_20210721_1218.py
  40. 23 0
      app/backend/migrations/0027_auto_20210721_1251.py
  41. 18 0
      app/backend/migrations/0028_place_title.py
  42. 20 0
      app/backend/migrations/0029_importfile.py
  43. 0 0
      app/backend/migrations/__init__.py
  44. 0 0
      app/backend/migrations/__pycache__/0001_initial.cpython-39.pyc
  45. 0 0
      app/backend/migrations/__pycache__/0002_hospital_geolocation.cpython-39.pyc
  46. 0 0
      app/backend/migrations/__pycache__/0003_alter_hospital_address.cpython-39.pyc
  47. 0 0
      app/backend/migrations/__pycache__/0004_alter_hospital_location.cpython-39.pyc
  48. 0 0
      app/backend/migrations/__pycache__/0005_hospital_address_text.cpython-39.pyc
  49. 0 0
      app/backend/migrations/__pycache__/0006_bed_patient.cpython-39.pyc
  50. 0 0
      app/backend/migrations/__pycache__/0007_auto_20210718_0246.cpython-39.pyc
  51. 0 0
      app/backend/migrations/__pycache__/0007_auto_20210718_0249.cpython-39.pyc
  52. 0 0
      app/backend/migrations/__pycache__/0008_alter_patient_prefix.cpython-39.pyc
  53. 0 0
      app/backend/migrations/__pycache__/0008_auto_20210718_0659.cpython-39.pyc
  54. 0 0
      app/backend/migrations/__pycache__/0009_auto_20210718_0702.cpython-39.pyc
  55. 0 0
      app/backend/migrations/__pycache__/0010_auto_20210718_0711.cpython-39.pyc
  56. 0 0
      app/backend/migrations/__pycache__/0010_auto_20210718_0713.cpython-39.pyc
  57. 0 0
      app/backend/migrations/__pycache__/0011_auto_20210718_0722.cpython-39.pyc
  58. 0 0
      app/backend/migrations/__pycache__/0012_patient_comment.cpython-39.pyc
  59. 0 0
      app/backend/migrations/__pycache__/0013_patientlog.cpython-39.pyc
  60. 0 0
      app/backend/migrations/__pycache__/0014_alter_patientlog_bed.cpython-39.pyc
  61. 0 0
      app/backend/migrations/__pycache__/0015_alter_patientlog_bed.cpython-39.pyc
  62. 0 0
      app/backend/migrations/__pycache__/0016_auto_20210718_1031.cpython-39.pyc
  63. 0 0
      app/backend/migrations/__pycache__/0017_ambulance_driver.cpython-39.pyc
  64. 0 0
      app/backend/migrations/__pycache__/0018_ambulance_color.cpython-39.pyc
  65. 0 0
      app/backend/migrations/__pycache__/0019_ambulanceticket.cpython-39.pyc
  66. 0 0
      app/backend/migrations/__pycache__/0020_driver_status.cpython-39.pyc
  67. 0 0
      app/backend/migrations/__pycache__/0021_auto_20210719_0014.cpython-39.pyc
  68. 0 0
      app/backend/migrations/__pycache__/0022_auto_20210719_0024.cpython-39.pyc
  69. 0 0
      app/backend/migrations/__pycache__/0023_place.cpython-39.pyc
  70. BIN
      app/backend/migrations/__pycache__/0024_points.cpython-39.pyc
  71. BIN
      app/backend/migrations/__pycache__/0025_auto_20210721_1145.cpython-39.pyc
  72. BIN
      app/backend/migrations/__pycache__/0026_auto_20210721_1218.cpython-39.pyc
  73. BIN
      app/backend/migrations/__pycache__/0027_auto_20210721_1251.cpython-39.pyc
  74. BIN
      app/backend/migrations/__pycache__/0028_place_title.cpython-39.pyc
  75. BIN
      app/backend/migrations/__pycache__/0029_importfile.cpython-39.pyc
  76. 0 0
      app/backend/migrations/__pycache__/__init__.cpython-39.pyc
  77. 96 0
      backend/models.py
  78. 7 0
      app/backend/templates/backend/import_file.html
  79. 8 0
      app/backend/templates/backend/index.html
  80. 0 0
      app/backend/tests.py
  81. 1 0
      backend/urls.py
  82. 11 0
      app/backend/views.py
  83. 0 0
      app/manage.py
  84. 0 0
      app/media/uploads/2021/07/18/67224.jpg
  85. 10715 0
      app/media/uploads/2021/07/22/citizeninfo_health_20200314.csv
  86. 10715 0
      app/media/uploads/2021/07/22/citizeninfo_health_20200314_W9jk8Vu.csv
  87. 1 0
      requirements.txt
  88. 0 0
      app/shaqfindbed/__init__.py
  89. 0 0
      app/shaqfindbed/__pycache__/__init__.cpython-39.pyc
  90. BIN
      app/shaqfindbed/__pycache__/settings.cpython-39.pyc
  91. BIN
      shaqfindbed/__pycache__/urls.cpython-39.pyc
  92. 0 0
      app/shaqfindbed/__pycache__/wsgi.cpython-39.pyc
  93. 0 0
      app/shaqfindbed/asgi.py
  94. 3 2
      shaqfindbed/settings.py
  95. 1 1
      shaqfindbed/urls.py
  96. 0 0
      app/shaqfindbed/wsgi.py
  97. BIN
      app/static/.DS_Store
  98. BIN
      app/static/admin/.DS_Store
  99. 0 0
      app/static/admin/css/autocomplete.css
  100. 0 0
      staticfile/admin/css/base.css

BIN
.DS_Store


+ 1 - 2
Dockerfile

@@ -1,11 +1,10 @@
1 1
 # syntax=docker/dockerfile:1
2 2
 FROM python:3
3 3
 ENV PYTHONUNBUFFERED=1
4
+ADD ./app /code
4 5
 WORKDIR /code
5
-COPY requirements.txt /code/
6 6
 RUN apt-get update && apt-get install -y \
7 7
         gettext \
8 8
         xfonts-thai \
9 9
         gdal-bin libgdal-dev python3-gdal binutils libproj-dev
10 10
 RUN pip install -r requirements.txt
11
-COPY . /code/

BIN
app/.DS_Store


BIN
app/backend/.DS_Store


shaqfindbed/__init__.py → app/backend/__init__.py


backend/__pycache__/__init__.cpython-39.pyc → app/backend/__pycache__/__init__.cpython-39.pyc


BIN
app/backend/__pycache__/admin.cpython-39.pyc


backend/__pycache__/apps.cpython-39.pyc → app/backend/__pycache__/apps.cpython-39.pyc


BIN
app/backend/__pycache__/models.cpython-39.pyc


BIN
app/backend/__pycache__/urls.cpython-39.pyc


BIN
app/backend/__pycache__/views.cpython-39.pyc


+ 35 - 2
backend/admin.py

@@ -1,18 +1,46 @@
1 1
 from django.contrib import admin
2 2
 from django.contrib.gis.admin import OSMGeoAdmin
3
-from .models import Hospital, Patient, Bed, PatientLog, Driver, Ambulance, AmbulanceTicket, Place
3
+from .models import Hospital, Patient, Bed, PatientLog, Driver, Ambulance, AmbulanceTicket, Place, Points, ImportFile
4 4
 from django_google_maps import widgets as map_widgets
5 5
 from django_google_maps import fields as map_fields
6 6
 from django_json_widget.widgets import JSONEditorWidget
7 7
 from django.db import models
8
-
8
+from django.utils.html import format_html
9
+from django.conf import settings
9 10
 
10 11
 #@admin.register(Bed)
11 12
 
13
+@admin.register(ImportFile)
14
+class ImportFileAdmin(admin.ModelAdmin):
15
+    pass
16
+
12 17
 @admin.register(AmbulanceTicket)
13 18
 class AmbulanceTicketAdmin(admin.ModelAdmin):
14 19
     list_display = ('driver', 'ambulance', 'checkin_at', 'checkout_at', 'status')
15 20
 
21
+@admin.register(Points)
22
+class PointAdmin(admin.ModelAdmin):
23
+    readonly_fields = ('distance', 'duration', 'get_map')
24
+    formfield_overrides = {
25
+        map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
26
+        models.JSONField: {'widget': JSONEditorWidget},
27
+    }
28
+
29
+    def get_map(self, obj):
30
+         return format_html( f'''
31
+<br>
32
+<div>
33
+<iframe
34
+  width="100%"
35
+  height="450"
36
+  style="border:0"
37
+  loading="lazy"
38
+  allowfullscreen
39
+  src="https://www.google.com/maps/embed/v1/directions?key={settings.GOOGLE_MAPS_API_KEY}&origin={obj.geolocation.lat},{obj.geolocation.lon}&destination={obj.dest.geolocation.lat},{obj.dest.geolocation.lon}"></iframe></div>''')
40
+
41
+    fields = ('dest', 'address', 'geolocation', 'distance', 'duration', 'directions','get_map' )
42
+    #pass
43
+
16 44
 @admin.register(Place)
17 45
 class PlaceAdmin(admin.ModelAdmin):
18 46
     formfield_overrides = {
@@ -51,7 +79,12 @@ class HospitalAdmin(OSMGeoAdmin):
51 79
 
52 80
 @admin.register(Patient)
53 81
 class PatientAdmin(admin.ModelAdmin):
82
+    readonly_fields = ('nearby_places', )
54 83
     formfield_overrides = {
55 84
         map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
56 85
     }
57 86
     inlines = [PatientLogAdmin,]
87
+
88
+    def nearby_places(self, obj):
89
+        r = obj.nearby()
90
+        return format_html(r)

backend/apps.py → app/backend/apps.py


backend/migrations/0001_initial.py → app/backend/migrations/0001_initial.py


backend/migrations/0002_hospital_geolocation.py → app/backend/migrations/0002_hospital_geolocation.py


backend/migrations/0003_alter_hospital_address.py → app/backend/migrations/0003_alter_hospital_address.py


backend/migrations/0004_alter_hospital_location.py → app/backend/migrations/0004_alter_hospital_location.py


backend/migrations/0005_hospital_address_text.py → app/backend/migrations/0005_hospital_address_text.py


backend/migrations/0006_bed_patient.py → app/backend/migrations/0006_bed_patient.py


backend/migrations/0007_auto_20210718_0249.py → app/backend/migrations/0007_auto_20210718_0249.py


backend/migrations/0008_auto_20210718_0659.py → app/backend/migrations/0008_auto_20210718_0659.py


backend/migrations/0009_auto_20210718_0702.py → app/backend/migrations/0009_auto_20210718_0702.py


backend/migrations/0010_auto_20210718_0713.py → app/backend/migrations/0010_auto_20210718_0713.py


backend/migrations/0011_auto_20210718_0722.py → app/backend/migrations/0011_auto_20210718_0722.py


backend/migrations/0012_patient_comment.py → app/backend/migrations/0012_patient_comment.py


backend/migrations/0013_patientlog.py → app/backend/migrations/0013_patientlog.py


backend/migrations/0014_alter_patientlog_bed.py → app/backend/migrations/0014_alter_patientlog_bed.py


backend/migrations/0015_alter_patientlog_bed.py → app/backend/migrations/0015_alter_patientlog_bed.py


backend/migrations/0016_auto_20210718_1031.py → app/backend/migrations/0016_auto_20210718_1031.py


backend/migrations/0017_ambulance_driver.py → app/backend/migrations/0017_ambulance_driver.py


backend/migrations/0018_ambulance_color.py → app/backend/migrations/0018_ambulance_color.py


backend/migrations/0019_ambulanceticket.py → app/backend/migrations/0019_ambulanceticket.py


backend/migrations/0020_driver_status.py → app/backend/migrations/0020_driver_status.py


backend/migrations/0021_auto_20210719_0014.py → app/backend/migrations/0021_auto_20210719_0014.py


backend/migrations/0022_auto_20210719_0024.py → app/backend/migrations/0022_auto_20210719_0024.py


backend/migrations/0023_place.py → app/backend/migrations/0023_place.py


+ 22 - 0
app/backend/migrations/0024_points.py

@@ -0,0 +1,22 @@
1
+# Generated by Django 3.2.5 on 2021-07-19 08:11
2
+
3
+from django.db import migrations, models
4
+import django.db.models.deletion
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('backend', '0023_place'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.CreateModel(
15
+            name='Points',
16
+            fields=[
17
+                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18
+                ('dest', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dest', to='backend.place')),
19
+                ('src', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='src', to='backend.place')),
20
+            ],
21
+        ),
22
+    ]

+ 28 - 0
app/backend/migrations/0025_auto_20210721_1145.py

@@ -0,0 +1,28 @@
1
+# Generated by Django 3.2.5 on 2021-07-21 04:45
2
+
3
+from django.db import migrations
4
+import django_google_maps.fields
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('backend', '0024_points'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.RemoveField(
15
+            model_name='points',
16
+            name='src',
17
+        ),
18
+        migrations.AddField(
19
+            model_name='points',
20
+            name='address',
21
+            field=django_google_maps.fields.AddressField(max_length=200, null=True),
22
+        ),
23
+        migrations.AddField(
24
+            model_name='points',
25
+            name='geolocation',
26
+            field=django_google_maps.fields.GeoLocationField(max_length=100, null=True),
27
+        ),
28
+    ]

+ 23 - 0
app/backend/migrations/0026_auto_20210721_1218.py

@@ -0,0 +1,23 @@
1
+# Generated by Django 3.2.5 on 2021-07-21 05:18
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('backend', '0025_auto_20210721_1145'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='points',
15
+            name='distance',
16
+            field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True),
17
+        ),
18
+        migrations.AddField(
19
+            model_name='points',
20
+            name='duration',
21
+            field=models.CharField(blank=True, max_length=200, null=True),
22
+        ),
23
+    ]

+ 23 - 0
app/backend/migrations/0027_auto_20210721_1251.py

@@ -0,0 +1,23 @@
1
+# Generated by Django 3.2.5 on 2021-07-21 05:51
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('backend', '0026_auto_20210721_1218'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='points',
15
+            name='directions',
16
+            field=models.JSONField(blank=True, null=True),
17
+        ),
18
+        migrations.AlterField(
19
+            model_name='points',
20
+            name='distance',
21
+            field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='Distance (km)'),
22
+        ),
23
+    ]

+ 18 - 0
app/backend/migrations/0028_place_title.py

@@ -0,0 +1,18 @@
1
+# Generated by Django 3.2.5 on 2021-07-21 10:11
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('backend', '0027_auto_20210721_1251'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='place',
15
+            name='title',
16
+            field=models.CharField(blank=True, max_length=200, null=True),
17
+        ),
18
+    ]

+ 20 - 0
app/backend/migrations/0029_importfile.py

@@ -0,0 +1,20 @@
1
+# Generated by Django 3.2.5 on 2021-07-22 08:04
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('backend', '0028_place_title'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.CreateModel(
14
+            name='ImportFile',
15
+            fields=[
16
+                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17
+                ('hospital_file', models.FileField(blank=True, upload_to='uploads/%Y/%m/%d/', verbose_name='Hospital (csv)')),
18
+            ],
19
+        ),
20
+    ]

backend/migrations/__init__.py → app/backend/migrations/__init__.py


backend/migrations/__pycache__/0001_initial.cpython-39.pyc → app/backend/migrations/__pycache__/0001_initial.cpython-39.pyc


backend/migrations/__pycache__/0002_hospital_geolocation.cpython-39.pyc → app/backend/migrations/__pycache__/0002_hospital_geolocation.cpython-39.pyc


backend/migrations/__pycache__/0003_alter_hospital_address.cpython-39.pyc → app/backend/migrations/__pycache__/0003_alter_hospital_address.cpython-39.pyc


backend/migrations/__pycache__/0004_alter_hospital_location.cpython-39.pyc → app/backend/migrations/__pycache__/0004_alter_hospital_location.cpython-39.pyc


backend/migrations/__pycache__/0005_hospital_address_text.cpython-39.pyc → app/backend/migrations/__pycache__/0005_hospital_address_text.cpython-39.pyc


backend/migrations/__pycache__/0006_bed_patient.cpython-39.pyc → app/backend/migrations/__pycache__/0006_bed_patient.cpython-39.pyc


backend/migrations/__pycache__/0007_auto_20210718_0246.cpython-39.pyc → app/backend/migrations/__pycache__/0007_auto_20210718_0246.cpython-39.pyc


backend/migrations/__pycache__/0007_auto_20210718_0249.cpython-39.pyc → app/backend/migrations/__pycache__/0007_auto_20210718_0249.cpython-39.pyc


backend/migrations/__pycache__/0008_alter_patient_prefix.cpython-39.pyc → app/backend/migrations/__pycache__/0008_alter_patient_prefix.cpython-39.pyc


backend/migrations/__pycache__/0008_auto_20210718_0659.cpython-39.pyc → app/backend/migrations/__pycache__/0008_auto_20210718_0659.cpython-39.pyc


backend/migrations/__pycache__/0009_auto_20210718_0702.cpython-39.pyc → app/backend/migrations/__pycache__/0009_auto_20210718_0702.cpython-39.pyc


backend/migrations/__pycache__/0010_auto_20210718_0711.cpython-39.pyc → app/backend/migrations/__pycache__/0010_auto_20210718_0711.cpython-39.pyc


backend/migrations/__pycache__/0010_auto_20210718_0713.cpython-39.pyc → app/backend/migrations/__pycache__/0010_auto_20210718_0713.cpython-39.pyc


backend/migrations/__pycache__/0011_auto_20210718_0722.cpython-39.pyc → app/backend/migrations/__pycache__/0011_auto_20210718_0722.cpython-39.pyc


backend/migrations/__pycache__/0012_patient_comment.cpython-39.pyc → app/backend/migrations/__pycache__/0012_patient_comment.cpython-39.pyc


backend/migrations/__pycache__/0013_patientlog.cpython-39.pyc → app/backend/migrations/__pycache__/0013_patientlog.cpython-39.pyc


backend/migrations/__pycache__/0014_alter_patientlog_bed.cpython-39.pyc → app/backend/migrations/__pycache__/0014_alter_patientlog_bed.cpython-39.pyc


backend/migrations/__pycache__/0015_alter_patientlog_bed.cpython-39.pyc → app/backend/migrations/__pycache__/0015_alter_patientlog_bed.cpython-39.pyc


backend/migrations/__pycache__/0016_auto_20210718_1031.cpython-39.pyc → app/backend/migrations/__pycache__/0016_auto_20210718_1031.cpython-39.pyc


backend/migrations/__pycache__/0017_ambulance_driver.cpython-39.pyc → app/backend/migrations/__pycache__/0017_ambulance_driver.cpython-39.pyc


backend/migrations/__pycache__/0018_ambulance_color.cpython-39.pyc → app/backend/migrations/__pycache__/0018_ambulance_color.cpython-39.pyc


backend/migrations/__pycache__/0019_ambulanceticket.cpython-39.pyc → app/backend/migrations/__pycache__/0019_ambulanceticket.cpython-39.pyc


backend/migrations/__pycache__/0020_driver_status.cpython-39.pyc → app/backend/migrations/__pycache__/0020_driver_status.cpython-39.pyc


backend/migrations/__pycache__/0021_auto_20210719_0014.cpython-39.pyc → app/backend/migrations/__pycache__/0021_auto_20210719_0014.cpython-39.pyc


backend/migrations/__pycache__/0022_auto_20210719_0024.cpython-39.pyc → app/backend/migrations/__pycache__/0022_auto_20210719_0024.cpython-39.pyc


backend/migrations/__pycache__/0023_place.cpython-39.pyc → app/backend/migrations/__pycache__/0023_place.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0024_points.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0025_auto_20210721_1145.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0026_auto_20210721_1218.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0027_auto_20210721_1251.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0028_place_title.cpython-39.pyc


BIN
app/backend/migrations/__pycache__/0029_importfile.cpython-39.pyc


backend/migrations/__pycache__/__init__.cpython-39.pyc → app/backend/migrations/__pycache__/__init__.cpython-39.pyc


+ 96 - 0
backend/models.py

@@ -8,6 +8,13 @@ from smart_selects.db_fields import (
8 8
     ChainedManyToManyField,
9 9
     GroupedForeignKey,
10 10
 )
11
+import googlemaps
12
+from django.contrib.gis.geos import fromstr
13
+
14
+from django.conf import settings
15
+import csv
16
+
17
+gmaps = googlemaps.Client(key=settings.GOOGLE_MAPS_API_KEY)
11 18
 # Create your models here.
12 19
 GENDER_CHOICES = (
13 20
     ('นางสาว','นางสาว'),
@@ -122,9 +129,66 @@ class Patient(models.Model):
122 129
     comment  = models.TextField(blank=True, null=True)
123 130
     #test
124 131
     def __str__(self):
132
+        #self.nearby()
125 133
         return f"{self.first_name} {self.last_name}"
126 134
 
135
+
136
+    def nearby(self):
137
+        r = gmaps.places_nearby(location=(self.geolocation.lat, self.geolocation.lon), type="hospital", radius=10000)
138
+        bd = ""
139
+        for r0 in r['results']:
140
+            openh = "-"
141
+            if 'opening_hours' in r0:
142
+                openh = r0['opening_hours']['open_now']
143
+            else:
144
+                openh = "-"
145
+
146
+            bd += f"<tr><td>{r0['name']}</td><td>{openh}</td><td>{r0['vicinity']}</td></tr>"
147
+
148
+        rt = f'''
149
+<br>
150
+        <table><thead><tr><th>Name</th><th>Opening Hours</th><th>Vicinity</th></tr></thead>
151
+        <tbody>
152
+            {bd}
153
+        </tbody>
154
+        </table>
155
+        '''
156
+        return rt
157
+
158
+
159
+
160
+class ImportFile(models.Model):
161
+    hospital_file  = models.FileField(upload_to="uploads/%Y/%m/%d/", blank=True, verbose_name="Hospital (csv)")
162
+
163
+    def save(self, *args, **kwargs):
164
+        super(ImportFile, self).save(*args, **kwargs)
165
+
166
+        with self.hospital_file.open('r') as csv_file:
167
+            csv_reader = csv.reader(csv_file, delimiter=',')
168
+            Hospital.objects.all().delete()
169
+            line_count = 0
170
+
171
+            for r in csv_reader:
172
+                if line_count > 0:
173
+                    print(r)
174
+                    print(f"{r[7]},{r[6]}")
175
+                    try:
176
+                        gp = map_fields.GeoPt(lat=float(r[6]), lon=float(r[7]))
177
+
178
+                        location = fromstr(f'POINT({r[7]} {r[6]})', srid=4326)
179
+                        print(location)
180
+                        h = Hospital(title=r[3], address_text=r[5], geolocation=gp, address=r[3])
181
+                        h.save()
182
+                    except Exception as e:
183
+                        print(e)
184
+
185
+                line_count += 1
186
+
187
+
188
+
127 189
 class Place(models.Model):
190
+    #title  = models.Char
191
+    title = models.CharField(max_length=200, blank=True, null=True)
128 192
     address = map_fields.AddressField(max_length=200)
129 193
     geolocation = map_fields.GeoLocationField(max_length=100)
130 194
 
@@ -133,6 +197,36 @@ class Place(models.Model):
133 197
 
134 198
     more_info  = models.JSONField(null=True, blank=True)
135 199
 
200
+    def __str__(self):
201
+        return f"{self.address} ({self.geolocation})"
202
+class Points(models.Model):
203
+    #src  = models.ForeignKey(Place, on_delete=models.SET_NULL, null=True, blank=False, related_name='src')
204
+    dest  = models.ForeignKey(Place, on_delete=models.SET_NULL, null=True, blank=False, related_name='dest')
205
+    address = map_fields.AddressField(max_length=200, null=True)
206
+    geolocation = map_fields.GeoLocationField(max_length=100, null=True)
207
+
208
+    distance = models.DecimalField(null=True, blank=True, decimal_places=2, max_digits=7, verbose_name="Distance (km)")
209
+    duration = models.CharField(max_length=200, null=True, blank=True)
210
+
211
+    directions  = models.JSONField(null=True, blank=True)
212
+
213
+    def save(self, *args, **kwargs):
214
+        geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')
215
+        print(geocode_result)
216
+        print(self.geolocation)
217
+        origin = [(self.geolocation.lat, self.geolocation.lon)]
218
+        dest = [(self.dest.geolocation.lat, self.dest.geolocation.lon)]
219
+        dst = gmaps.distance_matrix(origin, dest)
220
+        dirs = gmaps.directions(origin[0], dest[0])
221
+        self.directions = dirs
222
+        print(dirs)
223
+        self.distance = dst['rows'][0]['elements'][0]['distance']['value'] / 1000
224
+        self.duration = dst['rows'][0]['elements'][0]['duration']['text']
225
+        print(dst)
226
+        super(Points, self).save(*args, **kwargs)
227
+
228
+
229
+
136 230
 class Hospital(models.Model):
137 231
     title = models.CharField(max_length=200)
138 232
     location = models.PointField(blank=True, null=True)
@@ -190,3 +284,5 @@ class PatientLog(models.Model):
190 284
     updated_at = models.DateTimeField(auto_now=True)
191 285
 
192 286
 
287
+
288
+

+ 7 - 0
app/backend/templates/backend/import_file.html

@@ -0,0 +1,7 @@
1
+{% extends "base.html" %}
2
+
3
+{% block title %}My amazing blog{% endblock %}
4
+
5
+{% block content %}
6
+Import File
7
+{% endblock %}

+ 8 - 0
app/backend/templates/backend/index.html

@@ -0,0 +1,8 @@
1
+{% extends "base.html" %}
2
+
3
+{% block title %}My amazing blog{% endblock %}
4
+
5
+{% block content %}
6
+Hello world
7
+<a href="{% url "import_file" %}">Import</a>
8
+{% endblock %}

backend/tests.py → app/backend/tests.py


+ 1 - 0
backend/urls.py

@@ -4,4 +4,5 @@ from . import views
4 4
 
5 5
 urlpatterns = [
6 6
     path('', views.index, name='index'),
7
+    path('import_file', views.import_file, name='import_file'),
7 8
 ]

+ 11 - 0
app/backend/views.py

@@ -0,0 +1,11 @@
1
+from django.shortcuts import render
2
+
3
+# Create your views here.
4
+from django.http import HttpResponse
5
+
6
+
7
+def index(request):
8
+    return render(request, 'backend/index.html')
9
+
10
+def import_file(request):
11
+    return render(request, 'backend/import_file.html')

manage.py → app/manage.py


uploads/2021/07/18/67224.jpg → app/media/uploads/2021/07/18/67224.jpg


Dosya farkı çok büyük olduğundan ihmal edildi
+ 10715 - 0
app/media/uploads/2021/07/22/citizeninfo_health_20200314.csv


Dosya farkı çok büyük olduğundan ihmal edildi
+ 10715 - 0
app/media/uploads/2021/07/22/citizeninfo_health_20200314_W9jk8Vu.csv


+ 1 - 0
requirements.txt

@@ -5,3 +5,4 @@ django-smart-selects
5 5
 django-colorfield
6 6
 googlemaps
7 7
 django-json-widget
8
+django-import-export

backend/__init__.py → app/shaqfindbed/__init__.py


shaqfindbed/__pycache__/__init__.cpython-39.pyc → app/shaqfindbed/__pycache__/__init__.cpython-39.pyc


BIN
app/shaqfindbed/__pycache__/settings.cpython-39.pyc


BIN
shaqfindbed/__pycache__/urls.cpython-39.pyc


shaqfindbed/__pycache__/wsgi.cpython-39.pyc → app/shaqfindbed/__pycache__/wsgi.cpython-39.pyc


shaqfindbed/asgi.py → app/shaqfindbed/asgi.py


+ 3 - 2
shaqfindbed/settings.py

@@ -33,12 +33,13 @@ ALLOWED_HOSTS = []
33 33
 # Application definition
34 34
 
35 35
 INSTALLED_APPS = [
36
+    'django.contrib.staticfiles',
36 37
     'django.contrib.admin',
37 38
     'django.contrib.auth',
38 39
     'django.contrib.contenttypes',
39 40
     'django.contrib.sessions',
40 41
     'django.contrib.messages',
41
-    'django.contrib.staticfiles',
42
+    'import_export',
42 43
     'django_google_maps',
43 44
     'django.contrib.gis',
44 45
     'smart_selects',
@@ -62,7 +63,7 @@ ROOT_URLCONF = 'shaqfindbed.urls'
62 63
 TEMPLATES = [
63 64
     {
64 65
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
65
-        'DIRS': [],
66
+        'DIRS': [os.path.join(BASE_DIR, 'templates')],
66 67
         'APP_DIRS': True,
67 68
         'OPTIONS': {
68 69
             'context_processors': [

+ 1 - 1
shaqfindbed/urls.py

@@ -23,7 +23,7 @@ urlpatterns = [
23 23
     path('backend/', include('backend.urls')),
24 24
     path('admin/', admin.site.urls),
25 25
     url(r'^chaining/', include('smart_selects.urls')),
26
-]
26
+] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
27 27
 
28 28
 if settings.DEBUG:
29 29
     urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

shaqfindbed/wsgi.py → app/shaqfindbed/wsgi.py


BIN
app/static/.DS_Store


BIN
app/static/admin/.DS_Store


staticfile/admin/css/autocomplete.css → app/static/admin/css/autocomplete.css


+ 0 - 0
staticfile/admin/css/base.css


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor