'Update `status`, `latest_version` and `latest_public_version`
properties depending on the `status` on the ExtensionVersion
instances attached to this Extension.'

def update_status_according_to_versions(self):

    if self.is_blocked():
        raise BlockedExtensionError
    versions = self.versions.without_deleted()
    if versions.public().exists():
        self.update(status=STATUS_PUBLIC)
    elif versions.pending().exists():
        self.update(status=STATUS_PENDING)
    elif versions.rejected().exists():
        self.update(status=STATUS_REJECTED)
    else:
        self.update(status=STATUS_NULL)
    try:
        if self.latest_version:
            del self.latest_version
    except ExtensionVersion.DoesNotExist:
        pass
    try:
        if self.latest_public_version:
            del self.latest_public_version
    except ExtensionVersion.DoesNotExist:
        pass
