This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kpi.models.asset import Asset | |
import json | |
ASSET_CONTENT = json.loads(''' | |
{ | |
"survey": [ | |
{ | |
"$autoname": "s1", | |
"required": false, | |
"kobo--rank-items": "legacyrankitems", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kpi.models.asset import Asset | |
ASSET_CONTENT = {'choices': [{'$autovalue': 'red', | |
'$kuid': 'odkr1fAsW', | |
'label': ['Red'], | |
'list_name': 'ri2bk45', | |
'value': 'red'}, | |
{'$autovalue': 'yellow', | |
'$kuid': 'odkr2f3cX', | |
'label': ['Yellow'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyxform_test_case import PyxformTestCase | |
class TestSupportExternalInstances(PyxformTestCase): | |
def test_csv_externals(self): | |
# no choice filter | |
self.assertPyxformXform( | |
name="test_csv_externals", | |
md=""" | |
#survey | |
| type | name | label | choice_filter | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- a tm / sublime snippet to go with https://github.com/abeisgreat/-_-.js --> | |
<snippet> | |
<content><![CDATA[ಠ_ಠ( ${1} )]]></content> | |
<tabTrigger>oo</tabTrigger> | |
<scope>source.js</scope> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Excerpt from jQuery v2.1.1 | |
// a comment in the middle of the Sizzle declaration causes yuglify v0.1.4 to trip up | |
var Sizzle = | |
/*! | |
* Sizzle CSS Selector Engine v1.10.19 | |
* http://sizzlejs.com/ | |
* | |
* Copyright 2013 jQuery Foundation, Inc. and other contributors | |
* Released under the MIT license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyxform | |
from StringIO import StringIO | |
def csv_to_survey(csv_txt): | |
csv_io = StringIO(csv_txt) | |
workbook_repr = pyxform.xls2json_backends.csv_to_dict(csv_io) | |
try: | |
form_name = workbook_repr['settings'][0][u'id_string'] | |
except KeyError, e: | |
form_name = "xform" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dpi.get() code is from stackoverflow: | |
// http://stackoverflow.com/questions/2252030/how-can-i-find-out-a-web-page-viewers-pixels-per-inch#answer-2312609 | |
var dpi = { | |
v: 0, | |
get: function (noCache) { | |
if (noCache || dpi.v == 0) { | |
e = document.body.appendChild(document.createElement('DIV')); | |
e.style.width = '1in'; | |
e.style.padding = '0'; | |
dpi.v = e.offsetWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dpi.get() code is from stackoverflow: | |
// http://stackoverflow.com/questions/2252030/how-can-i-find-out-a-web-page-viewers-pixels-per-inch#answer-2312609 | |
var dpi = { | |
v: 0, | |
get: function (noCache) { | |
if (noCache || dpi.v == 0) { | |
e = document.body.appendChild(document.createElement('DIV')); | |
e.style.width = '1in'; | |
e.style.padding = '0'; | |
dpi.v = e.offsetWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.outerHtml = function() { | |
// edit: | |
// var el = $(this).get(0); | |
var el = this.get(0); | |
if (el === undefined || !(el instanceof Element)) return false; | |
if (el.outerHTML !== undefined) return el.outerHTML; | |
return $('<div>').html($(this).eq(0).clone()).html(); | |
}; | |
/* It could be convenient if jQuery objects had a toString method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# after pip installing python-gettext | |
# these lines go in django.core.management.commands.compilemessages | |
# they replace the call to "os.system" | |
from pythongettext import msgfmt | |
po = msgfmt.Msgfmt(pf + '.po') | |
moo_file = pf + '.mo' | |
with open(moo_file, 'w') as f: | |
f.write(po.get()) |