Commits

Anonymous committed 90f5780

Phase 1 of enabling renaming maps (ticket #1)

Comments (0)

Files changed (3)

                     map.delete_map_and_its_contents()
                     # prepare json to return with delete notification
 
+            else:
+                map = get_object_or_404(Map, id=json_model["id"])
+                if request.user == map.initiator:
+                    map.title = json_model["title"]
+                    map.save()
+                    ret_dict = map.to_dict()
+
         ret_dict["entity_type"] = entity_type
         ret_dict["method"] = method
         ret_dict["cid"] = cid

templates/admin/base.html

             {% block nav-global %}{% endblock %}
         </div>
         <!-- END Header -->
-        {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans 'Home' %}</a>{% if title %} &rsaquo; <span style="font-size: 15pt">{{ title }}</span>{% endif %} <div class="toolbar" style="float: right;">{% if is_initiator %}<a id="delete_map_link" href="#">{% trans "Delete map" %}</a>{% endif %}</div></div>{% endblock %}
+        {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans 'Home' %}</a>{% if title %} &rsaquo; <span style="font-size: 15pt">{{ title }}</span>{% endif %} <div class="toolbar" style="float: right;">{% if is_initiator %}<a id="rename_map_link" href="#">{% trans "Rename map" %}</a> | <a id="delete_map_link" href="#">{% trans "Delete map" %}</a>{% endif %}</div></div>{% endblock %}
     {% endif %}
 
     {% if messages %}

templates/map.html

                     {% endif %}
                         document.location = "/";
                     }
+                    if (entity["method"] == "update") {
+                        window.map.set({title: entity["title"]});
+                    }
                     break;
                 case "story":
                     try {
     init(options);
     window.user_id = {{ request.user.id }};
 
+    $("#rename_map_link").click(rename_map);
     $("#delete_map_link").click(delete_map);
 });
 
     }
 }
 
+function rename_map() {
+    var current_name = window.map.get("title");
+    var new_name = prompt("{% trans "Enter a new name" %}", current_name);
+    if (new_name != "" && new_name != current_name) {
+        window.map.set({title: new_name});
+        window.map.save();
+    }
+}
+
 function delete_map() {
     if (confirm("{% trans "Are you sure you want to delete this map?" %}")) {
         window.map.destroy();