def clear_app_cache(request, domain): ApplicationBase.get_db().view( 'app_manager/applications_brief', startkey=[domain], limit=1, ).all() ApplicationsTab.clear_dropdown_cache(domain, request.couch_user.get_id)
def clear_app_cache(request, domain): ApplicationBase.get_db().view('app_manager/applications_brief', startkey=[domain], limit=1, ).all() for is_active in True, False: key = make_template_fragment_key('header_tab', [ domain, None, # tab.org should be None for any non org page ApplicationsTab.view, is_active, request.couch_user.get_id, get_language(), ]) cache.delete(key)
def testAppsBrief(self): """Test that ApplicationBase can wrap the truncated version returned by applications_brief """ self.app.save() apps = ApplicationBase.get_db().view("app_manager/applications_brief", startkey=[self.domain], limit=1).all() self.assertEqual(len(apps), 1)
def has_app(domain, *args): return bool(ApplicationBase.get_db().view( 'app_manager/applications_brief', startkey=[domain], endkey=[domain, {}], limit=1 ).first())
def get_doc_ids(): for result in db.view("domain/domains", reduce=False).all(): yield result["id"] for result in ApplicationBase.get_db().view( "app_manager/applications", startkey=[None], endkey=[None, {}], reduce=False ): yield result["id"]
def get_doc_ids(): for result in db.view('domain/domains', reduce=False).all(): yield result['id'] for result in ApplicationBase.get_db().view( 'app_manager/applications', startkey=[None], endkey=[None, {}], reduce=False): yield result['id']
def testAppsBrief(self): """Test that ApplicationBase can wrap the truncated version returned by applications_brief """ self.app.save() apps = ApplicationBase.get_db().view('app_manager/applications_brief', startkey=[self.domain], limit=1, ).all() self.assertEqual(len(apps), 1)
def form_valid(self, form): db = ApplicationBase.get_db() build_jsons = db.all_docs(keys=form.build_ids, include_docs=True) docs = [] for doc in [build_json["doc"] for build_json in build_jsons.all()]: if doc.get("doc_type") in ["Application", "RemoteApp"]: doc["build_broken"] = True docs.append(doc) db.bulk_save(docs) return HttpResponse("posted!")
def form_valid(self, form): db = ApplicationBase.get_db() build_jsons = db.all_docs(keys=form.build_ids, include_docs=True) docs = [] for doc in [build_json['doc'] for build_json in build_jsons.all()]: if doc.get('doc_type') in ['Application', 'RemoteApp']: doc['build_broken'] = True docs.append(doc) db.bulk_save(docs) return HttpResponse("posted!")
def form_valid(self, form): db = ApplicationBase.get_db() build_jsons = db.all_docs(keys=form.build_ids, include_docs=True) docs = [] for doc in [build_json['doc'] for build_json in build_jsons.all()]: if doc.get('doc_type') in ['Application', 'RemoteApp']: doc['build_broken'] = True docs.append(doc) db.bulk_save(docs) return HttpResponse("posted!")
def _get_app_and_build_ids(domain, build_or_app_id): try: app_json = ApplicationBase.get_db().get(build_or_app_id) except ResourceNotFound: pass else: if domain == app_json.get('domain'): copy_of = app_json.get('copy_of') if copy_of: return copy_of, build_or_app_id return build_or_app_id, None
def all_apps_by_domain(domain): from corehq.apps.app_manager.models import ApplicationBase rows = ApplicationBase.get_db().view( 'app_manager/applications', startkey=[domain, None], endkey=[domain, None, {}], include_docs=True, ).all() for row in rows: doc = row['doc'] yield get_correct_app_class(doc).wrap(doc)
def all_apps_by_domain(domain): from corehq.apps.app_manager.models import ApplicationBase rows = ApplicationBase.get_db().view( 'app_manager/applications', startkey=[domain, None], endkey=[domain, None, {}], include_docs=True, ).all() for row in rows: doc = row['doc'] yield get_correct_app_class(doc).wrap(doc)
def _get_app_and_build_ids(domain, build_or_app_id): try: app_json = ApplicationBase.get_db().get(build_or_app_id) except ResourceNotFound: pass else: if domain == app_json.get('domain'): copy_of = app_json.get('copy_of') if copy_of: return copy_of, build_or_app_id return build_or_app_id, None
def get_cloudcare_apps(domain): result = ApplicationBase.get_db().view( 'app_manager/applications_brief', startkey=[domain], endkey=[domain, {}] ) app_docs = [row['value'] for row in result] # Note: even though cloudcare_enabled is in the value emitted by # the view, couch will not include it in the emitted value if # it's undefined. return [ app for app in app_docs if app['doc_type'] == 'Application' and app.get('cloudcare_enabled', False) ]
def clear_app_cache(request, domain): ApplicationBase.get_db().view("app_manager/applications_brief", startkey=[domain], limit=1).all() ApplicationsTab.clear_dropdown_cache(domain, request.couch_user.get_id)
def has_app(domain, *args): return bool(ApplicationBase.get_db().view('app_manager/applications_brief', startkey=[domain], endkey=[domain, {}], limit=1).first())