Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/breatheco-de/apiv2
Browse files Browse the repository at this point in the history
  • Loading branch information
alesanchezr committed Feb 7, 2025
2 parents 5084a2f + 03f0fde commit 311adb8
Show file tree
Hide file tree
Showing 27 changed files with 477 additions and 169 deletions.
2 changes: 1 addition & 1 deletion breathecode/activity/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_attendancy_log_per_cohort_user(cohort_user_id: int):
logger.info("History log saved")


@task(bind=True, priority=TaskPriority.ACADEMY.value)
@task(bind=True, priority=TaskPriority.ACTIVITY.value)
def upload_activities(self, task_manager_id: int, **_):

def extract_data():
Expand Down
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
3 changes: 2 additions & 1 deletion breathecode/marketing/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ def register_new_lead(form_entry=None):
tags = []
if ac_academy.crm_vendor == "BREVO":
# brevo uses slugs instead of ID for automations
automations = automations.values_list("slug", flat=True)
if hasattr(automations, "values_list"):
automations = automations.values_list("slug", flat=True)
if "tags" in form_entry and len(form_entry["tags"]) > 0:
raise Exception("Brevo CRM does not support tags, please remove them from the contact payload")
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 5.1.5 on 2025-02-06 00:24

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("marketing", "0093_alter_coursetranslation_heading"),
]

operations = [
migrations.AlterField(
model_name="formentry",
name="course",
field=models.CharField(blank=True, default=None, max_length=70, null=True),
),
migrations.AlterField(
model_name="formentry",
name="first_name",
field=models.CharField(blank=True, default="", max_length=150),
),
migrations.AlterField(
model_name="formentry",
name="lead_generation_app",
field=models.ForeignKey(
blank=True,
default=None,
help_text="Other apps can send leads to breathecode but they need to be registered here",
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="marketing.leadgenerationapp",
),
),
]
5 changes: 3 additions & 2 deletions breathecode/marketing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def __init__(self, *args, **kwargs):
max_length=20, null=True, default=None, blank=True, help_text="Active Campaign Deal ID"
)

first_name = models.CharField(max_length=150, default="")
first_name = models.CharField(max_length=150, default="", blank=True)
last_name = models.CharField(max_length=150, default="", blank=True)
email = models.CharField(max_length=150, null=True, default=None, blank=True)

Expand All @@ -363,7 +363,7 @@ def __init__(self, *args, **kwargs):
validators=[phone_regex], max_length=17, blank=True, null=True, default=None
) # validators should be a list

course = models.CharField(max_length=70, null=True, default=None)
course = models.CharField(max_length=70, null=True, default=None, blank=True)
client_comments = models.CharField(max_length=250, blank=True, null=True, default=None)
location = models.CharField(max_length=70, blank=True, null=True, default=None)
language = models.CharField(max_length=2, default="en")
Expand Down Expand Up @@ -443,6 +443,7 @@ def __init__(self, *args, **kwargs):
on_delete=models.CASCADE,
null=True,
default=None,
blank=True,
help_text="Other apps can send leads to breathecode but they need to be registered here",
)

Expand Down
Loading

0 comments on commit 311adb8

Please sign in to comment.