forked from openedx/credentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aci.main' into hantkovskyi/aci-748/unconditional-badge-…
…revocation
- Loading branch information
Showing
22 changed files
with
574 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
credentials/apps/badges/distribution/credly/credly_badges/migrations/0004_credlybadge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 3.2.20 on 2024-03-20 12:30 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('credentials', '0026_alter_usercredential_credential_content_type'), | ||
('credly_badges', '0003_credlybadgetemplate_state_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CredlyBadge', | ||
fields=[ | ||
('usercredential_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='credentials.usercredential')), | ||
], | ||
options={ | ||
'get_latest_by': 'modified', | ||
'abstract': False, | ||
}, | ||
bases=('credentials.usercredential',), | ||
), | ||
] |
32 changes: 32 additions & 0 deletions
32
...tials/apps/badges/distribution/credly/credly_badges/migrations/0005_auto_20240327_1118.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 3.2.20 on 2024-03-27 11:18 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import model_utils.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('badges', '0001_initial'), | ||
('credentials', '0026_alter_usercredential_credential_content_type'), | ||
('credly_badges', '0004_credlybadge'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CredlyBadgeCredential', | ||
fields=[ | ||
('usercredential_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='credentials.usercredential')), | ||
('state', model_utils.fields.StatusField(choices=[('created', 'created'), ('no_response', 'no_response'), ('error', 'error'), ('pending', 'pending'), ('accepted', 'accepted'), ('rejected', 'rejected'), ('revoked', 'revoked')], default='created', help_text='Credly badge issuing state', max_length=100, no_check_for_status=True)), | ||
], | ||
options={ | ||
'get_latest_by': 'modified', | ||
'abstract': False, | ||
}, | ||
bases=('credentials.usercredential',), | ||
), | ||
migrations.DeleteModel( | ||
name='CredlyBadge', | ||
), | ||
] |
20 changes: 20 additions & 0 deletions
20
...ribution/credly/credly_badges/migrations/0006_rename_credlybadgecredential_credlybadge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 3.2.20 on 2024-03-27 11:46 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('credentials', '0026_alter_usercredential_credential_content_type'), | ||
('contenttypes', '0002_remove_content_type_name'), | ||
('badges', '0001_initial'), | ||
('credly_badges', '0005_auto_20240327_1118'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='CredlyBadgeCredential', | ||
new_name='CredlyBadge', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.core.exceptions import ObjectDoesNotExist | ||
|
||
from ..models import BadgeTemplate | ||
|
||
|
||
def get_badge_template_by_id(badge_template_id): | ||
try: | ||
return BadgeTemplate.objects.get(id=badge_template_id) | ||
except ObjectDoesNotExist: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.contrib.contenttypes.models import ContentType | ||
|
||
from ..models import BadgeTemplate, UserCredential | ||
|
||
|
||
def create_user_credential(username, badge_template): | ||
if not isinstance(username, str): | ||
raise ValueError("`username` must be a string") | ||
|
||
if not isinstance(badge_template, BadgeTemplate): | ||
raise TypeError("`badge_template` must be an instance of BadgeTemplate") | ||
|
||
|
||
UserCredential.objects.create( | ||
credential_content_type=ContentType.objects.get_for_model( | ||
badge_template), | ||
credential_id=badge_template.id, | ||
username=username, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
from django.dispatch import Signal | ||
|
||
""" | ||
define internal signals: | ||
- BADGE_REQUIREMENT_FULFILLED - a single specific requirement has finished; | ||
- BADGE_REQUIREMENTS_COMPLETE - all badge template requirements are finished; | ||
- BADGE_REQUIREMENTS_NOT_COMPLETE - a reason for earned badge revocation; | ||
""" | ||
|
||
from django.dispatch import Signal | ||
|
||
|
||
BADGE_PROGRESS_COMPLETE = Signal() | ||
BADGE_PROGRESS_INCOMPLETE = Signal() |
Oops, something went wrong.