Skip to content

Instantly share code, notes, and snippets.

View samirbr's full-sized avatar

Sam Aouar samirbr

View GitHub Profile
class TokenViewSet(viewsets.GenericViewSet):
def retrieve(self, request, pk=None):
if request.user.is_authenticated():
token, created = Token.objects.get_or_create(user=request.user)
return Response({ 'token': token.key })
else:
return Response({
'status': 'Access Denied!',
'message': 'This account is not active!'
class MapFilterForm(forms.Form):
form = None
created__gte = forms.DateField(required=False)
created__lte = forms.DateField(required=False)
device = forms.ModelChoiceField(queryset=DeviceTeam.objects.all(),
required=False)
device__in = forms.ModelMultipleChoiceField(queryset=Device.objects.all(),
required=False)
def __init__(self, form=form, data=None, files=None, auto_id='id_%s', prefix=None,
from django.core import serializers
from django.shortcuts import get_object_or_404
from django.views.generic import ListView
from form.models import Form
from ..forms import MapFilterForm
from ..models import Harvest
class FormMap(ListView):
<!DOCTYPE html>
<html>
<head>
<!-- Mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Twitter Bootstrap -->
<!-- DatePicker -->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
var tmp = [];
harvests.filter(function(harvest) {
var question;
// use Array.prototype.filter
question = questions.filter(function (question) {
// supondo harvest.question ==> id da questao
// do contrario use harvest.question.id
return harvest.question == question.id;
.gridStyle {
border: 1px solid rgb(212,212,212);
width: 400px;
height: 300px;
}
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));
});
angular.module('myApp')
.factory('Harvest', [
'$resource',
function ($resource) {
return $resource('/viewver/api/harvest_viewver/?id', {'id': '@id'}, {
create: { method: 'POST' }
update: { method: 'PUT' }
});
}
]);
<!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;
}
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
nggettext_compile: {
all: {
options: {
format: "json"
},
files: [