This file contains hidden or 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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import migrations, models | |
def update_plans(apps, schema_editor): | |
# free to Free | |
for user in User.objects.filter(plan='free'): | |
user.plan = 'Free' | |
user.save() |
This file contains hidden or 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
def remove_keys(d, keys): | |
for key in keys: | |
d.pop(key) | |
return d | |
for consistency in Consistency.objects.filter(question__parent_id=form_to_copy.id): | |
c_dict = generic_as_dict(consistency) | |
c_dict = remove_keys(c_dict, ['id', 'condition', 'question']) | |
cond_dict = generic_as_dict(consistency.condition) |
This file contains hidden or 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
<div ng-controller="UploadOptionController"> | |
<!-- $scope must have a method fromFile that receives the content --> | |
<!-- $scope.fromFile = function(content) { ... } | |
<div> | |
<label>Separator</label> | |
<input type="text" ng-model="upload.needle" name="needle"> | |
<div> | |
<input class="hide" type="file" ng-model="upload.file" name="file" | |
onchange="angular.element(this).scope().upload.load().then(angular.element(this).scope().fromFile)"> |
This file contains hidden or 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
def copy(o, replacements, exclude): | |
d = model_to_dict(o) | |
for key in exclude: | |
d.pop(key) | |
for key in replacements.keys(): | |
d[key] = replacements[key] | |
obj = o.__class__.objects.create(**d) |
This file contains hidden or 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
""" | |
Classes that represent database functions. | |
""" | |
from django.db.models import IntegerField | |
from django.db.models.expressions import Func, Value | |
class Coalesce(Func): | |
""" | |
Chooses, from left to right, the first non-null expression and returns it. | |
""" |
This file contains hidden or 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 django.db.models.expressions import F | |
def __floordiv__(self, other): | |
return self._combine(other, '||', False) | |
F.__floordiv__ = __floordiv__ | |
class CF(F): | |
""" | |
A coalesced expression representing the value of the given field. | |
""" |
This file contains hidden or 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
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
nggettext_compile: { | |
all: { | |
options: { | |
format: "json" | |
}, | |
files: [ |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- http://jsfiddle.net/p7snevh1/81/ by myself --> | |
<style> | |
html, body { height: 100%; } | |
#list { height: 100%; } | |
#list>.item { | |
height: 18px; padding: 2px 0; border-bottom: solid 1px gray; overflow: hidden; | |
} |
This file contains hidden or 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
angular.module('myApp') | |
.factory('Harvest', [ | |
'$resource', | |
function ($resource) { | |
return $resource('/viewver/api/harvest_viewver/?id', {'id': '@id'}, { | |
create: { method: 'POST' } | |
update: { method: 'PUT' } | |
}); | |
} | |
]); |
This file contains hidden or 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
Array.prototype.forEach(document.querySelectorAll('[bind]'), function (bindable) { | |
this.value = application[this.attribues.get('bind')]; | |
bindable.addEventListener('keyup', (function (event) { | |
application[this.attribues.get('bind')] = this.value; | |
}).bind(bindable)); | |
}); |