Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/breatheco-de/apiv2 i…
Browse files Browse the repository at this point in the history
…nto feat/event-me-new-filters
  • Loading branch information
jefer94 committed Jul 18, 2024
2 parents 34e968d + 463453f commit 44b44e1
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 272 deletions.
9 changes: 7 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
"eamodio.gitlens",
"gruntfuggly.todo-tree",
"redhat.vscode-yaml",
"bungcip.better-toml",
"ms-python.black-formatter",
"ms-python.isort",
"janisdd.vscode-edit-csv",
"tamasfe.even-better-toml",
"ms-python.flake8",
"donjayamanne.githistory",
"TabNine.tabnine-vscode",
"github.vscode-github-actions"
"ms-python.debugpy"
]
}
},
Expand Down
13 changes: 6 additions & 7 deletions breathecode/assessment/signals.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
For each signal you want other apps to be able to receive, you have to
declare a new variable here like this:
"""
"""For each signal you want other apps to be able to receive, you have to declare a new variable here like this:"""

from django import dispatch
from task_manager.django.dispatch import Emisor

assessment_updated = dispatch.Signal()
userassessment_status_updated = dispatch.Signal()
emisor = Emisor("breathecode.assessment")

assessment_updated = emisor.signal("assessment_updated")
userassessment_status_updated = emisor.signal("userassessment_status_updated")
27 changes: 25 additions & 2 deletions breathecode/assignments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
from breathecode.services.learnpack import LearnPack

from .actions import sync_student_tasks
from .models import AssignmentTelemetry, CohortProxy, FinalProject, LearnPackWebhook, Task, UserAttachment, UserProxy
from .models import (
AssignmentTelemetry,
CohortProxy,
FinalProject,
LearnPackWebhook,
RepositoryDeletionOrder,
RepositoryWhiteList,
Task,
UserAttachment,
UserProxy,
)

# Register your models here.
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -125,7 +135,6 @@ def async_process_hook(modeladmin, request, queryset):
def process_hook(modeladmin, request, queryset):
# stay this here for use the poor mocking system
for hook in queryset.all().order_by("created_at"):
print(f"Procesing hook: {hook.id}")
client = LearnPack()
try:
client.execute_action(hook.id)
Expand Down Expand Up @@ -166,3 +175,17 @@ def from_status(s):
return ""

return format_html(f"<div><span class='badge'>{obj.status}</span></div><small>{obj.status_text}</small>")


@admin.register(RepositoryDeletionOrder)
class RepositoryDeletionOrderAdmin(admin.ModelAdmin):
list_display = ("provider", "status", "repository_user", "repository_name")
search_fields = ["repository_user", "repository_name"]
list_filter = ["provider", "status"]


@admin.register(RepositoryWhiteList)
class RepositoryWhiteListAdmin(admin.ModelAdmin):
list_display = ("provider", "repository_user", "repository_name")
search_fields = ["repository_user", "repository_name"]
list_filter = ["provider"]
15 changes: 7 additions & 8 deletions breathecode/assignments/signals.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""
For each signal you want other apps to be able to receive, you have to
declare a new variable here like this:
"""
"""For each signal you want other apps to be able to receive, you have to declare a new variable here like this:"""

from django import dispatch
from task_manager.django.dispatch import Emisor

assignment_created = dispatch.Signal()
assignment_status_updated = dispatch.Signal()
revision_status_updated = dispatch.Signal()
emisor = Emisor("breathecode.assignments")

assignment_created = emisor.signal("assignment_created")
assignment_status_updated = emisor.signal("assignment_status_updated")
revision_status_updated = emisor.signal("revision_status_updated")
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test__post__no_consumables(bc: Breathecode, client: APIClient, patch_post):
},
service={
"type": "VOID",
"slug": "add_code_review",
"consumer": "ADD_CODE_REVIEW",
},
)
client.force_authenticate(model.user)
Expand Down Expand Up @@ -290,7 +290,7 @@ def test__post__no_tasks(bc: Breathecode, client: APIClient, patch_post):
app={"slug": "rigobot", "app_url": bc.fake.url()},
service={
"type": "VOID",
"slug": "add_code_review",
"consumer": "ADD_CODE_REVIEW",
},
)
client.force_authenticate(model.user)
Expand Down Expand Up @@ -333,7 +333,7 @@ def test__post__no_github_accounts(bc: Breathecode, client: APIClient, patch_pos
},
service={
"type": "VOID",
"slug": "add_code_review",
"consumer": "ADD_CODE_REVIEW",
},
)
client.force_authenticate(model.user)
Expand Down Expand Up @@ -378,7 +378,7 @@ def test__post__auth(bc: Breathecode, client: APIClient, patch_post):
consumable=1,
service={
"type": "VOID",
"slug": "add_code_review",
"consumer": "ADD_CODE_REVIEW",
},
)
client.force_authenticate(model.user)
Expand Down Expand Up @@ -474,7 +474,7 @@ def test__post__auth__no_saas__finantial_status_no_late(
consumable=1,
service={
"type": "VOID",
"slug": "add_code_review",
"consumer": "ADD_CODE_REVIEW",
},
academy=academy,
cohort=cohort,
Expand Down Expand Up @@ -548,7 +548,7 @@ def test__post__auth__no_saas__finantial_status_late(bc: Breathecode, client: AP
consumable=1,
service={
"type": "VOID",
"slug": "add_code_review",
"slug": "ADD_CODE_REVIEW",
},
cohort_user=cohort_user,
cohort=cohort,
Expand Down
16 changes: 9 additions & 7 deletions breathecode/authenticate/signals.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from django import dispatch
from task_manager.django.dispatch import Emisor

emisor = Emisor("breathecode.authenticate")

# UserInvite accepted
invite_status_updated = dispatch.Signal()
invite_status_updated = emisor.signal("invite_status_updated")
# ProfileAcademy accepted
academy_invite_accepted = dispatch.Signal()
profile_academy_saved = dispatch.Signal()
academy_invite_accepted = emisor.signal("academy_invite_accepted")
profile_academy_saved = emisor.signal("profile_academy_saved")

# post_delete and post_save for User, ProfileAcademy and MentorProfileMentorProfile
user_info_updated = dispatch.Signal()
user_info_deleted = dispatch.Signal()
user_info_updated = emisor.signal("user_info_updated")
user_info_deleted = emisor.signal("user_info_deleted")

cohort_user_deleted = dispatch.Signal()
cohort_user_deleted = emisor.signal("cohort_user_deleted")
36 changes: 18 additions & 18 deletions breathecode/events/tests/urls/tests_me_event_id_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_no_consumables(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__bypass_with_feature_flag__live_event_not_found(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
model = self.bc.database.create(user=1, service=service, token=1)
querystring = self.bc.format.to_querystring({"token": model.token.key})

Expand Down Expand Up @@ -216,7 +216,7 @@ def test_no_consumables__bypass_with_feature_flag__live_event_not_found(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__bypass_with_feature_flag__with_live_event__cohort_without_url(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
delta = timedelta(seconds=random.randint(1, 1000))
event = {"starting_at": UTC_NOW - delta, "ending_at": UTC_NOW + delta}
event_type = {"icon_url": self.bc.fake.url()}
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_no_consumables__bypass_with_feature_flag__with_live_event__cohort_witho
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__bypass_with_feature_flag__with_live_event__cohort_with_url(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_no_consumables__bypass_with_feature_flag__with_live_event__cohort_with_
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__it_try_to_consume__live_event_not_found(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
model = self.bc.database.create(user=1, service=service, token=1)
querystring = self.bc.format.to_querystring({"token": model.token.key})

Expand Down Expand Up @@ -381,7 +381,7 @@ def test_no_consumables__it_try_to_consume__live_event_not_found(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__it_try_to_consume__with_live_event__cohort_without_url(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
delta = timedelta(seconds=random.randint(1, 1000))
event = {"starting_at": UTC_NOW - delta, "ending_at": UTC_NOW + delta}
event_type = {"icon_url": self.bc.fake.url()}
Expand Down Expand Up @@ -439,7 +439,7 @@ def test_no_consumables__it_try_to_consume__with_live_event__cohort_without_url(
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_no_consumables__it_try_to_consume__with_live_event__cohort_with_url(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -529,7 +529,7 @@ def test_no_consumables__it_try_to_consume__with_live_event__cohort_with_url(sel
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_past(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -605,7 +605,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_past(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_future(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -713,7 +713,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future(self
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__academy_no_saas__non_free1(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -825,7 +825,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__aca
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__academy_no_saas__non_free2(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -939,7 +939,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__aca
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_is_free_with_cohort_users_saas__cohort(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}

online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def test_is_free_with_cohort_users_saas__cohort(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_is_free_with_cohort_users_saas__academy(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1160,7 +1160,7 @@ def test_is_free_with_cohort_users_saas__academy(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_is_free_with_cohort_users_no_saas__cohort(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1255,7 +1255,7 @@ def test_is_free_with_cohort_users_no_saas__cohort(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_is_free_with_cohort_users_no_saas__academy(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1346,7 +1346,7 @@ def test_is_free_with_cohort_users_no_saas__academy(self):
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__show_countdown(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1447,7 +1447,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__sho
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__show_countdown(self):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = self.bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1559,7 +1559,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__sho
def test__post__auth__no_saas__finantial_status_no_late(
bc: Breathecode, client: fx.Client, academy, cohort, cohort_user
):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down Expand Up @@ -1644,7 +1644,7 @@ def test__post__auth__no_saas__finantial_status_no_late(
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test__post__auth__no_saas__finantial_status_late(bc: Breathecode, client: fx.Client, academy, cohort):
service = {"slug": "event_join"}
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
event = {
Expand Down
Loading

0 comments on commit 44b44e1

Please sign in to comment.