CKAN: How to get dataset name? - customization

I want to customize the template for every single dataset, using the dataset name for sharing button.
Is there a variable to get the dataset name?
Thanks

It sometimes varies depending on what page's template you're editing, but a lot of the time one of c.pkg.name, c.pkg_dict.name, pkg.name or pkg_dict.name should work.
To find out how to see for sure exactly what variables are available to each template, read http://docs.ckan.org/en/latest/theming/variables-and-functions.html

Related

Quicksight breaking up strings for use of all aspects

I was wondering if anyone has every had experience with breaking a string up in quicksight and using certain aspects of the string. My example is a data set that returns tags like this "animals|funny|dog-park" I have used "split(tags,'|',1)" but then all that gets returned is the first part(animals). I have also tried a combination of ifelse->locate->split with no luck. Is there a way to split these tags to where they are all usable (animals) & (funny) or (funny) & (dog-park), etc.? Say the article associated will then be broken up into one tag but also another separately? I know this will end up being a calculated field most likely. Thank you in advance!
Since QuickSight does not support any form of nested fields (including objects and list) in analysis, you need to normalise this into separate rows before feeding the data to QuickSight.
Otherwise, if you leave it as is, you would be limited to filtering using string contains and doing string lookup in calculated fields - nevertheless you would not be able to use these tags as categories (such as in colours field well of visuals).

Is there a way to pass data source connection string as a parameter to power bi embedded?

I have a pbix file that takes an Azure Storage account as a parameter and reads data from there accordingly. The next step is to be able to embed this powerbi dashboard on a webpage and let the end user specify the storage account. I see a lot of questions and answers surrounding passing in filter query parameters--this is different, we're trying to read from a completely different data source and not filtering on a static data source.
Another way to ask this question is: is there a way to embed powerbi template files, if not, is there a feature request somewhere we can upvote?
The short answer is no.
There is a reason to use filters in this case instead of parameters. Parameters are something that is part of the report itself. Each users that looks at your reports will get the same parameter values as the others. If one of them changes some parameter, this will affect all other users. Filters on the other hand, is something local for your session. You can filter the report the way you like, and this will not affect other users experience in any way.
You can't embed templates, because template is simply a state of the report on the disk. When you open it, it's not a template anymore, but becomes a report.
You can either combine the data from all of your data sources in a single report, adding one more column to indicate from where this data comes from, and then filter on this new column. Or create/modify ETL process (for example dataflows can be used for this) to combine these data sources into a single one.

How to make a search based on get_field_gender label?

Well, this might be a bit odd, but I was wondering if it is possible to make a search based on the label for choiceFields rather than the stored database value.
I have an app that when the user searches for a vehicle of type truck, the query can't retrieve results because the value stored in the database is tru, although choiceField label is truck. The same goes for gender female is fem, for example.
I could go around this problem with alternative ways, but I was wondering if Django had this implemented somehow.
I think you should consider changing the search functionality to search with the shortened name. You can still display the label on the front-end: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#Examples

Content migration from one template to another in Sitecore

I want to transfer content of items that belong to one template into another template.
For example, I have 5 fields in first template:
Tags
Image
Download link
Title
Date
and 5 fields in another template:
Type
Picture
Download Text
Title
Date
Here first two fields are different in the both the templates and remaining 3 fields are same.
So I want to migrate content of items that belong to first template to the second template. Also, I would like to highlight second template is a newly created template and currently no item from that template is created. So ultimately I am modifying the template of 100 items.
I tried overriding change template method of sitecore TemplateManager.ChangeTemplate(Item item, TemplateChangeList changes) but it empties the fields rather I want to retain the field data.
If anyone has any idea about this, please help.
I don't think there wouldn't be much difficulty to migrate all contents by changing the template. But, the main issue is that there are a number of page items which have to be changed to another template.
If you do, you can use PowerShellExtension. It takes only 1 second.
You can get the script idea from Sitecore Workflow Is Not Working
A solution is to inhertitance this fields, (using the "Base template" Field).
A other solution is to create your own change template command.
You can found here sample code: http://sitecore.stockpick.nl/nederlands/dialoge-box-in-een-command/ (it is a dutch article)
In code use: item.ChangeTemplate(template); and fill in the new field with the already stored values from the old template.

Custom Date Aggregate Function

I want to sort my Store models by their opening times. Store models contains is_open function which controls Store's opening time ranges and produces a boolean if it's open or not. The problem is I don't want to sort my queryset manually because of efficiency problem. I thought if I write a custom annotate function then I can filter the query more efficiently.
So I googled and found that I can extend Django's aggregate class. From what I understood, I have to use pre-defined sql functions like MAX, AVG etc. The thing is I want to check that today's date is in a given list of time intervals. So anyone can help me that which sql name should I use ?
Edit
I'd like to put the code here but it's really a spaghetti one. One pages long code only generates time intervals and checks the suitable one.
I want to avoid :
alg= lambda r: (not (s.is_open() and s.reachable))
sorted(stores,key=alg)
and replace with :
Store.objects.annotate(is_open = CheckOpen(datetime.today())).order_by('is_open')
But I'm totally lost at how to write CheckOpen...
have a look at the docs for extra