From f11152a8a8f6176a8e30ea1f94caa5e00e673409 Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 10:30:54 -0400 Subject: [PATCH 01/18] Dashboard stuff --- transit/templates/transit/dashboard.html | 22 +++++++++++++++++++++- transit/views.py | 7 ++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/transit/templates/transit/dashboard.html b/transit/templates/transit/dashboard.html index e3528e5..40b0df4 100644 --- a/transit/templates/transit/dashboard.html +++ b/transit/templates/transit/dashboard.html @@ -4,7 +4,27 @@ {% block content %}
- +
+
+
Orange Line & McCormick Rd
+
+
Routes
+

With supporting text below as a natural lead-in to additional content.

+
+
+
+ {% for stop in stops %} +
+
+
{{ stop.name }}/h5> +
+
Special title treatment
+

With supporting text below as a natural lead-in to additional content.

+ Go somewhere +
+
+
+ {% endfor %}
{% endblock %} \ No newline at end of file diff --git a/transit/views.py b/transit/views.py index 800ab49..ba64f8b 100644 --- a/transit/views.py +++ b/transit/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render import requests, re, os -from .models import UserSettings, UserSettingsForm +from .models import UserSettings, UserSettingsForm, Stop from django.http import HttpResponseRedirect from twilio.rest import Client from django.conf import settings @@ -40,6 +40,11 @@ def get_eta(pos1, pos2): eta_str2 = re.compile('\d+ min').search(eta_str)[0] return int(eta_str2[:-4]) # number of minutes +def dashboard_view(request): + stops = Stop.objects.all() + print(stops) + return render(request, "transit/dashboard.html", {'stops': stops}) + def settings_view(request): form = UserSettingsForm() return render(request, "transit/settings.html", {'form': form}) From 35a4d53306407f276205a286705e23b51f0f04c8 Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 11:40:40 -0400 Subject: [PATCH 02/18] Dashboard --- transit/models.py | 17 ++++++++++ transit/templates/transit/dashboard.html | 22 +++++-------- transit/urls.py | 2 +- transit/views.py | 40 +++++++++++++++++++++--- 4 files changed, 61 insertions(+), 20 deletions(-) diff --git a/transit/models.py b/transit/models.py index 8373a64..5ebcdd6 100644 --- a/transit/models.py +++ b/transit/models.py @@ -8,6 +8,9 @@ class Route(models.Model): short_name = models.CharField(max_length=10) is_active = models.BooleanField(default=True) + def __str__(self): + return self.long_name + class Stop(models.Model): id = models.IntegerField(primary_key=True) name = models.CharField(max_length=50) @@ -15,6 +18,17 @@ class Stop(models.Model): lat = models.IntegerField() code = models.IntegerField() routes = models.ManyToManyField(Route) + route_str = models.TextField(default="No routes to display") + + def __str__(self): + return str(self.code) + + def format_routes(self): + str = "Routes: " + for route in self.routes.all(): + str += route.long_name.lower().title() + ", " + + return str[:len(str)-2] class Vehicle(models.Model): id = models.IntegerField(primary_key=True) @@ -24,6 +38,9 @@ class Vehicle(models.Model): service_status = models.CharField(max_length=12) route_id = models.ForeignKey(Route,on_delete=models.DO_NOTHING) + def __str__(self): + return self.call_name + from django.conf import settings from django import forms diff --git a/transit/templates/transit/dashboard.html b/transit/templates/transit/dashboard.html index 40b0df4..3330b61 100644 --- a/transit/templates/transit/dashboard.html +++ b/transit/templates/transit/dashboard.html @@ -4,23 +4,15 @@ {% block content %}
-
-
-
Orange Line & McCormick Rd
-
-
Routes
-

With supporting text below as a natural lead-in to additional content.

-
-
-
{% for stop in stops %} -
+
-
{{ stop.name }}/h5> -
-
Special title treatment
-

With supporting text below as a natural lead-in to additional content.

- Go somewhere +
{{ stop.name }}
+
+

{{ stop.route_str }}

+ + Track +
diff --git a/transit/urls.py b/transit/urls.py index b553404..e4134e7 100644 --- a/transit/urls.py +++ b/transit/urls.py @@ -6,7 +6,7 @@ from . import views urlpatterns = [ - path('', TemplateView.as_view(template_name="transit/dashboard.html")), + path('', views.dashboard_view, name = "dashboard_view"), path('settings/', views.settings_view, name = "settings_view"), path('settings/retry/', views.change_settings, name = "change_settings"), path('accounts/', include('allauth.urls')), diff --git a/transit/views.py b/transit/views.py index ba64f8b..5cd305d 100644 --- a/transit/views.py +++ b/transit/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render import requests, re, os -from .models import UserSettings, UserSettingsForm, Stop +from .models import UserSettings, UserSettingsForm, Route, Vehicle, Stop from django.http import HttpResponseRedirect from twilio.rest import Client from django.conf import settings @@ -41,8 +41,12 @@ def get_eta(pos1, pos2): return int(eta_str2[:-4]) # number of minutes def dashboard_view(request): - stops = Stop.objects.all() - print(stops) + stops = Stop.objects.all().order_by('name') + + for stop in stops: + stop.route_str = stop.format_routes() + stop.save() + return render(request, "transit/dashboard.html", {'stops': stops}) def settings_view(request): @@ -69,4 +73,32 @@ def change_settings(request): return HttpResponseRedirect('/transit') else: form = UserSettingsForm() - return render(request, 'transit/settings.html', {'form': form, 'error_message': 'Something went wrong.'}) \ No newline at end of file + return render(request, 'transit/settings.html', {'form': form, 'error_message': 'Something went wrong.'}) + + +def create_routes(): + devhub_url = 'https://api.devhub.virginia.edu/v1/transit/routes' + devhub_data = {'success': False} + + while not devhub_data['success']: + devhub_data = requests.get(devhub_url).json() + + for route in devhub_data['routes']: + r = Route(id=route['id'], is_active=route['is_active'], long_name=route['long_name'], + short_name=route['short_name']) + r.save() + +def create_stops(): + devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' + devhub_data = {'success': False} + + while not devhub_data['success']: + devhub_data = requests.get(devhub_url).json() + + for stop in devhub_data['stops']: + s = Stop(id=stop['id'],name=stop['name'],lat=stop["position"][0],long=stop["position"][1],code=int(stop["code"])) + s.save() + + for route in devhub_data['routes']: + continue + From 36fb48e79007edb0d25b1e98d5b77b3f856f827d Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:18:23 -0400 Subject: [PATCH 03/18] Created routes, admin sees backend models --- transit/admin.py | 7 +++++-- transit/models.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/transit/admin.py b/transit/admin.py index 48c1b59..21de015 100644 --- a/transit/admin.py +++ b/transit/admin.py @@ -1,6 +1,9 @@ from django.contrib import admin -from .models import UserSettings +from .models import UserSettings, Route, Stop, Vehicle # Register your models here. -admin.site.register(UserSettings) \ No newline at end of file +admin.site.register(UserSettings) +admin.site.register(Route) +admin.site.register(Stop) +admin.site.register(Vehicle) diff --git a/transit/models.py b/transit/models.py index 5ebcdd6..a252542 100644 --- a/transit/models.py +++ b/transit/models.py @@ -30,6 +30,9 @@ def format_routes(self): return str[:len(str)-2] + def __str__(self): + return self.code + class Vehicle(models.Model): id = models.IntegerField(primary_key=True) call_name = models.CharField(max_length=20) From 37584272778f9152edd902943af0dae4aa1149e3 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:27:13 -0400 Subject: [PATCH 04/18] Fixed stop display issue --- transit/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transit/models.py b/transit/models.py index a252542..2043c8a 100644 --- a/transit/models.py +++ b/transit/models.py @@ -31,7 +31,7 @@ def format_routes(self): return str[:len(str)-2] def __str__(self): - return self.code + return str(self.code) class Vehicle(models.Model): id = models.IntegerField(primary_key=True) From da094b6e4bb73e3caf84ec910cdc2bedbb36a44e Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:48:20 -0400 Subject: [PATCH 05/18] Added stops, changed model for stops and vehicles to increase position precision --- transit/models.py | 8 ++++---- transit/views.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/transit/models.py b/transit/models.py index 2043c8a..a11bfc0 100644 --- a/transit/models.py +++ b/transit/models.py @@ -14,8 +14,8 @@ def __str__(self): class Stop(models.Model): id = models.IntegerField(primary_key=True) name = models.CharField(max_length=50) - long = models.IntegerField() - lat = models.IntegerField() + long = models.DecimalField(max_digits=17,decimal_places=15) + lat = models.DecimalField(max_digits=17,decimal_places=15) code = models.IntegerField() routes = models.ManyToManyField(Route) route_str = models.TextField(default="No routes to display") @@ -36,8 +36,8 @@ def __str__(self): class Vehicle(models.Model): id = models.IntegerField(primary_key=True) call_name = models.CharField(max_length=20) - long = models.IntegerField() - lat = models.IntegerField() + long = models.DecimalField(max_digits=17, decimal_places=15) + lat = models.DecimalField(max_digits=17, decimal_places=15) service_status = models.CharField(max_length=12) route_id = models.ForeignKey(Route,on_delete=models.DO_NOTHING) diff --git a/transit/views.py b/transit/views.py index 5cd305d..a82b095 100644 --- a/transit/views.py +++ b/transit/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponseRedirect from twilio.rest import Client from django.conf import settings +from decimal import Decimal def get_long_lat(): dev_url = "https://www.googleapis.com/geolocation/v1/geolocate?" @@ -96,9 +97,18 @@ def create_stops(): devhub_data = requests.get(devhub_url).json() for stop in devhub_data['stops']: - s = Stop(id=stop['id'],name=stop['name'],lat=stop["position"][0],long=stop["position"][1],code=int(stop["code"])) + lat = Decimal("%.15f" % stop["position"][0]) + long = Decimal("%.15f" % stop["position"][1]) + s = Stop(id=stop['id'],name=stop['name'],lat=lat,long=long,code=int(stop["code"])) s.save() for route in devhub_data['routes']: - continue + r = Route.objects.filter(id=route['id'])[0] + for stop_id in route['stops']: + try: + s = Stop.objects.filter(id=stop_id)[0] + s.routes.add(r) + except IndexError: + continue + From 01088467a4580e7fee54698180c129e27623839f Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 11:27:27 -0400 Subject: [PATCH 06/18] Not working buses_near_stop method --- transit/views.py | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/transit/views.py b/transit/views.py index a82b095..f086d15 100644 --- a/transit/views.py +++ b/transit/views.py @@ -20,15 +20,13 @@ def etas_to_loc(loc): :return: list of vehicles with fields from Devhub API + eta (number of minutes until bus reaches loc) ''' - dev_url = 'https://api.devhub.virginia.edu/v1/transit/vehicles' - dev_data = {'success': False} - while not dev_data['success']: - dev_data = requests.get(dev_url).json() - print("Got vehicle locations") - vehicles = dev_data['vehicles'] - for i in range(len(vehicles)): - vehicles[i]['eta'] = get_eta(vehicles[i]['position'], loc) - vehicles.sort(key=lambda k: k['eta']) + create_or_update_vehicles() + vehicles = [] + v_set = Vehicle.objects.all() + for v in v_set: + eta = get_eta((v.lat,v.long),loc) + vehicles.append((v,eta)) + vehicles.sort(key=lambda k: k[1]) # sort by min to max eta return vehicles def get_eta(pos1, pos2): @@ -112,3 +110,33 @@ def create_stops(): continue +def create_or_update_vehicles(): + devhub_url = 'https://api.devhub.virginia.edu/v1/transit/vehicles' + devhub_data = {'success': False} + + while not devhub_data['success']: + devhub_data = requests.get(devhub_url).json() + + for veh in devhub_data['vehicles']: + veh_set = Vehicle.objects.filter(id=veh['id']) + lat = Decimal("%.15f" % veh["position"][0]) + long = Decimal("%.15f" % veh["position"][1]) + r = Route.objects.filter(id=veh['route_id'])[0] + if len(veh_set) == 0: + v = Vehicle(id=veh['id'],call_name=veh['call_name'],long=long,lat=lat,service_status=veh['service_status'],route_id=r) + v.save() + else: + v.lat = lat + v.long = long + v.route_id = r + v.service_status = veh['service_status'] + +def buses_near_stop(stop_id): + s = Stop.objects.filter(id=stop_id)[0] + vehicles = etas_to_loc((s.lat,s.long)) + route_vehicles = [] + routes = s.routes.all() + for v,eta in vehicles: + if v.route_id in routes: + route_vehicles.append((v,eta)) + return vehicles From a6d6db652e767ec171f251a8b3c5f7991469c64e Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 11:34:22 -0400 Subject: [PATCH 07/18] Working buses_near_stop method --- transit/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/transit/views.py b/transit/views.py index f086d15..9016867 100644 --- a/transit/views.py +++ b/transit/views.py @@ -30,11 +30,14 @@ def etas_to_loc(loc): return vehicles def get_eta(pos1, pos2): - source = str(pos1)[1:-1] - dest = str(pos2)[1:-1] + get_str = lambda k: str(float(k[0]))+','+str(float(k[1])) + source = get_str(pos1) + dest = get_str(pos2) google_url = 'https://maps.googleapis.com/maps/api/distancematrix/json?' - google_data = requests.get( - google_url + 'origins=' + source + '&destinations=' + dest + '&key=' + os.environ.get("GOOGLE_DISTANCE_MATRIX_API_KEY")).json() + real_url = google_url + 'origins=' + source + '&destinations=' + dest + '&key=' + os.environ.get("GOOGLE_DISTANCE_MATRIX_API_KEY") + # print(real_url) + google_data = requests.get(real_url).json() + # print(google_data) eta_str = google_data['rows'][0]['elements'][0]['duration']['text'] eta_str2 = re.compile('\d+ min').search(eta_str)[0] return int(eta_str2[:-4]) # number of minutes @@ -126,6 +129,7 @@ def create_or_update_vehicles(): v = Vehicle(id=veh['id'],call_name=veh['call_name'],long=long,lat=lat,service_status=veh['service_status'],route_id=r) v.save() else: + v = veh_set[0] v.lat = lat v.long = long v.route_id = r From f8b79e80f91729dbe075708e03ba7d04b6fdf373 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 11:39:36 -0400 Subject: [PATCH 08/18] Fixed precision in stop locations --- transit/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/transit/views.py b/transit/views.py index 9016867..3e8abbb 100644 --- a/transit/views.py +++ b/transit/views.py @@ -90,6 +90,19 @@ def create_routes(): short_name=route['short_name']) r.save() +def update_stop_locations(): + devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' + devhub_data = {'success': False} + while not devhub_data['success']: + devhub_data = requests.get(devhub_url).json() + for stop in devhub_data['stops']: + lat = Decimal("%.15f" % stop["position"][0]) + long = Decimal("%.15f" % stop["position"][1]) + s = Stop.objects.filter(id=stop['id'])[0] + s.lat = lat + s.long = long + s.save() + def create_stops(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' devhub_data = {'success': False} @@ -103,6 +116,7 @@ def create_stops(): s = Stop(id=stop['id'],name=stop['name'],lat=lat,long=long,code=int(stop["code"])) s.save() + for route in devhub_data['routes']: r = Route.objects.filter(id=route['id'])[0] for stop_id in route['stops']: @@ -134,6 +148,7 @@ def create_or_update_vehicles(): v.long = long v.route_id = r v.service_status = veh['service_status'] + v.save() def buses_near_stop(stop_id): s = Stop.objects.filter(id=stop_id)[0] From 05a2355bc48443bd21196bfba05f2a9fae4937fe Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 11:42:03 -0400 Subject: [PATCH 09/18] Dashboard stuff --- transit/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/transit/views.py b/transit/views.py index 3e8abbb..9104238 100644 --- a/transit/views.py +++ b/transit/views.py @@ -90,6 +90,7 @@ def create_routes(): short_name=route['short_name']) r.save() +<<<<<<< HEAD def update_stop_locations(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' devhub_data = {'success': False} @@ -103,6 +104,8 @@ def update_stop_locations(): s.long = long s.save() +======= +>>>>>>> 35a4d53 (Dashboard) def create_stops(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' devhub_data = {'success': False} @@ -111,6 +114,7 @@ def create_stops(): devhub_data = requests.get(devhub_url).json() for stop in devhub_data['stops']: +<<<<<<< HEAD lat = Decimal("%.15f" % stop["position"][0]) long = Decimal("%.15f" % stop["position"][1]) s = Stop(id=stop['id'],name=stop['name'],lat=lat,long=long,code=int(stop["code"])) @@ -159,3 +163,11 @@ def buses_near_stop(stop_id): if v.route_id in routes: route_vehicles.append((v,eta)) return vehicles +======= + s = Stop(id=stop['id'],name=stop['name'],lat=stop["position"][0],long=stop["position"][1],code=int(stop["code"])) + s.save() + + for route in devhub_data['routes']: + continue + +>>>>>>> 35a4d53 (Dashboard) From da5e7d153c2c5541f0d9ecddd3c651dfd756d10c Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 11:40:40 -0400 Subject: [PATCH 10/18] Dashboard --- transit/views.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/transit/views.py b/transit/views.py index 9104238..3e8abbb 100644 --- a/transit/views.py +++ b/transit/views.py @@ -90,7 +90,6 @@ def create_routes(): short_name=route['short_name']) r.save() -<<<<<<< HEAD def update_stop_locations(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' devhub_data = {'success': False} @@ -104,8 +103,6 @@ def update_stop_locations(): s.long = long s.save() -======= ->>>>>>> 35a4d53 (Dashboard) def create_stops(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/bus-stops' devhub_data = {'success': False} @@ -114,7 +111,6 @@ def create_stops(): devhub_data = requests.get(devhub_url).json() for stop in devhub_data['stops']: -<<<<<<< HEAD lat = Decimal("%.15f" % stop["position"][0]) long = Decimal("%.15f" % stop["position"][1]) s = Stop(id=stop['id'],name=stop['name'],lat=lat,long=long,code=int(stop["code"])) @@ -163,11 +159,3 @@ def buses_near_stop(stop_id): if v.route_id in routes: route_vehicles.append((v,eta)) return vehicles -======= - s = Stop(id=stop['id'],name=stop['name'],lat=stop["position"][0],long=stop["position"][1],code=int(stop["code"])) - s.save() - - for route in devhub_data['routes']: - continue - ->>>>>>> 35a4d53 (Dashboard) From b3398ff05f85eacd96660da624b41bca1ae73b57 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:18:23 -0400 Subject: [PATCH 11/18] Created routes, admin sees backend models --- ..._rename_threshold_eta_usersettings_start.py | 18 ++++++++++++++++++ transit/models.py | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 transit/migrations/0002_rename_threshold_eta_usersettings_start.py diff --git a/transit/migrations/0002_rename_threshold_eta_usersettings_start.py b/transit/migrations/0002_rename_threshold_eta_usersettings_start.py new file mode 100644 index 0000000..dd090f8 --- /dev/null +++ b/transit/migrations/0002_rename_threshold_eta_usersettings_start.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.3 on 2022-03-27 07:53 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0001_initial'), + ] + + operations = [ + migrations.RenameField( + model_name='usersettings', + old_name='threshold_eta', + new_name='start', + ), + ] diff --git a/transit/models.py b/transit/models.py index a11bfc0..d53c436 100644 --- a/transit/models.py +++ b/transit/models.py @@ -33,6 +33,9 @@ def format_routes(self): def __str__(self): return str(self.code) + def __str__(self): + return self.code + class Vehicle(models.Model): id = models.IntegerField(primary_key=True) call_name = models.CharField(max_length=20) From 7c0bce7f1240f5c6aa1f3e42dce70e14bf0bac05 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:27:13 -0400 Subject: [PATCH 12/18] Fixed stop display issue --- transit/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transit/models.py b/transit/models.py index d53c436..5f94dff 100644 --- a/transit/models.py +++ b/transit/models.py @@ -34,7 +34,7 @@ def __str__(self): return str(self.code) def __str__(self): - return self.code + return str(self.code) class Vehicle(models.Model): id = models.IntegerField(primary_key=True) From 2511428277b5338c8c9402b2c2ae1547dd397fb5 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 11:46:35 -0400 Subject: [PATCH 13/18] Added favorite stop field to user settings --- transit/migrations/0003_auto_20220327_1433.py | 33 +++++++++++++++++++ transit/migrations/0004_auto_20220327_1438.py | 33 +++++++++++++++++++ transit/migrations/0005_auto_20220327_1440.py | 33 +++++++++++++++++++ transit/models.py | 3 +- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 transit/migrations/0003_auto_20220327_1433.py create mode 100644 transit/migrations/0004_auto_20220327_1438.py create mode 100644 transit/migrations/0005_auto_20220327_1440.py diff --git a/transit/migrations/0003_auto_20220327_1433.py b/transit/migrations/0003_auto_20220327_1433.py new file mode 100644 index 0000000..fb1db94 --- /dev/null +++ b/transit/migrations/0003_auto_20220327_1433.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.12 on 2022-03-27 14:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0002_alter_usersettings_phone'), + ] + + operations = [ + migrations.AlterField( + model_name='stop', + name='lat', + field=models.FloatField(), + ), + migrations.AlterField( + model_name='stop', + name='long', + field=models.FloatField(), + ), + migrations.AlterField( + model_name='vehicle', + name='lat', + field=models.FloatField(), + ), + migrations.AlterField( + model_name='vehicle', + name='long', + field=models.FloatField(), + ), + ] diff --git a/transit/migrations/0004_auto_20220327_1438.py b/transit/migrations/0004_auto_20220327_1438.py new file mode 100644 index 0000000..6c2e530 --- /dev/null +++ b/transit/migrations/0004_auto_20220327_1438.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.12 on 2022-03-27 14:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0003_auto_20220327_1433'), + ] + + operations = [ + migrations.AlterField( + model_name='stop', + name='lat', + field=models.DecimalField(decimal_places=17, max_digits=17), + ), + migrations.AlterField( + model_name='stop', + name='long', + field=models.DecimalField(decimal_places=17, max_digits=17), + ), + migrations.AlterField( + model_name='vehicle', + name='lat', + field=models.DecimalField(decimal_places=17, max_digits=17), + ), + migrations.AlterField( + model_name='vehicle', + name='long', + field=models.DecimalField(decimal_places=17, max_digits=17), + ), + ] diff --git a/transit/migrations/0005_auto_20220327_1440.py b/transit/migrations/0005_auto_20220327_1440.py new file mode 100644 index 0000000..6fc6184 --- /dev/null +++ b/transit/migrations/0005_auto_20220327_1440.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.12 on 2022-03-27 14:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0004_auto_20220327_1438'), + ] + + operations = [ + migrations.AlterField( + model_name='stop', + name='lat', + field=models.DecimalField(decimal_places=15, max_digits=17), + ), + migrations.AlterField( + model_name='stop', + name='long', + field=models.DecimalField(decimal_places=15, max_digits=17), + ), + migrations.AlterField( + model_name='vehicle', + name='lat', + field=models.DecimalField(decimal_places=15, max_digits=17), + ), + migrations.AlterField( + model_name='vehicle', + name='long', + field=models.DecimalField(decimal_places=15, max_digits=17), + ), + ] diff --git a/transit/models.py b/transit/models.py index 5f94dff..3e4938e 100644 --- a/transit/models.py +++ b/transit/models.py @@ -59,11 +59,12 @@ class UserSettings(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) phone = PhoneNumberField(null=False, blank=False) start = models.IntegerField(default=5) + fav_stop = models.ForeignKey(Stop,blank=True,on_delete=models.DO_NOTHING,default=4266820) class UserSettingsForm(forms.ModelForm): class Meta: model = UserSettings - fields = ['phone', 'start'] + fields = ['phone', 'start','fav_stop'] widgets = { 'phone': PhoneNumberPrefixWidget(attrs={'placeholder': ('Phone')}), 'start': forms.TextInput(attrs={'type': 'range', 'min': '1', 'max': '11', 'step': '1', 'value': '6', 'list': 'tickmarks'}), From a29fda902062d8a7a33a7f3332288c9d5116498c Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 11:46:57 -0400 Subject: [PATCH 14/18] Added favorite stop field to user settings --- .../migrations/0006_usersettings_fav_stop.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 transit/migrations/0006_usersettings_fav_stop.py diff --git a/transit/migrations/0006_usersettings_fav_stop.py b/transit/migrations/0006_usersettings_fav_stop.py new file mode 100644 index 0000000..c53b680 --- /dev/null +++ b/transit/migrations/0006_usersettings_fav_stop.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.12 on 2022-03-27 15:46 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0005_auto_20220327_1440'), + ] + + operations = [ + migrations.AddField( + model_name='usersettings', + name='fav_stop', + field=models.ForeignKey(blank=True, default=4266820, on_delete=django.db.models.deletion.DO_NOTHING, to='transit.stop'), + ), + ] From 97b2a28b0716453be80cff62b90fe16e8079b72f Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 11:40:40 -0400 Subject: [PATCH 15/18] Dashboard --- transit/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transit/models.py b/transit/models.py index 3e4938e..f17d5b8 100644 --- a/transit/models.py +++ b/transit/models.py @@ -29,9 +29,12 @@ def format_routes(self): str += route.long_name.lower().title() + ", " return str[:len(str)-2] +<<<<<<< HEAD def __str__(self): return str(self.code) +======= +>>>>>>> ed35f18 (Dashboard) def __str__(self): return str(self.code) From 603858a5c55388fd7eaecb4985ce2badb6100612 Mon Sep 17 00:00:00 2001 From: Bejoy Sen Date: Sun, 27 Mar 2022 10:48:20 -0400 Subject: [PATCH 16/18] Added stops, changed model for stops and vehicles to increase position precision --- transit/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/transit/views.py b/transit/views.py index 3e8abbb..6206849 100644 --- a/transit/views.py +++ b/transit/views.py @@ -126,7 +126,6 @@ def create_stops(): except IndexError: continue - def create_or_update_vehicles(): devhub_url = 'https://api.devhub.virginia.edu/v1/transit/vehicles' devhub_data = {'success': False} From 22f10322235c98ec566431d2a325f5f12dbf75ba Mon Sep 17 00:00:00 2001 From: Denis Callinan Date: Sun, 27 Mar 2022 11:56:54 -0400 Subject: [PATCH 17/18] Update models.py --- transit/models.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/transit/models.py b/transit/models.py index fa1fb23..a59586b 100644 --- a/transit/models.py +++ b/transit/models.py @@ -29,15 +29,6 @@ def format_routes(self): str += route.long_name.lower().title() + ", " return str[:len(str)-2] -<<<<<<< HEAD - - def __str__(self): - return str(self.code) -======= ->>>>>>> ed35f18 (Dashboard) - - def __str__(self): - return str(self.code) def __str__(self): return str(self.code) From 77017d8d55974a2e9c9b32a1485831e7cc35c118 Mon Sep 17 00:00:00 2001 From: drcall Date: Sun, 27 Mar 2022 11:58:28 -0400 Subject: [PATCH 18/18] stuff --- transit/migrations/0007_merge_20220327_1558.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 transit/migrations/0007_merge_20220327_1558.py diff --git a/transit/migrations/0007_merge_20220327_1558.py b/transit/migrations/0007_merge_20220327_1558.py new file mode 100644 index 0000000..9d3bdcf --- /dev/null +++ b/transit/migrations/0007_merge_20220327_1558.py @@ -0,0 +1,14 @@ +# Generated by Django 3.2.12 on 2022-03-27 15:58 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('transit', '0002_rename_threshold_eta_usersettings_start'), + ('transit', '0006_usersettings_fav_stop'), + ] + + operations = [ + ]