54
     formfield_overrides = {
83
     formfield_overrides = {
55
         map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
84
         map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
56
     }
85
     }
57
     inlines = [PatientLogAdmin,]
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

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

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

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

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

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

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
     ChainedManyToManyField,
8
     ChainedManyToManyField,
9
     GroupedForeignKey,
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
 # Create your models here.
18
 # Create your models here.
12
 GENDER_CHOICES = (
19
 GENDER_CHOICES = (
13
     ('นางสาว','นางสาว'),
20
     ('นางสาว','นางสาว'),
122
     comment  = models.TextField(blank=True, null=True)
129
     comment  = models.TextField(blank=True, null=True)
123
     #test
130
     #test
124
     def __str__(self):
131
     def __str__(self):
132
+        #self.nearby()
125
         return f"{self.first_name} {self.last_name}"
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
 class Place(models.Model):
189
 class Place(models.Model):
190
+    #title  = models.Char
191
+    title = models.CharField(max_length=200, blank=True, null=True)
128
     address = map_fields.AddressField(max_length=200)
192
     address = map_fields.AddressField(max_length=200)
129
     geolocation = map_fields.GeoLocationField(max_length=100)
193
     geolocation = map_fields.GeoLocationField(max_length=100)
130
 
194
 
133
 
197
 
134
     more_info  = models.JSONField(null=True, blank=True)
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
 class Hospital(models.Model):
230
 class Hospital(models.Model):
137
     title = models.CharField(max_length=200)
231
     title = models.CharField(max_length=200)
138
     location = models.PointField(blank=True, null=True)
232
     location = models.PointField(blank=True, null=True)
190
     updated_at = models.DateTimeField(auto_now=True)
284
     updated_at = models.DateTimeField(auto_now=True)
191
 
285
 
192
 
286
 
287
+
288
+

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

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

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
 
5
 urlpatterns = [
5
 urlpatterns = [
6
     path('', views.index, name='index'),
6
     path('', views.index, name='index'),
7
+    path('import_file', views.import_file, name='import_file'),
7
 ]
8
 ]

+ 11 - 0
app/backend/views.py

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
 django-colorfield
5
 django-colorfield
6
 googlemaps
6
 googlemaps
7
 django-json-widget
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
 # Application definition
33
 # Application definition
34
 
34
 
35
 INSTALLED_APPS = [
35
 INSTALLED_APPS = [
36
+    'django.contrib.staticfiles',
36
     'django.contrib.admin',
37
     'django.contrib.admin',
37
     'django.contrib.auth',
38
     'django.contrib.auth',
38
     'django.contrib.contenttypes',
39
     'django.contrib.contenttypes',
39
     'django.contrib.sessions',
40
     'django.contrib.sessions',
40
     'django.contrib.messages',
41
     'django.contrib.messages',
41
-    'django.contrib.staticfiles',
42
+    'import_export',
42
     'django_google_maps',
43
     'django_google_maps',
43
     'django.contrib.gis',
44
     'django.contrib.gis',
44
     'smart_selects',
45
     'smart_selects',
62
 TEMPLATES = [
63
 TEMPLATES = [
63
     {
64
     {
64
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
65
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
65
-        'DIRS': [],
66
+        'DIRS': [os.path.join(BASE_DIR, 'templates')],
66
         'APP_DIRS': True,
67
         'APP_DIRS': True,
67
         'OPTIONS': {
68
         'OPTIONS': {
68
             'context_processors': [
69
             'context_processors': [

+ 1 - 1
shaqfindbed/urls.py

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

tmt/tiger_frontend - Gogs: Simplico Git Service

Bez popisu

golf 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky
..
deps.js 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky
index.js 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky
plugin.js 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky
utils.js 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky
watching.js 77628cf8bf first comm %!s(int64=2) %!d(string=před) roky