Merge lp:~jakedahn/horizon/lp732493 into lp:~hudson-openstack/horizon/trunk

Proposed by Jake Dahn
Status: Merged
Approved by: Devin Carlen
Approved revision: 24
Merged at revision: 22
Proposed branch: lp:~jakedahn/horizon/lp732493
Merge into: lp:~hudson-openstack/horizon/trunk
Diff against target: 106 lines (+36/-17)
3 files modified
django-nova/src/django_nova/adminclient.py (+7/-0)
django-nova/src/django_nova/templates/admin/django_nova/project/edit_project.html (+3/-14)
django-nova/src/django_nova/views/admin.py (+26/-3)
To merge this branch: bzr merge lp:~jakedahn/horizon/lp732493
Reviewer Review Type Date Requested Status
Devin Carlen Approve
Review via email: mp+52819@code.launchpad.net

Description of the change

This branch adds the ability to modify the project manager of any given project from the django-admin interface.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'django-nova/src/django_nova/adminclient.py'
2--- django-nova/src/django_nova/adminclient.py 2011-03-03 01:20:17 +0000
3+++ django-nova/src/django_nova/adminclient.py 2011-03-10 11:04:08 +0000
4@@ -466,6 +466,13 @@
5 'Operation': operation}
6 return self.apiconn.get_status('ModifyProjectMember', params)
7
8+ def modify_project(self, projectname, manager_user=None, description=None):
9+ """Modifies an existing project."""
10+ params = {'Name': projectname,
11+ 'ManagerUser': manager_user,
12+ 'Description': description}
13+ return self.apiconn.get_status('ModifyProject', params)
14+
15 def get_zip(self, user, project):
16 """
17 Returns the content of a zip file containing novarc and access credentials.
18
19=== modified file 'django-nova/src/django_nova/templates/admin/django_nova/project/edit_project.html'
20--- django-nova/src/django_nova/templates/admin/django_nova/project/edit_project.html 2011-03-03 01:20:17 +0000
21+++ django-nova/src/django_nova/templates/admin/django_nova/project/edit_project.html 2011-03-10 11:04:08 +0000
22@@ -26,7 +26,8 @@
23 <div id="content-main">
24 {% block object-tools %}
25 {% endblock %}
26- <form action="#" method="post" enctype="multipart/form-data">
27+
28+ <form action="." method="post" enctype="multipart/form-data">
29 {% csrf_token %}
30 <fieldset class="module aligned {{ fieldset.classes }}">
31 {% for field in form.visible_fields %}
32@@ -39,24 +40,12 @@
33 {% for field in form.hidden_fields %}
34 {{ field }}
35 {% endfor %}
36- <div class="form-row">
37- <label for="project_name">Project Name</label>
38- <span id="project_name" style="display: block; padding-top: 5px; padding-left: 5px; float: left;"><em>{{projectname}}</em></span>
39- </div>
40- <div class="form-row">
41- <label for="project_description">Description</label>
42- <span id="project_description" style="display: block; padding-top: 5px; padding-left: 5px; float: left;"><em>{{description}}</em></span>
43- </div>
44- <div class="form-row">
45- <label for="project_manager">Project Manager</label>
46- <span id="project_manager" style="display: block; padding-top: 5px; padding-left: 5px; float: left;"><em>{{manager}}</em></span>
47- </div>
48 </fieldset>
49 <div class="submit-row">
50 <p class="deletelink-box">
51 <a href="{% url delete_project project.projectname %}" class="deletelink">Delete Project</a>
52 </p>
53- {# <input type="submit" value="Save" class="default" /> #}
54+ <input type="submit" value="Save" class="default" />
55 </div>
56
57 </form>
58
59=== modified file 'django-nova/src/django_nova/views/admin.py'
60--- django-nova/src/django_nova/views/admin.py 2011-03-03 01:20:17 +0000
61+++ django-nova/src/django_nova/views/admin.py 2011-03-10 11:04:08 +0000
62@@ -107,10 +107,35 @@
63 nova = get_nova_admin_connection()
64 project = nova.get_project(project_name)
65 users = nova.get_project_members(project_name)
66+
67 try:
68 manager = auth_models.User.objects.get(username=project.projectManagerId)
69 except auth_models.User.DoesNotExist:
70 manager = None
71+
72+ if request.method == 'POST':
73+ form = forms.ProjectForm(request.POST)
74+ if form.is_valid():
75+ try:
76+ nova.modify_project(form.cleaned_data["projectname"],
77+ form.cleaned_data["manager"],
78+ form.cleaned_data["description"])
79+ messages.success(request,
80+ 'Successfully modified the project %s.' %
81+ project_name)
82+ except boto.exception.EC2ResponseError, e:
83+ messages.error(request,
84+ 'Unable modify the project %s: %s - %s' %
85+ (project_name, e.code, e.error_message))
86+
87+
88+ return redirect('admin_project', request.POST["projectname"])
89+ else:
90+ form = forms.ProjectForm(initial={'projectname': project.projectname,
91+ 'description': project.description,
92+ 'manager': manager
93+ })
94+
95
96 for user in users:
97 project_role = [str(role.role) for role in nova.get_user_roles(user.memberId, project_name)]
98@@ -122,9 +147,7 @@
99 return render_to_response('admin/django_nova/project/edit_project.html', {
100 'project' : project,
101 'users' : users,
102- 'projectname': project.projectname,
103- 'manager': manager,
104- 'description': project.description,
105+ 'form': form,
106 }, context_instance = template.RequestContext(request))
107
108

Subscribers

People subscribed via source and target branches