Skip to content

Commit

Permalink
Merge branch 'djangoindia:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
prakkhar03 authored Dec 10, 2024
2 parents 8fcb1b9 + 15dcf04 commit b7b682d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='event',
name='end_date',
field=models.DateTimeField(blank=True, null=True, validators=[djangoindia.db.models.event.validate_future_date]),
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='event',
name='start_date',
field=models.DateTimeField(blank=True, null=True, validators=[djangoindia.db.models.event.validate_future_date]),
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='eventregistration',
Expand All @@ -71,7 +71,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='event',
name='registration_end_date',
field=models.DateTimeField(blank=True, null=True, validators=[djangoindia.db.models.event.validate_future_date]),
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='eventregistration',
Expand Down
19 changes: 3 additions & 16 deletions backend/djangoindia/db/models/event.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
from cabinet.models import Folder

from django.core.exceptions import ValidationError
from django.db import models
from django.utils import timezone
from django.utils.text import slugify

from .base import BaseModel
from .volunteer import Volunteer


def validate_future_date(value):
if value <= timezone.now():
raise ValidationError("Date must be in the future.")


class Event(BaseModel):
class EventModes(models.TextChoices):
IN_PERSON = "in_person"
Expand All @@ -26,15 +19,9 @@ class EventModes(models.TextChoices):
venue = models.TextField(default="TBA", null=True, blank=True)
city = models.CharField(max_length=255, default="TBA", null=True, blank=True)
venue_map_link = models.TextField(null=True, blank=True)
start_date = models.DateTimeField(
null=True, blank=True, validators=[validate_future_date]
)
end_date = models.DateTimeField(
null=True, blank=True, validators=[validate_future_date]
)
registration_end_date = models.DateTimeField(
null=True, blank=True, validators=[validate_future_date]
)
start_date = models.DateTimeField(null=True, blank=True)
end_date = models.DateTimeField(null=True, blank=True)
registration_end_date = models.DateTimeField(null=True, blank=True)
event_mode = models.CharField(
max_length=20, choices=EventModes.choices, default=EventModes.IN_PERSON
)
Expand Down

0 comments on commit b7b682d

Please sign in to comment.