Commits

u...@localhost  committed 9bac909

Incremental: phase 1 of Delete map

  • Participants
  • Parent commits 0a0f4a4

Comments (0)

Files changed (3)

File maps/views.py

     return render_to_response('dashboard.html', locals())
 
 
-def create_map(request, group_profile, map_template,release_name=None,deliverable_name=None):
+def create_map(name, group_profile, map_template, initiator, release_name=None):
     map = Map()
-    name = request.POST.get("name", _("Untitled"))
-    if release_name:
-        map.title = "%s - %s - %s" % (release_name,deliverable_name,name)
-    else:
-        map.title = name
+    if name is None:
+        name = _("Untitled")
+    map.title = name
     map.group_profile = group_profile
-    map.initiator = request.user
+    map.initiator = initiator
     map.release=release_name
     map.save()
     if map_template:
         for entry in template_entries:
             story = Story()
             story.title = entry.title
-            story.by = request.user
+            story.by = initiator
             story.map = map
             story.story_type = entry.story_type
             story.save()
 @login_required
 def map(request, map_id=None):
     # if no id given, create a new map, using the default template of the current user's group
+    user = request.user
     if map_id:
         map = Map.objects.get(id=map_id)
+        is_initiator = user == map.initiator
     else:
-        user = request.user
-
+        is_initiator = True
         user_profile = user.profile.all()[0]
         group_profile = user_profile.group_profile
 
 #            map_template = group_profile.default_template
             map_template = None
 
-        map = create_map(request,group_profile, map_template)
+        map = create_map(None, group_profile, map_template, user)
 #        return HttpResponseRedirect(reverse("view_map", map_id=map.id))
         return HttpResponseRedirect("/map/%d/" % map.id)
 

File releases/views.py

         deliverable = Deliverable.objects.create(release = release,group_profile = user_profile.group_profile,
                                                  release_manager = request.user,deliverable_type=deliverable_type)
         deliverable.name = deliverable_type.name
-        deliverable.map = create_map(request,user_profile.group_profile, deliverable_type.map_template,
-                                     release_name,deliverable_type.name)
+        map_name = "%s - %s" % (release.name, deliverable_type.name)
+        deliverable.map = create_map(map_name, user_profile.group_profile, deliverable_type.map_template, request.user, release_name)
         deliverable.map.save()
         deliverable.save()
 

File 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>{% 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 href="#">{% trans "Delete map" %}</a>{% endif %}</div></div>{% endblock %}
     {% endif %}
 
     {% if messages %}