Пример #1
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):
        update_kissmetrics_properties.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]))
Пример #2
0
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):
        update_kissmetrics_properties.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]))