How to Sort X-editable json data by values or stop default sorting by key - x-editable

this is my editable code,
jQuery('.billitemname').editable({
url: base_url+'timetracker/saveEdit',
source: base_url+'/timetracker/getBillCats',
type: 'select',
mode: 'inline'
});
and this is the Json data while i am getting in source,
{"96":"B2B Calling","68":"Billboards","12":"Comprehensive Planning","13":"Consulting Fees","109":"Content Writing","105":"Convenience Fee","15":"Creative Writing","104":"Digital Video X","55":"Direct Mail","62":"Direct Mail List","17":"Domain","98":"Drone Work","79":"Email Marketing","100":"Google Adwords","20":"Graphic Design","88":"Healthy Website Plan","89":"Healthy Website Plan Set up","21":"Logo Design","95":"Marketing Package","113":"Miscellaneous Marketing","103":"Mobile 360","83":"Online Ad","110":"Online Partnership Package - Brand Level","115":"Online Partnership Package - Strategy Level","97":"Onsite Tech","81":"Pay Per Click","94":"Photo Edits","25":"Photography","74":"Postage","26":"Print Ad","27":"Print Work","101":"Production","93":"Production Supplies","67":"Promotional Items","30":"Radio Ads","28":"Radio Production","114":"Research","102":"Retargeting","90":"Robo Calls","87":"Services","34":"Shipping","35":"Signage","80":"Social Media Marketing","75":"SSL Certificate","91":"Stock Photography","107":"Talent Fees","73":"Trade","37":"TV Ads","38":"TV production Cost","56":"Video Work","92":"Video\/Social Package","51":"Voice Talent","40":"Web Hosting","33":"Web Optimization","84":"Web Work","46":"Website Design"}
But it is sorting by default key, So my output is like
<option value=12>Comprehensive</option>..... so on,

Related

Not able to put tag column value on monday item

I am trying to use python to automation common Monday tasks. I am able to create an item in the board but the column (type=tag) is not updating.
I used this tutorial:
https://support.monday.com/hc/en-us/articles/360013483119-API-Quickstart-Tutorial-Python#
Here is my graphql code that I am executing:
query = 'mutation ($device: String!, $columnVals: JSON!) { create_item (board_id:<myboardid>, item_name:$device, column_values:$columnVals) { id } }'
vars = {'device': device,
'columnVals': json.dumps({
'cloud_name6': {'text': cloudname} # this is where i want to add a tag. cloud_name6 is id of the column.
})
}
data = {'query' : query, 'variables' : vars}
r = requests.post(url=apiUrl, json=data, headers=headers) print(r.json())
I have tried changing id to title as key in the Json string but no luck. I fetched the existing item and tried to add exact json string but still no luck. I also tried below json data without any luck
'columnVals': json.dumps({
'cloud_name6': cloudname
})
Any idea what's wrong with the query?
When creating or mutating tag columns via item queries, you need to send an array of ids of the tags ("tag_ids") that are relating to this item. You don't set or alter tag names via an item query.
Corrected Code
'columnVals': json.dumps({
'cloud_name6': {'tag_ids': [295026,295064]}
})
https://developer.monday.com/api-reference/docs/tags

Hugo Pass Shortcode Variables From Pages Into sitemap.xml

Currently Hugo's built-in sitemap generator only creates two field attributes for images -- image:loc and image:license. Unfortunately this does not tell Google Bots much about the images context for SEO. The fields, image:title & image:caption at minimum is needed with the other two for best practices; Otherwise it's basically dead XML code.
I am working on a site that is image-content driven and since a short code is given in each page labeled as "Featured-Image" and contains the needed variables where I would like to extract/pass into the sitemap.
Here is an example of the shortcode within a page.md:
{{<
featured-image
name ="THE_IMAGE_NAME.jpg"
featuredTitle ="THE_IMAGE_TITLE"
location ="THE_IMAGE_LOCATION"
alt ="THE_IMAGE_ALT/CAPTION"
>}}
Within the sitemap.xml is what I would like to do:
{{ $license := .Site.Params.schema.license }}
{{ range .Data.Pages }}
...
{{ range $i := .Resources.ByType "image" }}
// Below is the additional data I am wanting to get from the pages'
// shortcode named "featured-image" -- But How Do I Get It?.
{{ $caption := .Get "alt" }}
{{ $location := .Get "location"}}
{{ $title := .Get "featuredTitle"}}
<image:image>
<image:loc>{{ $i.Permalink }}</image:loc>
<image:license>{{ $license }}</image:license>
// Below are the additional attributes needed:
<image:geo_location>{{ $location }}</image:geo_location>
<image:title>{{ $title }}</image:title>
<image:caption>{{ $caption }}</image:caption>
</image:image>
...

how to change the created by <user> in log to OdooBot when creating a record using odoo external API

I'm trying to create a new lead from external landing page
The code work as expected so far on Odoo 13.0+e-20200524
url = ODOO_URL
db = ODOO_DB
username = ODOO_USERNAME
password = ODOO_PASSWORD
kwargs = {
'name': 'hello world',
}
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
print(uid)
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [{
'name': kwargs.get('name'),
'user_id': 1,
}])
print(id)
But the log of the lead showing that my user created that lead (which is properly right)
Change the created user to OdooBot in the view - screenshot
My question is:
How can I change the created user to OdooBot instead of my user?
PS: I already searched around and tried bellow parameters without luck:
'user_login': "OdooBot",
'create_uid': [1],
'write_uid': [1],
uid represent a key role of User to create a record using xmlrpc.
You can change uid and it will log with that User.

How to get top 10 videos from your channel with the views count included in the response

So I have a ouath web app that connects to youtube. I use the youtube analytics calls to get information like number of subscribers from my channel. But right now I try to make a top 10 videos from my channel with the views count for every video included in the response. I use this documentation:
Top videos for subscribed or unsubscribed viewers
My call looks like this:
$command = 'curl -H "Authorization: Bearer ' . $access_token . '" "https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=' . date('Y-m-d', strtotime('-31 days')) . '&end-date=' . date('Y-m-d', strtotime('today')). '&metrics=views&dimensions=video&sort=views"';
But I get an error message as a response:
"The query is not supported. Check the documentation at https://developers.google.com/youtube/analytics/v1/available_reports for a list of supported queries."
I also tried this call with YoTube data API:
$videos_url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&order=viewCount&type=video&access_token=' . $access_token;
But it provides this response:
["kind"]=>
string(26) "youtube#searchListResponse"
["etag"]=>
string(57) ""######""
["nextPageToken"]=>
string(112) "#######"
["pageInfo"]=>
object(stdClass)#267 (2) {
["totalResults"]=>
int(1)
["resultsPerPage"]=>
int(5)
}
["items"]=>
array(1) {
[0]=>
object(stdClass)#270 (4) {
["kind"]=>
string(20) "youtube#searchResult"
["etag"]=>
string(57) ""#####""
["id"]=>
object(stdClass)#269 (2) {
["kind"]=>
string(13) "youtube#video"
["videoId"]=>
string(11) "####"
}
["snippet"]=>
object(stdClass)#273 (6) {
["publishedAt"]=>
string(24) "2016-09-14T14:49:49.000Z"
["channelId"]=>
string(24) "#####"
["title"]=>
string(12) "My Slideshow"
["description"]=>
string(87) "I created this video with the YouTube Slideshow Creator (http://www.youtube.com/upload)"
This response provides no views count. I need for every video to get the views count as well.
Any ideas on how to accomplish this? Any help is welcomed! Thank you all for your time!
The issue with your youtube analytics api request is sort parameter. Try using value -views instead of views. You can double check the API link you provided. Also set the max-results
Example URL :
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3Dmine&start-date=2016-05-01&end-date=2016-09-01&metrics=views&dimensions=video&max-results=10&sort=-views&key={YOUR_API_KEY}

Yodlee REST API - addItemForContentService1

Could you please provide a JSON sample of how you would post an addItemForContentService1 for a bank with a FieldInfoMultiFixed field. An example is Sallie Mae, content service ID #3805
Thanks
I wrote this in python. Replace some of the values such as cobrand_session_token, content_service_id with the actual values:
Most of the below is directly from this documentation.
payload = {"cobSessionToken": cobrand_session_token, "userSessionToken": session["user_session_token"], "contentServiceId": content_service_id, "shareCredentialsWithinSite": True, "startRefreshItemOnAddition": True, "credentialFields.enclosedType": "com.yodlee.common.FieldInfoMultiFixed",\
"credentialFields[0].valueIdentifier":"LOGIN",\
"credentialFields[0].displayName":"UserID",\
"credentialFields[0].isEditable":True,\
"credentialFields[0].isEscaped":False,\
"credentialFields[0].name":"LOGIN",\
"credentialFields[0].helpText":5112,\
"credentialFields[0].fieldType":"TEXT",\
"credentialFields[0].valueMask":"LOGIN_FIELD",\
"credentialFields[0].maxlength":40,\
"credentialFields[0].size":20,\
"credentialFields[1].valueIdentifier":"PASSWORD",\
"credentialFields[1].displayName":"Password",\
"credentialFields[1].isEditable":True,\
"credentialFields[1].isEscaped":False,\
"credentialFields[1].name":"PASSWORD",\
"credentialFields[1].helpText":4530,\
"credentialFields[1].fieldType":"IF_PASSWORD",\
"credentialFields[1].valueMask":"LOGIN_FIELD",\
"credentialFields[1].maxlength":40,\
"credentialFields[1].size":20, "credentialFields[0].value":"content_account_username", "credentialFields[1].value":"content_account_password"}