Skip to content

Commit

Permalink
feat: remove changing state after revocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo-kh committed Jan 13, 2025
1 parent 0a7f487 commit c366335
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion credentials/apps/badges/issuers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
from credentials.apps.credentials.issuers import AbstractCredentialIssuer


REVOCATION_STATES = {
CredlyBadge: CredlyBadge.STATES.revoked,
AccredibleBadge: AccredibleBadge.STATES.expired,
}


class BadgeTemplateIssuer(AbstractCredentialIssuer):
"""
Issues BadgeTemplate credentials to users.
Expand Down Expand Up @@ -76,14 +82,17 @@ def issue_credential(
UserCredential
"""

user_credential, __ = self.issued_user_credential_type.objects.update_or_create(
user_credential, __ = self.issued_user_credential_type.objects.get_or_create(
username=username,
credential_content_type=ContentType.objects.get_for_model(credential),
credential_id=credential.id,
defaults={
"status": status,
},
)
if not user_credential.state == REVOCATION_STATES.get(self.issued_user_credential_type):
user_credential.status = status
user_credential.save()

self.set_credential_attributes(user_credential, attributes)
self.set_credential_date_override(user_credential, date_override)
Expand Down
1 change: 1 addition & 0 deletions credentials/apps/badges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ class CredlyBadge(UserCredential):
STATES.pending,
STATES.accepted,
STATES.rejected,
STATES.revoked,
}

state = StatusField(
Expand Down

0 comments on commit c366335

Please sign in to comment.