def create(self, account_id, user_id, revision_id, resource_type, resource_id, action_id, resource_title, resource_category): """ Create a redis-hash and then addit to a redis-lits""" if settings.DEBUG: logger.info('Create ActivityStreamDAO %d %s' % (action_id, resource_title)) c = Cache(db=settings.CACHE_DATABASES['activity_resources']) timeformat = "%s %s %s %s" % (ugettext('APP-ON-TEXT'), "%Y-%m-%d,", ugettext('APP-AT-TEXT'), "%H:%M") now = datetime.datetime.now() time = now.strftime(timeformat) l_permalink = "" #TODO check and fix al urls. if int(action_id) != int(choices.ActionStreams.DELETE): if resource_type == settings.TYPE_DATASTREAM: l_permalink = reverse('manageDataviews.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) elif resource_type == settings.TYPE_VISUALIZATION: l_permalink = reverse('manageVisualizations.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) elif resource_type == settings.TYPE_DATASET: l_permalink = reverse('manageDatasets.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) else: for plugin in DatalPluginPoint.get_plugins(): if (plugin.is_active() and hasattr(plugin, 'doc_type') and plugin.doc_type == resource_type and hasattr(plugin, 'workspace_permalink')): l_permalink = plugin.workspace_permalink(revision_id) list_key = 'activity_stream::%s' % str(account_id) n = c.incr( "%s_counter" % list_key ) # count any use of the list indexing hash and never repeat an ID activity_key = 'activity.stream_%s:%s' % (str(account_id), str(n)) activity_value = { "user_id": user_id, "revision_id": revision_id, "type": resource_type, "resource_id": resource_id, "action_id": action_id, "title": resource_title, "time": time, "resource_link": l_permalink, "category": resource_category } r1 = c.hmset(activity_key, activity_value) r2 = c.lpush(str(list_key), activity_key) if settings.DEBUG: logger.info('Saved ActivityStreamDAO {} {} {} {} {}'.format( str(r1), str(r2), list_key, activity_key, activity_value)) return list_key, activity_key, activity_value
def create(self, account_id, user_id, revision_id, resource_type, resource_id, action_id, resource_title, resource_category): """ Create a redis-hash and then addit to a redis-lits""" if settings.DEBUG: logger.info('Create ActivityStreamDAO %d %s' % (action_id, resource_title)) c = Cache(db=settings.CACHE_DATABASES['activity_resources']) timeformat = "%s %s %s %s" % (ugettext('APP-ON-TEXT'), "%Y-%m-%d,", ugettext('APP-AT-TEXT'), "%H:%M") now = datetime.datetime.now() time = now.strftime(timeformat) l_permalink="" #TODO check and fix al urls. if int(action_id) != int(choices.ActionStreams.DELETE): if resource_type == settings.TYPE_DATASTREAM: l_permalink = reverse('manageDataviews.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) elif resource_type == settings.TYPE_VISUALIZATION: l_permalink = reverse('manageVisualizations.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) elif resource_type == settings.TYPE_DATASET: l_permalink = reverse('manageDatasets.view', urlconf='workspace.urls', kwargs={'revision_id': revision_id}) else: for plugin in DatalPluginPoint.get_plugins(): if (plugin.is_active() and hasattr(plugin, 'doc_type') and plugin.doc_type == resource_type and hasattr(plugin, 'workspace_permalink')): l_permalink = plugin.workspace_permalink(revision_id) list_key = 'activity_stream::%s' % str(account_id) n=c.incr("%s_counter" % list_key) # count any use of the list indexing hash and never repeat an ID activity_key = 'activity.stream_%s:%s' % (str(account_id), str(n)) activity_value = {"user_id": user_id, "revision_id": revision_id , "type": resource_type, "resource_id": resource_id ,"action_id": action_id , "title": resource_title, "time":time , "resource_link": l_permalink , "category": resource_category } r1 = c.hmset(activity_key, activity_value) r2 = c.lpush(str(list_key), activity_key) if settings.DEBUG: logger.info('Saved ActivityStreamDAO {} {} {} {} {}'.format(str(r1), str(r2), list_key, activity_key, activity_value)) return list_key, activity_key, activity_value
from workspace.rest.categories import RestCategoryViewSet from workspace.rest.users import RestUserViewSet router = routers.DefaultRouter() router.register(r'datastreams', RestDataStreamViewSet, base_name='datastreams') router.register(r'maps', RestMapViewSet, base_name='maps') router.register(r'charts', RestChartViewSet, base_name='charts') router.register(r'datasets', RestDataSetViewSet, base_name='datasets') router.register(r'sources', RestSourceViewSet, base_name='sources') router.register(r'tags', RestTagViewSet, base_name='tags') router.register(r'resources', MultipleResourceViewSet, base_name='resources') router.register(r'categories', RestCategoryViewSet, base_name='categories') router.register(r'users', RestUserViewSet, base_name='users') # Implemento los routers que tenga el plugin plugins = DatalPluginPoint.get_plugins() for plugin in plugins: if plugin.is_active() and hasattr(plugin, 'workspace_routers'): for router_list in plugin.workspace_routers: router.register(router_list[0], router_list[1], base_name=router_list[2]) def jsi18n(request, packages=None, domain=None): if not domain: domain = 'djangojs' return javascript_catalog(request, domain, packages) js_info_dict = {
from workspace.rest.users import RestUserViewSet router = routers.DefaultRouter() router.register(r'datastreams', RestDataStreamViewSet, base_name='datastreams') router.register(r'maps', RestMapViewSet, base_name='maps') router.register(r'charts', RestChartViewSet, base_name='charts') router.register(r'datasets', RestDataSetViewSet, base_name='datasets') router.register(r'sources', RestSourceViewSet, base_name='sources') router.register(r'tags', RestTagViewSet, base_name='tags') router.register(r'resources', MultipleResourceViewSet, base_name='resources') router.register(r'categories', RestCategoryViewSet, base_name='categories') router.register(r'users', RestUserViewSet, base_name='users') # Implemento los routers que tenga el plugin plugins = DatalPluginPoint.get_plugins() for plugin in plugins: if plugin.is_active() and hasattr(plugin, 'workspace_routers'): for router_list in plugin.workspace_routers: router.register(router_list[0], router_list[1], base_name=router_list[2]) def jsi18n(request, packages=None, domain=None): if not domain: domain = 'djangojs' return javascript_catalog(request, domain, packages) js_info_dict = { 'domain': 'djangojs', 'packages': ('workspace'), }