'Retrieves the latest PUBLIC version of an addon.'

def get_public_version(self):

    if (self.status not in mkt.WEBAPPS_APPROVED_STATUSES):
        return None
    try:
        return self.versions.filter(files__status=mkt.STATUS_PUBLIC).extra(where=[('\n                                                                                                NOT    EXISTS    (\n                                                                                                                SELECT    1    FROM    versions    as    v2\n                                                                                                                INNER    JOIN    files    AS    f2    ON    (f2.version_id    =    v2.id)\n                                                                                                                WHERE    v2.id    =    versions.id\n                                                                                                                AND    f2.status    !=    %s)' % mkt.STATUS_PUBLIC)])[0]
    except (IndexError, Version.DoesNotExist):
        return None
