'Assign an identifier to the provided certificate data.
If the caller did not provide an identifier, we autogenerate a unique one for them
In addition, we check the certificate\'s signatories and ensure they also have unique ids'

@staticmethod
def assign_id(course, certificate_data, certificate_id=None):

    used_ids = CertificateManager.get_used_ids(course)
    if certificate_id:
        certificate_data['id'] = int(certificate_id)
    else:
        certificate_data['id'] = generate_int_id(CERTIFICATE_MINIMUM_ID, MYSQL_MAX_INT, used_ids)
    for (index, signatory) in enumerate(certificate_data['signatories']):
        if (signatory and (not signatory.get('id', False))):
            signatory['id'] = generate_int_id(used_ids=used_ids)
        used_ids.append(signatory['id'])
    return certificate_data
