Source

ekkli-maps / maps / views.py

Diff from to

maps/views.py

 @login_required 
 def dashboard(request):
     user = request.user
-    maps = Map.objects.all()
     return render_to_response('dashboard.html', locals())
 
 
         }
         if story.is_approved:
             params["style"] = "fill:#1dc43a;fill-opacity:1"
-        elif story.is_late():
+        elif story.is_overdue():
             params["style"] = "fill:red;fill-opacity:1"
         et.SubElement(g, 'circle', attrib=params)
         text = et.SubElement(g, 'text', id="story-text-277",
 
 def message_handler(request):
     client_id = request.user.email
+    map_updated = False
 
     if request.POST:
         # GET THE PARAMETERS
                 if "is_approved" in json_model:
                     story.is_approved = json_model["is_approved"]
                 story.save()
+                map_updated = True
                 ret_dict = story.to_dict()
         elif entity_type == "answer":
 
                 answer.web_link = json_model.get("web_link", None)
                 answer.media_link = json_model.get("media_link", None)
                 answer.save()
+                map_updated = True
                 ret_dict = answer.to_dict()
 
         ret_dict["entity_type"] = entity_type
         ret_dict["method"] = method
         ret_dict["cid"] = cid
         json = simplejson.dumps(ret_dict, default=dthandler)
+
+        logging.info("%" * 100)
+        if map_updated:
+            map = get_object_or_404(Map, id=json_model["map_id"])
+            logging.info("Updating map %s" % map.title)
+            map.save()
+            logging.info("%" * 100)
+
         # SEND THE MESSAGE TO ALL THE CONNECTED USERS
         logging.info("*" * 80)
         logging.info("Sending to users: " + json)
 
 @login_required()
 def get_maps(request):
-    mapsRaw = [map.to_dict() for map in Map.objects.all()]
+    mapsRaw = [map.to_dict() for map in Map.objects.all().order_by("-last_update")]
     maps = simplejson.dumps(mapsRaw, default=dthandler)
     return HttpResponse(maps)