Esempio n. 1
0
 def editImage0(self, request, uuid, template):
     img = self.defaultImageModel.objects.get(uuid = uuid)
     ajax = request.POST.has_key('ajax')
     if request.method == 'POST':
         form = EditImageForm(request.POST, instance=img)
         if form.is_valid():
             # FIX: update map, etc!
             updatedObject = form.save()
             if ajax:
                 return HttpResponse(json.dumps({'result': updatedObject.getGeoJson()}),
                                     mimetype='application/json')
         else:
             if ajax:
                 return HttpResponse(json.dumps({'error': {'code': -32099,
                                                           'message': 'invalid value in form field',
                                                           'data': form._get_errors()}
                                                 }),
                                     mimetype='application/json')
     else:
         form = EditImageForm(instance=img)
     return (render_to_response
             (template,
              dict(img=img,
                   form=form),
              context_instance = RequestContext(request)))
 def submitData(self, jstr):
     obj = json.loads(jstr)
     # for now, assume it's plan status, that's all we have...
     planStat = obj['planStatus']
     for k in planStat.keys():
         if k != 'timestamp':
             try:
                 statusInfo = StatusboardPlanStatus.objects.get(keyword=k)
                 statusInfo.value = json.dumps(planStat[k])
                 statusInfo.timestamp = \
                     datetime.datetime.\
                     fromtimestamp(float(planStat['timestamp']))
                 statusInfo.save()
             except ObjectDoesNotExist:
                 StatusboardPlanStatus.objects.\
                     create(timestamp=(datetime.datetime.
                                       fromtimestamp(float(planStat['timestamp']))),
                            keyword=k,
                            value=json.dumps(planStat[k]))
Esempio n. 3
0
 def getExportSettings(self):
     exportedVars = ['SCRIPT_NAME',
                     'MEDIA_URL',
                     'DATA_URL',
                     'GALLERY_PAGE_COLS',
                     'GALLERY_PAGE_ROWS',
                     'GALLERY_THUMB_SIZE',
                     'DESC_THUMB_SIZE',
                     'MAP_BACKEND',
                     'USE_MARKER_CLUSTERING',
                     'USE_TRACKING']
     exportDict = dict(((f, getattr(settings, f))
                        for f in exportedVars))
     return json.dumps(exportDict)
Esempio n. 4
0
def getLatitudeClient(request):
    profile = None
    try:
        profile = LatitudeProfile.objects.get(user=request.user)
    except ObjectDoesNotExist:
        pass # catch this below
    if not profile or not profile.oauthToken:
        raise Exception("You have not authorized Share to monitor your position in Latitude")

    return LatitudeClient(settings.LATITUDE_CONSUMER_KEY, settings.LATITUDE_CONSUMER_SECRET,
                          profile.oauthToken, profile.oauthSecret)

@login_required
def currentPosition(request):
    c = getLatitudeClient(request)
    try:
        loc = c.getCurrentLocation()
    except LatitudeClient.LatitudeError, e:
        raise Exception("Error trying to get current location from Latitude server: %s" % e)
    return HttpResponse('<pre>%s</pre>' % json.dumps(loc, indent=4))

@login_required
def locationList(request):
    c = getLatitudeClient(request)
    try:
        loc = c.getLocationList()
    except LatitudeClient.LatitudeError, e:
        raise Exception("Error trying to get current location from Latitude server: %s" % e)
    return HttpResponse('<pre>%s</pre>' % json.dumps(loc, indent=4))
Esempio n. 5
0
 def __str__(self):
     return 'Google Latitude API error %s' % json.dumps(self.contentJson['error'])
Esempio n. 6
0
 def dumps(self, obj):
     if 1:
         return json.dumps(obj, indent=4, sort_keys=True) # pretty print for debugging
     else:
         return json.dumps(obj, separators=(',',':')) # compact
Esempio n. 7
0
 def get_db_prep_value(self, value):
     return json.dumps(value.__dict__)
Esempio n. 8
0
 def __repr__(self):
     return json.dumps(self.__dict__, indent=4)
Esempio n. 9
0
def dumps(obj):
    if settings.DEBUG:
        return json.dumps(obj, indent=4, sort_keys=True)  # pretty print
    else:
        return json.dumps(obj, separators=(",", ":"))  # compact