Example #1
0
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)
Example #2
0
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)
Example #3
0
 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)
Example #4
0
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"]
Example #6
0
 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']
Example #7
0
 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)
Example #8
0
 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!")
Example #9
0
 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!")
Example #10
0
 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!")
Example #11
0
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
Example #12
0
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)
Example #13
0
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)
Example #14
0
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
Example #15
0
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)
    ]
Example #16
0
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())