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
# https://gist.github.com/tobych/6372218 | |
# Monkey patch to work around https://code.djangoproject.com/ticket/13843 | |
import django | |
from functools import wraps | |
def discard_exceptions(f): | |
@wraps(f) | |
def wrapper(*args, **kwds): | |
try: |
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
def patched__del__(self): | |
if self.ptr: lgeos.finishGEOS_r(self.ptr) | |
import django | |
django.contrib.gis.geos.prototypes.threadsafe.GEOSContextHandle.__del__ = patched__del__ |
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
<span class="statusLabel" data-status="{{ status.name }}">{{ status.name }}</span> | |
... | |
<script type="text/javascript"> | |
$('.statusLabel').addClass(function() { | |
var classes = { | |
"Never seen": 'label', | |
"OK": "label label-success", | |
"Relocated": "label label-warning", | |
"Missing": "label label-danger" | |
} |
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
class TruckResource(ModelResource): | |
class Meta: | |
queryset = Truck.objects.all() | |
list_allowed_methods = ['get'] | |
detail_allowed_methods = ['get'] | |
filtering = {'owner': ALL_WITH_RELATIONS, 'truck_number': ALL} |