예제 #1
0
def get_topic_for_doc_type(doc_type, data_source_type=None):
    from corehq.apps.change_feed import document_types
    from corehq.apps.locations.document_store import LOCATION_DOC_TYPE

    if doc_type in document_types.CASE_DOC_TYPES:
        return {
            'sql': CASE_SQL,
            'couch': CASE
        }.get(data_source_type, CASE)
    elif doc_type in all_known_formlike_doc_types():
        return {
            'sql': FORM_SQL,
            'couch': FORM
        }.get(data_source_type, FORM)
    elif doc_type in document_types.DOMAIN_DOC_TYPES:
        return DOMAIN
    elif doc_type in document_types.MOBILE_USER_DOC_TYPES:
        return COMMCARE_USER
    elif doc_type in document_types.WEB_USER_DOC_TYPES:
        return WEB_USER
    elif doc_type in document_types.GROUP_DOC_TYPES:
        return GROUP
    elif doc_type in document_types.SYNCLOG_DOC_TYPES:
        return SYNCLOG_SQL
    elif doc_type in app_doc_types():
        return APP
    elif doc_type == LOCATION_DOC_TYPE:
        return LOCATION
    elif doc_type in ALL:  # for docs that don't have a doc_type we use the Kafka topic
        return doc_type
    else:
        # at some point we may want to make this more granular
        return META  # note this does not map to the 'meta' Couch database
예제 #2
0
def get_topic_for_doc_type(doc_type,
                           data_source_type=None,
                           default_topic=None):
    from corehq.apps.change_feed import document_types
    from corehq.apps.locations.document_store import LOCATION_DOC_TYPE

    if doc_type in document_types.CASE_DOC_TYPES:
        return {'sql': CASE_SQL, 'couch': CASE}.get(data_source_type, CASE)
    elif doc_type in all_known_formlike_doc_types():
        return {'sql': FORM_SQL, 'couch': FORM}.get(data_source_type, FORM)
    elif doc_type in document_types.DOMAIN_DOC_TYPES:
        return DOMAIN
    elif doc_type in document_types.MOBILE_USER_DOC_TYPES:
        return COMMCARE_USER
    elif doc_type in document_types.WEB_USER_DOC_TYPES:
        return WEB_USER
    elif doc_type in document_types.GROUP_DOC_TYPES:
        return GROUP
    elif doc_type in document_types.SYNCLOG_DOC_TYPES:
        return SYNCLOG_SQL
    elif doc_type in app_doc_types():
        return APP
    elif doc_type == LOCATION_DOC_TYPE:
        return LOCATION
    elif doc_type in ALL:  # for docs that don't have a doc_type we use the Kafka topic
        return doc_type
    elif default_topic:
        return default_topic
    else:
        # at some point we may want to make this more granular
        return META  # note this does not map to the 'meta' Couch database
예제 #3
0
파일: util.py 프로젝트: soitun/commcare-hq
def delete_all_apps():
    for doc_type in app_doc_types():
        res = Application.get_db().view('all_docs/by_doc_type',
                                        startkey=[doc_type],
                                        endkey=[doc_type, {}],
                                        reduce=False,
                                        include_docs=True)
        for row in res:
            Application.get_db().delete_doc(row['doc'])
예제 #4
0
def _get_primary_type(raw_doc_type):
    if raw_doc_type in ('CommCareCase', 'CommCareCase-Deleted'):
        return CASE
    elif raw_doc_type in all_known_formlike_doc_types():
        return FORM
    elif raw_doc_type in ('Domain', 'Domain-Deleted', 'Domain-DUPLICATE'):
        return DOMAIN
    elif raw_doc_type in ('CommCareUser', 'CommCareUser-Deleted'):
        return COMMCARE_USER
    elif raw_doc_type in ('WebUser', 'WebUser-Deleted'):
        return WEB_USER
    elif raw_doc_type in ('Group', 'Group-Deleted'):
        return GROUP
    elif raw_doc_type in app_doc_types():
        return APP
    else:
        # at some point we may want to make this more granular
        return META
예제 #5
0
def _get_primary_type(raw_doc_type):
    if raw_doc_type in ('CommCareCase', 'CommCareCase-Deleted'):
        return CASE
    elif raw_doc_type in all_known_formlike_doc_types():
        return FORM
    elif raw_doc_type in ('Domain', 'Domain-Deleted', 'Domain-DUPLICATE'):
        return DOMAIN
    elif raw_doc_type in ('CommCareUser', 'CommCareUser-Deleted'):
        return COMMCARE_USER
    elif raw_doc_type in ('WebUser', 'WebUser-Deleted'):
        return WEB_USER
    elif raw_doc_type in ('Group', 'Group-Deleted'):
        return GROUP
    elif raw_doc_type in app_doc_types():
        return APP
    else:
        # at some point we may want to make this more granular
        return META
예제 #6
0
파일: apps.py 프로젝트: zbidi/commcare-hq
def new_app(request, domain):
    "Adds an app to the database"
    lang = 'en'
    type = request.POST["type"]
    cls = app_doc_types()[type]
    form_args = []
    if cls == Application:
        app = cls.new_app(domain, "Untitled Application", lang=lang)
        module = Module.new_module("Untitled Module", lang)
        app.add_module(module)
        form = app.new_form(0, "Untitled Form", lang)
        form_args = [module.id, form.id]
    else:
        app = cls.new_app(domain, "Untitled Application", lang=lang)
    if request.project.secure_submissions:
        app.secure_submissions = True
    app.save()
    clear_app_cache(request, domain)
    main_args = [request, domain, app.id]
    main_args.extend(form_args)

    return back_to_main(*main_args)
예제 #7
0
파일: apps.py 프로젝트: dimagi/commcare-hq
def new_app(request, domain):
    "Adds an app to the database"
    lang = 'en'
    type = request.POST["type"]
    cls = app_doc_types()[type]
    form_args = []
    if cls == Application:
        app = cls.new_app(domain, "Untitled Application", lang=lang)
        module = Module.new_module("Untitled Module", lang)
        app.add_module(module)
        form = app.new_form(0, "Untitled Form", lang)
        form_args = [module.id, form.id]
    else:
        app = cls.new_app(domain, "Untitled Application", lang=lang)
    if request.project.secure_submissions:
        app.secure_submissions = True
    app.save()
    clear_app_cache(request, domain)
    main_args = [request, domain, app.id]
    main_args.extend(form_args)

    return back_to_main(*main_args)
예제 #8
0
def get_commcare_settings_layout(app):
    doc_type = app.get_doc_type()
    if doc_type in app_doc_types():
        return _load_commcare_settings_layout(app)
    raise Exception("Unexpected doc_type received: %s" % doc_type)
예제 #9
0
def get_commcare_settings_layout(doc_type):
    if doc_type in app_doc_types():
        return _load_commcare_settings_layout(doc_type)
    raise Exception("Unexpected doc_type received: %s" % doc_type)