diff --git a/src/django_project/tests/unit/web/test_model_crud.py b/src/django_project/tests/unit/web/test_model_crud.py index 77f8040..118d6b9 100644 --- a/src/django_project/tests/unit/web/test_model_crud.py +++ b/src/django_project/tests/unit/web/test_model_crud.py @@ -93,6 +93,17 @@ def test_update_location_address(self): self.assertEqual(getattr(row, "location_address"), updated_value) self.assertNotEqual(getattr(row, "location_address"), original_value) + def test_create_without_location(self): + """verify event can be created without location fields""" + row = self.model.objects.create( + name="Locationless event", + start_datetime="2026-06-24T00:00:00Z", + location_name=None, + location_address=None, + ) + self.assertIsNone(row.location_name) + self.assertIsNone(row.location_address) + def test_update_location_name(self): """verify location_name (CharField) can be updated""" row = self.bake() diff --git a/src/django_project/web/migrations/0005_alter_event_location_fields_nullable.py b/src/django_project/web/migrations/0005_alter_event_location_fields_nullable.py new file mode 100644 index 0000000..351a74c --- /dev/null +++ b/src/django_project/web/migrations/0005_alter_event_location_fields_nullable.py @@ -0,0 +1,31 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("web", "0004_alter_event_end_datetime"), + ] + + operations = [ + migrations.AlterField( + model_name="event", + name="location_name", + field=models.CharField( + blank=True, + help_text="name of location where this event is being hosted", + max_length=64, + null=True, + ), + ), + migrations.AlterField( + model_name="event", + name="location_address", + field=models.CharField( + blank=True, + help_text="address of location where this event is being hosted", + max_length=256, + null=True, + ), + ), + ] diff --git a/src/django_project/web/models.py b/src/django_project/web/models.py index 2082c80..43b09d2 100644 --- a/src/django_project/web/models.py +++ b/src/django_project/web/models.py @@ -20,11 +20,13 @@ class Event(HandyHelperBaseModel): location_name = models.CharField( max_length=64, blank=True, + null=True, help_text="name of location where this event is being hosted", ) location_address = models.CharField( max_length=256, blank=True, + null=True, help_text="address of location where this event is being hosted", ) map_link = models.URLField( diff --git a/src/django_project/web/tasks.py b/src/django_project/web/tasks.py index 961ee4b..f48f187 100644 --- a/src/django_project/web/tasks.py +++ b/src/django_project/web/tasks.py @@ -100,6 +100,9 @@ def ingest_future_meetup_events(group_pk) -> str: event_info = get_event_information(event_link) event_info["group"] = group if event_info: + event_info.setdefault("location_name", "") + event_info.setdefault("location_address", "") + event_info.setdefault("map_link", "") if not event_info.get("name", None): logging.error(f"error parsing name for event hosted by {group.name}; data = {event_info}") continue diff --git a/src/django_project/web/templates/web/partials/li/events.htm b/src/django_project/web/templates/web/partials/li/events.htm index 5b0b39f..e24b2ca 100644 --- a/src/django_project/web/templates/web/partials/li/events.htm +++ b/src/django_project/web/templates/web/partials/li/events.htm @@ -14,8 +14,10 @@ {{ row.group.name }}
- {{ row.location_name }}
- {{ row.location_address }} + {% if row.location_name or row.location_address %} + {{ row.location_name }}{% if row.location_address %}
+ {{ row.location_address }}{% endif %} + {% endif %}