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)
def sync(user=None): if user: conf = ModuleSetting.get('nuvius_profile', user=user, strict=True) else: conf = ModuleSetting.get('nuvius_profile') for item in conf: profile = item.loads() user = item.user if user: connector = Connector(profile_id=profile['id']) active_resources = ModuleSetting.get_for_module( 'treeio.identities', 'integration_resource', user=user, strict=True) for resource in active_resources: res = resource.loads() response = connector.get( '/service/contact-book/contact/data.json/id' + profile['id'] + '/app' + str(res.resource_id)) data = DataBlock(response['data']) if data.result_name == 'success': _do_sync(data, user)
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 )
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)
def sync(user=None): if user: conf = ModuleSetting.get('nuvius_profile', user=user, strict=True) else: conf = ModuleSetting.get('nuvius_profile') for item in conf: profile = item.loads() user = item.user if user: connector = Connector(profile_id=profile['id']) active_resources = ModuleSetting.get_for_module('treeio.events', 'integration_resource', user=user, strict=True) for resource in active_resources: res = resource.loads() response = connector.get('/service/calendar/event/data.json/id' + profile['id'] + '/app' + str(res.resource_id)) data = DataBlock(response['data']) if data.result_name == 'success': _do_sync(data, user)
def sync(user=None): if user: conf = ModuleSetting.get("nuvius_profile", user=user, strict=True) else: conf = ModuleSetting.get("nuvius_profile") for item in conf: profile = item.loads() user = item.user if user: connector = Connector(profile_id=profile["id"]) active_resources = ModuleSetting.get_for_module( "treeio.identities", "integration_resource", user=user, strict=True ) for resource in active_resources: res = resource.loads() response = connector.get( "/service/contact-book/contact/data.json/id" + profile["id"] + "/app" + str(res.resource_id) ) data = DataBlock(response["data"]) if data.result_name == "success": _do_sync(data, user)