misc: do not update Issuer uselessly (#86976)
gitea/django-mellon/pipeline/head This commit looks good
Details
gitea/django-mellon/pipeline/head This commit looks good
Details
This commit is contained in:
parent
244ca2abcd
commit
f41fd2cf08
|
@ -19,12 +19,18 @@ from . import models, utils
|
|||
def get_issuer(entity_id):
|
||||
idp = utils.get_idp(entity_id)
|
||||
slug = idp.get('SLUG')
|
||||
issuer = None
|
||||
if slug:
|
||||
issuer = models.Issuer.objects.filter(slug=slug).first()
|
||||
# migrate issuer entity_id based on the slug
|
||||
if issuer and issuer.entity_id != entity_id:
|
||||
issuer.entity_id = entity_id
|
||||
issuer.save()
|
||||
if not slug or not issuer:
|
||||
issuer, _ = models.Issuer.objects.update_or_create(entity_id=entity_id, defaults={'slug': slug})
|
||||
|
||||
if issuer is None:
|
||||
issuer, _ = models.Issuer.objects.get_or_create(entity_id=entity_id)
|
||||
# migrate issuer slug based on the entity_id
|
||||
if issuer.slug != slug:
|
||||
issuer.slug = slug
|
||||
issuer.save()
|
||||
return issuer
|
||||
|
|
Loading…
Reference in New Issue