Skip to content

Commit

Permalink
feat: [ACI-869] remove effect property from requirement (#106)
Browse files Browse the repository at this point in the history
* feat: [ACI-869] remove effect property from requirement

* fix: [ACI-869] remove effect completely from model

---------

Co-authored-by: Andrii <andrii.hantkovskyi@raccoongang.com>
  • Loading branch information
andrii-hantkovskyi and Andrii authored Apr 6, 2024
1 parent 3ad3337 commit d872d34
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
4 changes: 0 additions & 4 deletions credentials/apps/badges/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def get_readonly_fields(self, request, obj=None):
readonly_fields.extend([
"template",
"event_type",
"effect",
"description",
])
return readonly_fields
Expand Down Expand Up @@ -158,7 +157,6 @@ class BadgeRequirementAdmin(admin.ModelAdmin):
"id",
"template",
"event_type",
"effect",
]
list_display_links = (
"id",
Expand All @@ -167,7 +165,6 @@ class BadgeRequirementAdmin(admin.ModelAdmin):
list_filter = [
"template",
"event_type",
"effect",
]


Expand All @@ -177,7 +174,6 @@ def get_readonly_fields(self, request, obj=None):
readonly_fields.extend([
"template",
"event_type",
"effect",
"description",
])
return readonly_fields
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.20 on 2024-04-05 14:02

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('badges', '0006_auto_20240403_1424'),
]

operations = [
migrations.RemoveField(
model_name='badgerequirement',
name='effect',
),
]
7 changes: 0 additions & 7 deletions credentials/apps/badges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class BadgeRequirement(models.Model):
To achieve "OR" processing logic for 2 requirement one must group them (put identical group ID).
"""

EFFECTS = Choices("award", "revoke")
EVENT_TYPES = Choices(*settings.BADGES_CONFIG['events'])

template = models.ForeignKey(
Expand All @@ -130,12 +129,6 @@ class BadgeRequirement(models.Model):
'Public signal type. Use namespaced types, e.g: "org.openedx.learning.student.registration.completed.v1"'
),
)
effect = models.CharField(
max_length=32,
choices=EFFECTS,
default=EFFECTS.award,
help_text=_("Defines how this requirement contributes to badge earning."),
)
description = models.TextField(
null=True, blank=True, help_text=_("Provide more details if needed.")
)
Expand Down
7 changes: 0 additions & 7 deletions credentials/apps/badges/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def setUp(self):
self.requirement = BadgeRequirement.objects.create(
template=self.badge_template,
event_type="org.openedx.learning.course.passing.status.updated.v1",
effect="award",
description="Test description",
)

Expand Down Expand Up @@ -50,19 +49,16 @@ def test_multiple_requirements_for_badgetemplate(self):
self.requirement1 = BadgeRequirement.objects.create(
template=self.badge_template,
event_type="org.openedx.learning.course.passing.status.updated.v1",
effect="award",
description="Test description",
)
self.requirement2 = BadgeRequirement.objects.create(
template=self.badge_template,
event_type="org.openedx.learning.course.passing.status.updated.v1",
effect="revoke",
description="Test description",
)
self.requirement3 = BadgeRequirement.objects.create(
template=self.badge_template,
event_type="org.openedx.learning.ccx.course.passing.status.updated.v1",
effect="award",
description="Test description",
)

Expand All @@ -77,19 +73,16 @@ def test_multiple_requirements_for_credlybadgetemplate(self):
self.requirement1 = BadgeRequirement.objects.create(
template=self.credlybadge_template,
event_type="org.openedx.learning.ccx.course.passing.status.updated.v1",
effect="award",
description="Test description",
)
self.requirement2 = BadgeRequirement.objects.create(
template=self.credlybadge_template,
event_type="org.openedx.learning.ccx.course.passing.status.updated.v1",
effect="revoke",
description="Test description",
)
self.requirement3 = BadgeRequirement.objects.create(
template=self.credlybadge_template,
event_type="org.openedx.learning.course.passing.status.updated.v1",
effect="award",
description="Test description",
)

Expand Down
5 changes: 2 additions & 3 deletions credentials/apps/badges/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ def test_discovery_eventtype_related_requirements(self):
self.requirements = []
self.requirements.append(
BadgeRequirement.objects.create(template=self.badge_template, event_type=self.COURSE_PASSING_EVENT,
effect="award", description="Test course passing award description"))
description="Test course passing award description"))
self.requirements.append(
BadgeRequirement.objects.create(template=self.badge_template, event_type=self.CCX_COURSE_PASSING_EVENT,
effect="award", description="Test ccx course passing award description"))
description="Test ccx course passing award description"))
self.requirements.append(
BadgeRequirement.objects.create(template=self.badge_template, event_type=self.CCX_COURSE_PASSING_EVENT,
effect="revoke",
description="Test ccx course passing revoke description"))
course_passing_requirements = discover_requirements(event_type=self.COURSE_PASSING_EVENT)
ccx_course_passing_requirements = discover_requirements(event_type=self.CCX_COURSE_PASSING_EVENT)
Expand Down

0 comments on commit d872d34

Please sign in to comment.