Merge lp:~xtoddx/django-nova/adduser into lp:django-nova

Proposed by Todd Willey
Status: Rejected
Rejected by: Devin Carlen
Proposed branch: lp:~xtoddx/django-nova/adduser
Merge into: lp:django-nova
Diff against target: 78 lines (+41/-2)
3 files modified
src/django_nova/forms.py (+12/-0)
src/django_nova/templates/django_nova/projects/manage.html (+17/-1)
src/django_nova/views/projects.py (+12/-1)
To merge this branch: bzr merge lp:~xtoddx/django-nova/adduser
Reviewer Review Type Date Requested Status
Devin Carlen Needs Resubmitting
Review via email: mp+51855@code.launchpad.net

Description of the change

Allows adding users to projects from the project management page.

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

This is a little tricky. I don't think we can allow NASA users to add the users themselves.

Can you add a setting for enabling and disabling this? It can be enabled by default.

review: Needs Fixing
Revision history for this message
Devin Carlen (devcamcar) wrote :

I am in the process of combining the openstack-dashboard and django-nova repos. This is almost done. Pleas resubmit this patch against lp:openstack-dashboard in the django-nova folder when that is ready.

review: Needs Resubmitting

Unmerged revisions

20. By Todd Willey

Add users to projects!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/django_nova/forms.py'
2--- src/django_nova/forms.py 2011-01-21 22:38:42 +0000
3+++ src/django_nova/forms.py 2011-03-02 06:29:56 +0000
4@@ -260,3 +260,15 @@
5
6 self.fields['users'].choices = [(choices, choices) for choices in query_list]
7
8+class InviteUserForm(forms.Form):
9+ username = forms.CharField(required=True, label="Username")
10+
11+ def is_valid(self):
12+ super(InviteUserForm, self).is_valid()
13+ if not self.errors:
14+ nova = get_nova_admin_connection()
15+ user = nova.get_user(self.cleaned_data['username'])
16+ if not user:
17+ self.errors['username'] = self.error_class()
18+ self.errors['username'].append("Invalid user")
19+ return not self.errors
20
21=== modified file 'src/django_nova/templates/django_nova/projects/manage.html'
22--- src/django_nova/templates/django_nova/projects/manage.html 2011-01-12 20:02:06 +0000
23+++ src/django_nova/templates/django_nova/projects/manage.html 2011-03-02 06:29:56 +0000
24@@ -41,5 +41,21 @@
25 </div>
26 {% endif %}
27 </div>
28+
29+ <div id="invite_user">
30+ <form id="invite_user_form" method="post" action="{% url nova_project_manage project.projectname %}">
31+ {% csrf_token %}
32+ <fieldset>
33+ {% for field in invite_form %}
34+ {{ field.label_tag }}
35+ {% if field.errors %}
36+ {{ field.errors }}
37+ {% endif %}
38+ {{ field }}
39+ {% endfor %}
40+ </fieldset>
41+ <input type="submit" value="Add to Project"/>
42+ </form>
43+ </div>
44+
45 {% endblock %}
46-
47
48=== modified file 'src/django_nova/views/projects.py'
49--- src/django_nova/views/projects.py 2011-01-31 20:08:02 +0000
50+++ src/django_nova/views/projects.py 2011-03-02 06:29:56 +0000
51@@ -51,6 +51,17 @@
52 return redirect('login')
53
54 nova = get_nova_admin_connection()
55+
56+ if request.method == 'POST':
57+ invite_form = nova_forms.InviteUserForm(request.POST)
58+ if invite_form.is_valid():
59+ updated = nova.add_project_member(
60+ invite_form.cleaned_data['username'], project_id)
61+ if updated:
62+ return redirect('nova_project_manage', project_id)
63+ else:
64+ invite_form = nova_forms.InviteUserForm()
65+
66 members = nova.get_project_members(project_id)
67
68 for member in members:
69@@ -60,10 +71,10 @@
70 member.project_roles = ", ".join(project_role)
71 member.global_roles = ", ".join(global_role)
72
73-
74 return render_to_response('django_nova/projects/manage.html', {
75 'project': project,
76 'members': members,
77+ 'invite_form': invite_form
78 }, context_instance = template.RequestContext(request))
79
80

Subscribers

People subscribed via source and target branches

to status/vote changes: