Repository: carpentries/amy

Issue:
Fixes needed to how lat/lon is treated
Latitude and longitude are appropriately stored as floats, for example in the [Airport class](https://github.com/carpentries/amy/blob/develop/amy/workshops/models.py#L397) and the [Event class](https://github.com/carpentries/amy/blob/develop/amy/workshops/models.py#L1015).  

However, because (0, 0) is a valid set of lat/long coordinates,  testing for something like `if not lat` or `if not long` returns false negatives.  See the for example the [admin dashboard](https://github.com/carpentries/amy/blob/develop/amy/templates/dashboard/admin_dashboard.html#L78) and the [event details table](https://github.com/carpentries/amy/blob/develop/amy/templates/includes/event_details_table.html#L55).  

Once this is resolved we should also fix the [default coordinates](https://github.com/carpentries/amy/blob/develop/amy/workshops/models.py#L1322) for online events to be (0,0).




Discussion:
Great catch. We could switch to using NULLs in the database for latitude and longitude when they're undefined (like in case of online event).

EDIT: to switch to NULLs-enabled database fields we must have `null=True` in model field's definition. Once it's in place, the comparison instead of `if not lat` would be `if lat is None` (`is` operator compares also LHS and RHS type).
> We could switch to using NULLs in the database for latitude and longitude when they're undefined (like in case of online event).

:+1: 

Resolving patch:
diff --git a/amy/workshops/models.py b/amy/workshops/models.py
--- a/amy/workshops/models.py
+++ b/amy/workshops/models.py
@@ -1592,8 +1592,8 @@ def save(self, *args, **kwargs):
             # enforce location data for 'Online' country
             self.venue = "Internet"
             self.address = "Internet"
-            self.latitude = -48.876667
-            self.longitude = -123.393333
+            self.latitude = None
+            self.longitude = None
 
         super().save(*args, **kwargs)
 
diff --git a/amy/workshops/views.py b/amy/workshops/views.py
--- a/amy/workshops/views.py
+++ b/amy/workshops/views.py
@@ -1016,6 +1016,12 @@ def event_details(request, slug):
         .values_list("person__email", flat=True),
         "today": datetime.date.today(),
         "admin_lookup_form": admin_lookup_form,
+        "event_location": {
+            "venue": event.venue,
+            "humandate": event.human_readable_date,
+            "latitude": event.latitude,
+            "longitude": event.longitude,
+        },
     }
     return render(request, "workshops/event.html", context)
 


Test patch:
diff --git a/amy/workshops/tests/test_event.py b/amy/workshops/tests/test_event.py
--- a/amy/workshops/tests/test_event.py
+++ b/amy/workshops/tests/test_event.py
@@ -67,8 +67,8 @@ def test_online_country_enforced_values(self):
         )
         self.assertEqual(e.venue, "Internet")
         self.assertEqual(e.address, "Internet")
-        self.assertAlmostEqual(e.latitude, -48.876667)
-        self.assertAlmostEqual(e.longitude, -123.393333)
+        self.assertEqual(e.latitude, None)
+        self.assertEqual(e.longitude, None)
 
         e = Event.objects.create(
             slug="offline-event", country="US", host=Organization.objects.first()