def download_index(request, domain, app_id): """ A landing page, mostly for debugging, that has links the jad and jar as well as all the resource files that will end up zipped into the jar. """ files = [] try: files = source_files(request.app) except Exception: messages.error( request, _( "We were unable to get your files " "because your Application has errors. " "Please click <strong>Make New Version</strong> " "for feedback on how to fix these errors." ), extra_tags='html' ) built_versions = get_all_built_app_ids_and_versions(domain, request.app.copy_of) return render(request, "app_manager/download_index.html", { 'app': request.app, 'files': [{'name': f[0], 'source': f[1]} for f in files], 'supports_j2me': request.app.build_spec.supports_j2me(), 'built_versions': [{ 'app_id': app_id, 'build_id': build_id, 'version': version, 'comment': comment, } for app_id, build_id, version, comment in built_versions] })
def handle(self, domain=None, app_id=None, dry_run=False, ignore_deleted=False, verbose=False, **options): self.dry_run = dry_run if verbose: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.ERROR) if domain and app_id: app = get_app( domain, app_id) # Sanity check, will 404 if domain doesn't match assert (app.doc_type == 'LinkedApplication' or app.doc_type == 'LinkedApplication-Deleted') app_ids = set([ v.build_id for v in get_all_built_app_ids_and_versions(domain, app_id) ]) app_ids.add(app_id) # in case linked app has no builds yet else: app_ids = get_doc_ids_by_class(LinkedApplication) if not ignore_deleted: app_ids += get_deleted_doc_ids_by_class(LinkedApplication) iter_update(LinkedApplication.get_db(), self._add_overrides_for_build, with_progress_bar(app_ids), chunksize=1)
def _get_app_build_ids_to_process(domain, last_app_versions): app_build_verions = get_all_built_app_ids_and_versions(domain) # Filter by current app id app_build_verions = filter( lambda app_build_version: last_app_versions.get(app_build_version.app_id, -1) < app_build_version.version, app_build_verions ) # Map to all build ids return map(lambda app_build_version: app_build_version.build_id, app_build_verions)
def test_get_all_built_app_ids_and_versions_by_app(self): app_build_versions = get_all_built_app_ids_and_versions(self.domain, app_id='1234') self.assertEqual(len(app_build_versions), 1) self.assertEqual( len(filter(lambda abv: abv.app_id == '1234', app_build_versions)), 1) self.assertEqual( len(filter(lambda abv: abv.app_id != '1234', app_build_versions)), 0)
def test_get_all_built_app_ids_and_versions(self): app_build_versions = get_all_built_app_ids_and_versions(self.domain) self.assertEqual(len(app_build_versions), 3) self.assertEqual( len(filter(lambda abv: abv.app_id == '1234', app_build_versions)), 1) self.assertEqual( len( filter(lambda abv: abv.app_id == self.apps[0]._id, app_build_versions)), 2)
def test_get_all_built_app_ids_and_versions_by_app(self): app_build_versions = get_all_built_app_ids_and_versions(self.domain, app_id='1234') self.assertEqual(len(app_build_versions), 1) self.assertEqual( len([abv for abv in app_build_versions if abv.app_id == '1234']), 1) self.assertEqual( len([abv for abv in app_build_versions if abv.app_id != '1234']), 0)
def _find_build_id(self): # find build id if version specified if self.version: from corehq.apps.app_manager.dbaccessors import get_all_built_app_ids_and_versions built_app_ids = get_all_built_app_ids_and_versions( self.domain, self.app_id) for app_built_version in built_app_ids: if app_built_version.version == self.version: return app_built_version.build_id raise Exception("Build for version requested not found") else: return self.app_id
def test_get_all_built_app_ids_and_versions(self): app_build_versions = get_all_built_app_ids_and_versions(self.domain) self.assertEqual(len(app_build_versions), 3) self.assertEqual( len([abv for abv in app_build_versions if abv.app_id == '1234']), 1) self.assertEqual( len([ abv for abv in app_build_versions if abv.app_id == self.apps[0]._id ]), 2)
def download_index(request, domain, app_id): """ A landing page, mostly for debugging, that has links the jad and jar as well as all the resource files that will end up zipped into the jar. """ files = defaultdict(list) try: for file_ in source_files(request.app): form_filename = re.search('modules-(\d+)\/forms-(\d+)', file_[0]) if form_filename: module_id, form_id = form_filename.groups() module = request.app.get_module(module_id) form = module.get_form(form_id) section_name = "m{} - {}".format( module_id, ", ".join([ "({}) {}".format(lang, name) for lang, name in six.iteritems(module.name) ])) files[section_name].append({ 'name': file_[0], 'source': file_[1], 'readable_name': "f{} - {}".format( form_id, ", ".join([ "({}) {}".format(lang, name) for lang, name in six.iteritems(form.name) ])), }) else: files[None].append({ 'name': file_[0], 'source': file_[1], 'readable_name': None, }) except Exception: messages.error(request, _("We were unable to get your files " "because your Application has errors. " "Please click <strong>Make New Version</strong> " "for feedback on how to fix these errors."), extra_tags='html') built_versions = get_all_built_app_ids_and_versions( domain, request.app.copy_of) enabled_build_profiles = [] if toggles.RELEASE_BUILDS_PER_PROFILE.enabled(domain): enabled_build_profiles = get_enabled_build_profiles_for_version( request.app.get_id, request.app.version) return render( request, "app_manager/download_index.html", { 'app': request.app, 'files': OrderedDict(sorted(six.iteritems(files), key=lambda x: x[0])), 'supports_j2me': request.app.build_spec.supports_j2me(), 'built_versions': [{ 'app_id': _app_id, 'build_id': build_id, 'version': version, 'comment': comment, } for _app_id, build_id, version, comment in built_versions], 'enabled_build_profiles': enabled_build_profiles })
def test_get_all_built_app_ids_and_versions(self): app_build_verions = get_all_built_app_ids_and_versions(self.domain) self.assertEqual(len(app_build_verions), 3) self.assertEqual(len(filter(lambda abv: abv.app_id == "1234", app_build_verions)), 1) self.assertEqual(len(filter(lambda abv: abv.app_id == self.apps[0]._id, app_build_verions)), 2)
def download_index(request, domain, app_id): """ A landing page, mostly for debugging, that has links the jad and jar as well as all the resource files that will end up zipped into the jar. """ files = defaultdict(list) try: for file_ in source_files(request.app): form_filename = re.search('modules-(\d+)\/forms-(\d+)', file_[0]) if form_filename: module_id, form_id = form_filename.groups() module = request.app.get_module(module_id) form = module.get_form(form_id) section_name = "m{} - {}".format( module_id, ", ".join(["({}) {}".format(lang, name) for lang, name in six.iteritems(module.name)]) ) files[section_name].append({ 'name': file_[0], 'source': file_[1], 'readable_name': "f{} - {}".format( form_id, ", ".join(["({}) {}".format(lang, name) for lang, name in six.iteritems(form.name)]) ), }) else: files[None].append({ 'name': file_[0], 'source': file_[1], 'readable_name': None, }) except Exception: messages.error( request, _( "We were unable to get your files " "because your Application has errors. " "Please click <strong>Make New Version</strong> " "for feedback on how to fix these errors." ), extra_tags='html' ) built_versions = get_all_built_app_ids_and_versions(domain, request.app.copy_of) enabled_build_profiles = [] if toggles.RELEASE_BUILDS_PER_PROFILE.enabled(domain): enabled_build_profiles = get_enabled_build_profiles_for_version(request.app.get_id, request.app.version) return render(request, "app_manager/download_index.html", { 'app': request.app, 'files': OrderedDict(sorted(six.iteritems(files), key=lambda x: x[0])), 'supports_j2me': request.app.build_spec.supports_j2me(), 'built_versions': [{ 'app_id': _app_id, 'build_id': build_id, 'version': version, 'comment': comment, } for _app_id, build_id, version, comment in built_versions], 'enabled_build_profiles': enabled_build_profiles })