def _sanitize(self, value, name, further_args): app = Apps.find_by_string(value) app_version = app.version if not app.is_installed() and not app.install_permissions_exist(): apps = Apps().get_all_apps_with_id(app.id) apps = [_app for _app in apps if not _app.install_permissions] if apps: for _app in apps: if _app.version == app_version: app = _app break else: app = sorted(apps)[-1] return app
def _sanitize(self, value, name, further_args): app = Apps.find_by_string(value) if not app: self.raise_validation_error(_("Could not find an application for %s") % (value, )) app_version = app.version if not app.is_installed() and not app.install_permissions_exist(): apps = Apps().get_all_apps_with_id(app.id) apps = [_app for _app in apps if not _app.install_permissions] if apps: for _app in apps: if _app.version == app_version: app = _app break else: app = sorted(apps)[-1] return app