示例#1
0
文件: views.py 项目: vovkd/treeio
def integration_view(request, conf_id, response_format='html'):
    "Integration view resource page"

    user = request.user.get_profile()

    resconf = get_object_or_404(ModuleSetting, pk=conf_id)
    res = resconf.loads()

    conf = ModuleSetting.get('nuvius_profile', user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None

    resource = None
    if profile:
        connector = Connector(request, profile_id=profile['id'])
        resource = DataBlock(connector.get_app(res.resource_id))
        if request.POST and 'delete' in request.POST:
            resconf.delete()
            return HttpResponseRedirect(reverse('events_integration_index'))

    context = {'conf_id': conf_id, 'resource': resource}

    return render_to_response('events/integration_view',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
示例#2
0
文件: views.py 项目: alejo8591/maker
def integration_view(request, conf_id, response_format='html'):
    "Integration view resource page"
    
    user = request.user.get_profile()
    
    resconf = get_object_or_404(ModuleSetting, pk=conf_id)
    res = resconf.loads()
    
    conf = ModuleSetting.get('nuvius_profile', user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None
    
    resource = None
    if profile:
        connector = Connector(request, profile_id=profile['id'])
        resource = DataBlock(connector.get_app(res.resource_id))
        if request.POST and 'delete' in request.POST:
            resconf.delete()
            return HttpResponseRedirect(reverse('events_integration_index'))
        
    context = {'conf_id': conf_id, 'resource': resource}
    
    return render_to_response('events/integration_view', context,
                              context_instance=RequestContext(request), response_format=response_format)
示例#3
0
文件: views.py 项目: alejo8591/maker
def integration_view(request, conf_id, response_format="html"):
    "Integration view resource page"

    user = request.user.get_profile()

    resconf = get_object_or_404(ModuleSetting, pk=conf_id)
    res = resconf.loads()

    conf = ModuleSetting.get("nuvius_profile", user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None

    resource = None
    if profile:
        connector = Connector(request, profile_id=profile["id"])
        resource = DataBlock(connector.get_app(res.resource_id))
        if request.POST and "delete" in request.POST:
            resconf.delete()
            return HttpResponseRedirect(reverse("identities_integration_index"))

    context = _get_default_context(request)
    context.update({"conf_id": conf_id, "resource": resource})

    return render_to_response(
        "identities/integration_view",
        context,
        context_instance=RequestContext(request),
        response_format=response_format,
    )
示例#4
0
文件: views.py 项目: vovkd/treeio
def integration_add(request, resource_id, response_format='html'):
    "Integration add new resource page"

    user = request.user.get_profile()

    conf = ModuleSetting.get('nuvius_profile', user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None

    resource = None
    data = None
    if profile:
        connector = Connector(request, profile_id=profile['id'])
        resource = DataBlock(connector.get_app(resource_id))
        if request.POST and 'add' in request.POST:
            resource = IntegrationResource(profile['id'], resource_id,
                                           resource.application.name.raw,
                                           '9rw')
            conf = ModuleSetting.add_for_module('integration_resource',
                                                '',
                                                'treeio.identities',
                                                user=user)
            conf.dumps(resource).save()
            return HttpResponseRedirect(
                reverse('identities_integration_index'))
        else:
            data = connector.get('/service/contact-book/contact/data.json/id' +
                                 profile['id'] + '/app' + unicode(resource_id),
                                 no_cache=True)
            data = DataBlock(data)
            if data.result_name == 'success':
                pass
            elif data.result_name == 'redirect':
                next = request.build_absolute_uri(
                    reverse('identities_integration_add', args=[resource_id]))
                data = connector.get(
                    '/service/contact-book/contact/data.json/id' +
                    profile['id'] + '/app' + unicode(resource_id),
                    parameters={'next': next},
                    no_cache=True)
            data = DataBlock(data)

    context = _get_default_context(request)
    context.update({
        'resource_id': resource_id,
        'resource': resource,
        'data': data
    })

    return render_to_response('identities/integration_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
示例#5
0
文件: views.py 项目: alejo8591/maker
def integration_add(request, resource_id, response_format="html"):
    "Integration add new resource page"

    user = request.user.get_profile()

    conf = ModuleSetting.get("nuvius_profile", user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None

    resource = None
    data = None
    if profile:
        connector = Connector(request, profile_id=profile["id"])
        resource = DataBlock(connector.get_app(resource_id))
        if request.POST and "add" in request.POST:
            resource = IntegrationResource(profile["id"], resource_id, resource.application.name.raw, "9rw")
            conf = ModuleSetting.add_for_module("integration_resource", "", "maker.identities", user=user)
            conf.dumps(resource).save()
            return HttpResponseRedirect(reverse("identities_integration_index"))
        else:
            data = connector.get(
                "/service/contact-book/contact/data.json/id" + profile["id"] + "/app" + unicode(resource_id),
                no_cache=True,
            )
            data = DataBlock(data)
            if data.result_name == "success":
                pass
            elif data.result_name == "redirect":
                next = request.build_absolute_uri(reverse("identities_integration_add", args=[resource_id]))
                data = connector.get(
                    "/service/contact-book/contact/data.json/id" + profile["id"] + "/app" + unicode(resource_id),
                    parameters={"next": next},
                    no_cache=True,
                )
            data = DataBlock(data)

    context = _get_default_context(request)
    context.update({"resource_id": resource_id, "resource": resource, "data": data})

    return render_to_response(
        "identities/integration_add", context, context_instance=RequestContext(request), response_format=response_format
    )
示例#6
0
文件: views.py 项目: alejo8591/maker
def integration_add(request, resource_id, response_format='html'):
    "Integration add new resource page"
    
    user = request.user.get_profile()
    
    conf = ModuleSetting.get('nuvius_profile', user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None
    
    resource = None
    data = None
    if profile:
        connector = Connector(request, profile_id=profile['id'])
        resource = DataBlock(connector.get_app(resource_id))
        if request.POST and 'add' in request.POST:
            resource = IntegrationResource(profile['id'], resource_id, resource.application.name.raw, '9rw')
            conf = ModuleSetting.add_for_module('integration_resource', '', 'maker.events', user=user)
            conf.dumps(resource).save()
            return HttpResponseRedirect(reverse('events_integration_index'))
        else:
            data = connector.get('/service/calendar/event/data.json/id' + profile['id'] + '/app' + unicode(resource_id),
                                 no_cache=True)
            data = DataBlock(data)
            if data.result_name == 'success':
                pass
            elif data.result_name == 'redirect':
                next = request.build_absolute_uri(reverse('events_integration_add', args=[resource_id]))
                data = connector.get('/service/calendar/event/data.json/id' + profile['id'] + '/app' + unicode(resource_id),
                                     parameters={'next': next},  no_cache=True)
            data = DataBlock(data)
        
    context = {'resource_id': resource_id, 'resource': resource, 'data': data}
    
    return render_to_response('events/integration_add', context,
                              context_instance=RequestContext(request), response_format=response_format)