Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event recording url to register workshops #1542

24 changes: 24 additions & 0 deletions breathecode/events/migrations/0062_event_recording_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.4 on 2025-01-28 12:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("events", "0061_event_is_public"),
]

operations = [
migrations.AddField(
model_name="event",
name="recording_url",
field=models.URLField(
blank=True,
default=None,
help_text="This will be the URL of the workshop's recording, added once it's finished",
max_length=255,
null=True,
),
),
]
8 changes: 8 additions & 0 deletions breathecode/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ def __init__(self, *args, **kwargs):
help_text="This URL should have the URL of the meeting if it is an online event, if it's not online it should be empty.",
)

recording_url = models.URLField(
max_length=255,
null=True,
blank=True,
default=None,
help_text="This will be the URL of the workshop's recording, added once it's finished",
)

starting_at = models.DateTimeField(blank=False)
ending_at = models.DateTimeField(
blank=False, help_text="This field contains the value of when the event is supposed to be finished."
Expand Down
15 changes: 15 additions & 0 deletions breathecode/events/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class EventSmallSerializer(EventTinySerializer):
author = UserSerializer(required=False)
asset = serpy.MethodField()
is_public = serpy.Field()
recording_url = serpy.Field()

def get_asset(self, obj):
if obj.asset_slug is not None:
Expand Down Expand Up @@ -247,6 +248,7 @@ class EventSmallSerializerNoAcademy(serpy.Serializer):
eventbrite_sync_description = serpy.Field()
tags = serpy.Field()
is_public = serpy.Field()
recording_url = serpy.Field()


class EventPublicBigSerializer(EventSmallSerializer):
Expand Down Expand Up @@ -299,6 +301,7 @@ class AcademyEventSmallSerializer(serpy.Serializer):
free_for_all = serpy.Field()
asset = serpy.MethodField()
is_public = serpy.Field()
recording_url = serpy.Field()

def get_asset(self, obj):
if obj.asset_slug is not None:
Expand Down Expand Up @@ -363,6 +366,17 @@ def validate(self, data: dict[str, Any]):

academy = self.context.get("academy_id")

recording_url = data.get("recording_url")
if recording_url and not recording_url.startswith(("http://", "https://")):
raise ValidationException(
translation(
self.context.get("lang", "en"),
en="The recording URL must be a valid URL starting with http:// or https://",
es="La URL de la grabación debe ser una URL válida que comience con http:// o https://",
slug="invalid-recording-url",
)
)

if ("tags" not in data and self.instance.tags == "") or ("tags" in data and data["tags"] == ""):
raise ValidationException(
translation(
Expand Down Expand Up @@ -457,6 +471,7 @@ class EventPUTSerializer(serializers.ModelSerializer):
ending_at = serializers.DateTimeField(required=False)
online_event = serializers.BooleanField(required=False)
status = serializers.CharField(required=False)
recording_url = serializers.URLField(required=False)

class Meta:
model = Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def test_update_or_create_event__with_academy(self):
"free_for_all": False,
"uuid": uuid,
"is_public": True,
"recording_url": None,
}

self.assertEqual(self.bc.database.list_of("events.Event"), [kwargs])
Expand Down Expand Up @@ -294,6 +295,7 @@ def test_update_or_create_event__with_event(self):
"free_for_all": False,
"uuid": uuid,
"is_public": True,
"recording_url": None,
}

self.assertEqual(self.bc.database.list_of("events.Event"), [kwargs])
1 change: 1 addition & 0 deletions breathecode/events/tests/mixins/new_events_tests_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def check_all_academy_events(self, models=None):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
for model in models
]
Expand Down
9 changes: 9 additions & 0 deletions breathecode/events/tests/urls/tests_academy_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def post_serializer(data={}):
"live_stream_url": None,
"host_user": None,
"is_public": True,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -97,6 +98,7 @@ def event_table(data={}):
"sync_with_eventbrite": False,
"currency": "",
"is_public": True,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -195,6 +197,7 @@ def test_all_academy_events_correct_city(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]

Expand Down Expand Up @@ -269,6 +272,7 @@ def test_all_academy_events_correct_country(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]

Expand Down Expand Up @@ -343,6 +347,7 @@ def test_all_academy_events_correct_zip_code(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]

Expand Down Expand Up @@ -398,6 +403,7 @@ def test_all_academy_events_upcoming(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]

Expand Down Expand Up @@ -687,6 +693,7 @@ def test_all_academy_events__post_with_event_is_public_true(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]
self.assertEqual(json, expected)
Expand Down Expand Up @@ -741,6 +748,7 @@ def test_all_academy_events__post_with_event_is_public_false(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]
self.assertEqual(json, expected)
Expand Down Expand Up @@ -794,6 +802,7 @@ def test_all_academy_events__post_with_event_is_public_empty(self):
"eventbrite_sync_description": model["event"].eventbrite_sync_description,
"eventbrite_sync_status": model["event"].eventbrite_sync_status,
"is_public": model["event"].is_public,
"recording_url": model["event"].recording_url,
}
]

Expand Down
6 changes: 6 additions & 0 deletions breathecode/events/tests/urls/tests_academy_event_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_serializer(event, academy, asset=None, data={}):
"eventbrite_sync_description": event.eventbrite_sync_description,
"asset": asset_serializer(asset) if asset else None,
"is_public": event.is_public,
"recording_url": event.recording_url,
**data,
}

Expand Down Expand Up @@ -218,6 +219,7 @@ def test_academy_event_id__put__is_public_true(self):
"free_for_all": False,
"uuid": str(uuid),
"is_public": True,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -316,6 +318,7 @@ def test_academy_event_id__put__is_public_false(self):
"free_for_all": False,
"uuid": str(uuid),
"is_public": False,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -666,6 +669,7 @@ def test_academy_cohort_id__put(self):
"free_for_all": False,
"uuid": str(uuid),
"is_public": True,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -900,6 +904,7 @@ def test_academy_cohort_id__put__with_tags(self):
"free_for_all": False,
"uuid": str(uuid),
"is_public": True,
"recording_url": None,
**data,
}

Expand Down Expand Up @@ -1001,6 +1006,7 @@ def test_academy_cohort_id__put__with_duplicate_tags(self):
"free_for_all": False,
"uuid": str(uuid),
"is_public": True,
"recording_url": None,
**data,
}

Expand Down
1 change: 1 addition & 0 deletions breathecode/events/tests/urls/tests_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def serialize_event(event):
"ended_at": (event.ended_at.strftime("%Y-%m-%dT%H:%M:%S.%f") + "Z" if event.ended_at else None),
"online_event": event.online_event,
"is_public": event.is_public,
"recording_url": event.recording_url,
"venue": (
None
if not event.venue
Expand Down
1 change: 1 addition & 0 deletions breathecode/events/tests/urls/tests_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def get_serializer(
"url": event.url,
"venue": event.venue,
"is_public": event.is_public,
"recording_url": event.recording_url,
**data,
}

Expand Down
1 change: 1 addition & 0 deletions breathecode/events/tests/urls/tests_me_event_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def get_serializer(
"url": event.url,
"venue": event.venue,
"is_public": event.is_public,
"recording_url": event.recording_url,
**data,
}

Expand Down
6 changes: 6 additions & 0 deletions breathecode/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def get_events(request):
elif is_public == "false":
lookup["is_public"] = False

recording_url = request.GET.get("recording_url", None)
if recording_url == "true":
lookup["recording_url"] = True
elif recording_url == "false":
lookup["recording_url"] = False

if "technologies" in request.GET:
values = request.GET.get("technologies").split(",")
tech_query = Q()
Expand Down
2 changes: 1 addition & 1 deletion breathecode/services/eventbrite/actions/event_created.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

def event_created(self, webhook, payload: dict):
# lazyload to fix circular import
from breathecode.events.models import Organization
from breathecode.events.actions import update_or_create_event
from breathecode.events.models import Organization

org = Organization.objects.filter(id=webhook.organization_id).first()

Expand Down
Loading