Udi Bauman avatar Udi Bauman committed aed3524

cosmetic

Comments (0)

Files changed (5)

     schedule_date = models.DateTimeField(null=True, blank=True)
     is_completed = models.BooleanField(default=False)
     created_on = models.DateTimeField(auto_now_add=True)
-
+    last_update = models.DateTimeField(auto_now=True)
     #the following key should be ForeignKey(releases.models.Release) but I couldn't resolve the circular inclusion
     #temporarily I use an ID instead.
     release = models.CharField(_("Release name"),max_length=255,null=True,blank=True)
+
     def to_dict(self):
         ans=model_to_dict(self)
         #TOOD: why do i need to replace release_id?
 
     def is_overdue(self):
         if self.schedule_date:
-            return self.schedule_date<datetime.now()
+            return (datetime.now() - self.schedule_date).days >= 1
         return False
 
     def schedule_date_string(self):
     class Meta:
         verbose_name_plural = "stories"
 
-    def is_late(self):
+    def is_overdue(self):
         if self.schedule_date:
-            if datetime.today() >= self.schedule_date:
-                return True
+            return (datetime.now() - self.schedule_date).days >= 1
         return False
 
 ANSWER_TYPE_TEXT = 1
 @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)
 
Add a comment to this file

static/img/indicator.gif

Added
New image

templates/add_story_dialog.html

         $( "#id_schedule_date" ).datepicker({ "dateFormat": 'yy-mm-dd' }).datepicker('setDate', new Date(date));
     });
 
+    function indicate_upload() {
+        $("#preview").attr("src", "/static/img/indicator.gif");
+        return true;
+    }
+
+
     function handle_image_upload(image_url) {
         $("#id_image_url").val(image_url);
         $("#preview").attr("src", image_url);
     }
+
 </script>
     <table width="80%" border="0" cellpadding="5">
         <tr>
                 {% trans "Image" %}:<br/>
                 {{ form.image_url }}<br/>
 
-                <form action="{{ upload_url}}" method="POST" enctype="multipart/form-data" target="upload_iframe">
+                <form action="{{ upload_url}}" onsubmit="return indicate_upload()" method="POST" enctype="multipart/form-data" target="upload_iframe">
                      {% csrf_token %}
                      {% render_upload_data upload_data %}
                      {{ upload_form.as_p }}<input type="submit" value="{% trans "Upload" %}">

templates/dashboard.html

 {% extends 'admin/base_site.html' %}
 {% load i18n %}
-{% block title %}{{ map.title }}{{ block.super }}{% endblock %}
+{% block title %}{{ block.super }}{% endblock %}
 
 {% block content %}
     <script src="/static/js/libs/jquery.min.js"></script>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.