Skip to content

Commit

Permalink
tracking if venue is open, not closed; fixes #240
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsadetsky committed Mar 2, 2024
1 parent f970e84 commit a896553
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def get_content_as_text(self, obj):

class VenueAdmin(admin.ModelAdmin):
list_display = (
"closed",
"is_open",
"name_the_string",
"name",
"address",
Expand All @@ -233,7 +233,7 @@ class VenueAdmin(admin.ModelAdmin):
"neighborhood_and_borough",
)
list_display_links = ("name",)
list_filter = ("closed",)
list_filter = ("is_open",)
search_fields = ("name",)
ordering = ("name",)
save_on_top = True
Expand All @@ -251,11 +251,11 @@ def formfield_for_dbfield(self, db_field, **kwargs):

@admin.action(description="Mark as closed")
def mark_as_closed(self, request, queryset):
queryset.update(closed=True)
queryset.update(is_open=False)

@admin.action(description="Mark as open")
def mark_as_open(self, request, queryset):
queryset.update(closed=False)
queryset.update(is_open=True)


admin.site.register(Venue, VenueAdmin)
Expand Down
30 changes: 30 additions & 0 deletions core/migrations/0065_alleventproxy_venue_is_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.10 on 2024-03-02 19:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0064_venue_closed"),
]

operations = [
migrations.CreateModel(
name="AllEventProxy",
fields=[],
options={
"verbose_name": "event",
"verbose_name_plural": "events",
"proxy": True,
"indexes": [],
"constraints": [],
},
bases=("core.event",),
),
migrations.AddField(
model_name="venue",
name="is_open",
field=models.BooleanField(default=True),
),
]
22 changes: 22 additions & 0 deletions core/migrations/0066_auto_20240302_1439.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.10 on 2024-03-02 19:39

from django.db import migrations


def change_venue_field_closed_to_open(apps, schema_editor):
Venue = apps.get_model("core", "Venue")

# save into venue's new is_open field from closed (flipping the bit)
for venue in Venue.objects.all():
venue.is_open = not venue.closed
venue.save()


class Migration(migrations.Migration):
dependencies = [
("core", "0065_alleventproxy_venue_is_open"),
]

operations = [
migrations.RunPython(change_venue_field_closed_to_open),
]
17 changes: 17 additions & 0 deletions core/migrations/0067_remove_venue_closed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.10 on 2024-03-02 19:42

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("core", "0066_auto_20240302_1439"),
]

operations = [
migrations.RemoveField(
model_name="venue",
name="closed",
),
]
3 changes: 2 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ class Meta:
phone = models.CharField(max_length=255, null=True, blank=True)
email = models.EmailField(null=True, blank=True)

closed = models.BooleanField(null=True, default=False)
is_open = models.BooleanField(default=True)

capacity = models.CharField(
max_length=255, null=True, blank=True, verbose_name="cap"
)
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_user_submitted_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_user_submitted_events_are_unapproved(self):

def test_closed_venues_not_shown_in_list(self):
open_venue = Venue(name=uuid.uuid4().hex)
closed_venue = Venue(name=uuid.uuid4().hex, closed=True)
closed_venue = Venue(name=uuid.uuid4().hex, is_open=False)
open_venue.save()
closed_venue.save()

Expand Down
2 changes: 1 addition & 1 deletion core/views/event_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserSubmittedEventForm(forms.ModelForm):
label=mark_safe("Venue Name<br>(if not in list above)"), required=False
)
venue = forms.models.ModelChoiceField(
queryset=Venue.objects.filter(closed=False), required=False
queryset=Venue.objects.filter(is_open=True), required=False
)

class Meta:
Expand Down

0 comments on commit a896553

Please sign in to comment.