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

feat: [ACI-461] define CredlyBadge credential model #80

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from credentials.apps.badges.toggles import is_badges_enabled

from .forms import CredlyOrganizationAdminForm
from .models import CredlyBadgeTemplate, CredlyOrganization
from .models import CredlyBadge, CredlyBadgeTemplate, CredlyOrganization
from .utils import sync_badge_templates_for_organization


Expand Down Expand Up @@ -63,6 +63,29 @@ class CredlyBadgeTemplateAdmin(admin.ModelAdmin):
]


class CredlyBadgeAdmin(admin.ModelAdmin):
"""
Credly badge admin setup.
"""
list_display = (
"username",
"state",
"uuid",
)
list_filter = (
"state",
)
search_fields = (
"username",
"uuid",
)
readonly_fields = (
"state",
"uuid",
)


if is_badges_enabled():
admin.site.register(CredlyOrganization, CredlyOrganizationAdmin)
admin.site.register(CredlyBadgeTemplate, CredlyBadgeTemplateAdmin)
admin.site.register(CredlyBadge, CredlyBadgeAdmin)
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',),
),
]
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',
),
]
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',
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ class CredlyBadge(UserCredential):
"""
Earned Credly badge template for user.
"""
# TODO: check if we can fetch pii for username from LMS for badge issuing?

STATES = Choices("created", "no_response", "error", "pending", "accepted", "rejected", "revoked")

state = StatusField(
choices_name="STATES",
help_text=_("Credly badge issuing state"),
default=STATES.created,
)
Loading