def get_snippet_dataset(activity, detail): data = activity['data'] pkg_dict = data.get('package') or data.get('dataset') link = h.dataset_link(pkg_dict) if pkg_dict else '' return literal('''<span>%s</span>''' % (link) )
def get_snippet_dataset(activity, detail): data = activity["data"] link = h.dataset_link(data.get("package") or data.get("dataset")) return literal( """<span data-module="popover-context" data-module-type="dataset" data-module-id="%s">%s</span>""" % (activity["object_id"], link) )
def result(self): context = { 'model': ckan.model, 'session': ckan.model.Session, 'user': pylons.c.user or pylons.c.author } #check for POST data if ckan.plugins.toolkit.request.method == 'POST': data = ckan.plugins.toolkit.request.POST dataset = data['dataset'] resources = data['resources'].split(';') try: package = plugins.toolkit.get_action('package_show')( context, { 'id': dataset }) except Exception: flash_error('error: update unsuccessful') #list of resources target_resources = package['resources'] reorder_list = [] for res in resources: index = map(itemgetter('name'), target_resources).index(res) reorder_list.append(target_resources[index]) package['resources'] = reorder_list try: package = plugins.toolkit.get_action('package_update')(context, package) flash_success('resources in ' + dataset_display_name(package) + ' have been updated') except: #something went wrong with the update flash_error('error: update unsuccessful') plugins.toolkit.c.resources = [ item['name'] for item in package['resources'] ] plugins.toolkit.c.name = package['name'] plugins.toolkit.c.link = dataset_link(package) #no POST data - redirect to home page else: ckan.plugins.toolkit.redirect_to(controller="home", action="index") return plugins.toolkit.render('result.html')
def render_new_dataset(template, activity): """Return the HTML snippet describing a user creating a new dataset""" # Provide a html link to the user's page actor = link_to_user(activity['user_id']) actor = '%s' % actor # Provide a html link to the new group object = h.dataset_link(activity['data']['package']) if object: object = '%s' % object # Build the entire message and return the html. date = '%s' % h.render_datetime(activity['timestamp']) template = template.format(actor=actor, date=date, object=object) template = '%s %s' % (template, date) # It is important to return it as a literal or it will be converted to text return html.literal(template)
def result(self): context = {'model': ckan.model, 'session': ckan.model.Session, 'user': pylons.c.user or pylons.c.author} #check for POST data if ckan.plugins.toolkit.request.method == 'POST': data = ckan.plugins.toolkit.request.POST dataset = data['dataset'] resources = data['resources'].split(';') try: package = plugins.toolkit.get_action('package_show')(context, {'id': dataset}) except Exception: flash_error('error: update unsuccessful') #list of resources target_resources = package['resources'] reorder_list = [] for res in resources: index = map(itemgetter('name'), target_resources).index(res) reorder_list.append(target_resources[index]) package['resources'] = reorder_list try: package = plugins.toolkit.get_action('package_update')(context, package) flash_success('resources in ' + dataset_display_name(package) + ' have been updated') except: #something went wrong with the update flash_error('error: update unsuccessful') plugins.toolkit.c.resources = [item['name'] for item in package['resources']] plugins.toolkit.c.name = package['name'] plugins.toolkit.c.link = dataset_link(package) #no POST data - redirect to home page else: ckan.plugins.toolkit.redirect_to(controller="home", action="index") return plugins.toolkit.render('result.html')
def get_snippet_dataset(activity, detail): data = activity['data'] link = h.dataset_link(data.get('package') or data.get('dataset')) return literal('''<span data-module="popover-context" data-module-type="dataset" data-module-id="%s">%s</span>''' % (activity['object_id'], link) )
def get_snippet_dataset(activity, detail): data = activity['data'] link = h.dataset_link(data.get('package') or data.get('dataset')) return literal('''<span>%s</span>''' % (link) )
def get_snippet_dataset(activity, detail): data = activity['data'] link = h.dataset_link(data.get('package') or data.get('dataset')) return literal('''<span>%s</span>''' % (link))
def get_snippet_dataset(activity, detail): data = activity["data"] link = h.dataset_link(data.get("package") or data.get("dataset")) return literal("""<span>%s</span>""" % (link))
def get_snippet_dataset(activity, detail): data = activity['data'] return h.dataset_link(data.get('package') or data.get('dataset'))
def get_snippet_dataset(activity, detail): data = activity['data'] link = h.dataset_link(data.get('package') or data.get('dataset')) return literal( '''<span data-module="popover-context" data-module-type="dataset" data-module-id="%s">%s</span>''' % (activity['object_id'], link))