コード例 #1
0
ファイル: apps.py プロジェクト: zbidi/commcare-hq
def default_new_app(request, domain):
    """New Blank Application according to defaults. So that we can link here
    instead of creating a form and posting to the above link, which was getting
    annoying for the Dashboard.
    """
    meta = get_meta(request)
    track_app_from_template_on_hubspot.delay(request.couch_user,
                                             request.COOKIES, meta)
    if tours.NEW_APP.is_enabled(request.user):
        identify.delay(request.couch_user.username,
                       {'First Template App Chosen': 'blank'})
    lang = 'en'
    app = Application.new_app(domain, _("Untitled Application"), lang=lang)

    if not toggles.APP_MANAGER_V2.enabled(domain):
        # APP MANAGER V2 is completely blank on new app
        module = Module.new_module(_("Untitled Module"), lang)
        app.add_module(module)
        form = app.new_form(0, "Untitled Form", lang)

    if request.project.secure_submissions:
        app.secure_submissions = True
    clear_app_cache(request, domain)
    app.save()
    if toggles.APP_MANAGER_V2.enabled(request.domain):
        return HttpResponseRedirect(reverse('view_app', args=[domain,
                                                              app._id]))
    return HttpResponseRedirect(
        reverse('view_form', args=[domain, app._id, 0, 0]))
コード例 #2
0
def user_save_callback(sender, **kwargs):
    couch_user = kwargs.get("couch_user", None)
    if couch_user and couch_user.is_web_user():
        properties = {}
        properties.update(get_subscription_properties_by_user(couch_user))
        properties.update(get_domain_membership_properties(couch_user))
        identify.delay(couch_user.username, properties)
        update_hubspot_properties.delay(couch_user, properties)
コード例 #3
0
ファイル: apps.py プロジェクト: dimagi/commcare-hq
def app_from_template(request, domain, slug):
    meta = get_meta(request)
    track_app_from_template_on_hubspot.delay(request.couch_user, request.COOKIES, meta)
    if tours.NEW_APP.is_enabled(request.user):
        identify.delay(request.couch_user.username, {"First Template App Chosen": "%s" % slug})
    clear_app_cache(request, domain)
    template = load_app_template(slug)
    app = import_app_util(template, domain, {"created_from_template": "%s" % slug})
    module_id = 0
    form_id = 0
    try:
        app.get_module(module_id).get_form(form_id)
    except (ModuleNotFoundException, FormNotFoundException):
        return HttpResponseRedirect(reverse("view_app", args=[domain, app._id]))
    return HttpResponseRedirect(reverse("view_form", args=[domain, app._id, module_id, form_id]))
コード例 #4
0
def app_from_template(request, domain, slug):
    meta = get_meta(request)
    track_app_from_template_on_hubspot.delay(request.couch_user, request.COOKIES, meta)
    if tours.NEW_APP.is_enabled(request.user):
        identify.delay(request.couch_user.username, {'First Template App Chosen': '%s' % slug})
    clear_app_cache(request, domain)
    template = load_app_template(slug)
    app = import_app_util(template, domain, {
        'created_from_template': '%s' % slug,
    })
    module_id = 0
    form_id = 0
    try:
        app.get_module(module_id).get_form(form_id)
    except (ModuleNotFoundException, FormNotFoundException):
        return HttpResponseRedirect(reverse('view_app', args=[domain, app._id]))
    return HttpResponseRedirect(reverse('view_form', args=[domain, app._id, module_id, form_id]))
コード例 #5
0
ファイル: apps.py プロジェクト: saketkanth/commcare-hq
def default_new_app(request, domain):
    """New Blank Application according to defaults. So that we can link here
    instead of creating a form and posting to the above link, which was getting
    annoying for the Dashboard.
    """
    meta = get_meta(request)
    track_app_from_template_on_hubspot.delay(request.couch_user, request.COOKIES, meta)
    if tours.NEW_APP.is_enabled(request.user):
        identify.delay(request.couch_user.username, {'First Template App Chosen': 'blank'})
    lang = 'en'
    app = Application.new_app(
        domain, _("Untitled Application"), lang=lang,
        application_version=APP_V2
    )
    module = Module.new_module(_("Untitled Module"), lang)
    app.add_module(module)
    form = app.new_form(0, "Untitled Form", lang)
    if request.project.secure_submissions:
        app.secure_submissions = True
    clear_app_cache(request, domain)
    app.save()
    return HttpResponseRedirect(reverse('view_form', args=[domain, app._id, 0, 0]))