Merge lp:~linaro-validation/linaro-django-xmlrpc/edit-token into lp:~linaro-validation/linaro-django-xmlrpc/trunk

Proposed by Zygmunt Krynicki
Status: Merged
Merged at revision: 28
Proposed branch: lp:~linaro-validation/linaro-django-xmlrpc/edit-token
Merge into: lp:~linaro-validation/linaro-django-xmlrpc/trunk
Diff against target: 181 lines (+55/-11)
8 files modified
.bzrignore (+2/-0)
linaro_django_xmlrpc/templates/linaro_django_xmlrpc/edit_token.html (+10/-0)
linaro_django_xmlrpc/templates/linaro_django_xmlrpc/tokens.html (+5/-3)
linaro_django_xmlrpc/test_project/manage.py (+5/-5)
linaro_django_xmlrpc/tests.py (+0/-1)
linaro_django_xmlrpc/urls.py (+1/-0)
linaro_django_xmlrpc/views.py (+27/-2)
setup.cfg (+5/-0)
To merge this branch: bzr merge lp:~linaro-validation/linaro-django-xmlrpc/edit-token
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+62854@code.launchpad.net

Description of the change

Add view for editing token descriptions + some minor changes here and there

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

All looks good, I'll merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-05-26 23:50:33 +0000
3+++ .bzrignore 2011-05-30 09:57:29 +0000
4@@ -1,3 +1,5 @@
5 *.egg-info
6 *.sqlite
7 test.db
8+build
9+dist
10
11=== added file 'linaro_django_xmlrpc/templates/linaro_django_xmlrpc/edit_token.html'
12--- linaro_django_xmlrpc/templates/linaro_django_xmlrpc/edit_token.html 1970-01-01 00:00:00 +0000
13+++ linaro_django_xmlrpc/templates/linaro_django_xmlrpc/edit_token.html 2011-05-30 09:57:29 +0000
14@@ -0,0 +1,10 @@
15+{% extends "django_testproject/base.html" %}
16+
17+{% block content %}
18+<h1>Edit token {{ token.pk }}</h1>
19+<form action="{% url linaro_django_xmlrpc.views.edit_token token.pk %}" method="POST">
20+ {% csrf_token %}
21+ {{ form.as_table }}
22+ <input type="submit" value="Submit" />
23+</form>
24+{% endblock %}
25
26=== modified file 'linaro_django_xmlrpc/templates/linaro_django_xmlrpc/tokens.html'
27--- linaro_django_xmlrpc/templates/linaro_django_xmlrpc/tokens.html 2011-05-27 03:02:23 +0000
28+++ linaro_django_xmlrpc/templates/linaro_django_xmlrpc/tokens.html 2011-05-30 09:57:29 +0000
29@@ -4,12 +4,13 @@
30 {% block content %}
31 <h1>Authentication tokens</h1>
32 {% if token_list %}
33-<table>
34+<table border="1">
35 <tr>
36 <th>Description</th>
37 <th>Created on</th>
38 <th>Last used on</th>
39 <th>Secret</th>
40+ <th>Actions</th>
41 </tr>
42 {% for token in token_list %}
43 <tr>
44@@ -18,10 +19,11 @@
45 <td>{{ token.last_used_on|default_if_none:"Never" }}</td>
46 <td>
47 <button id="button_{{ forloop.counter }}" onclick='document.getElementById("secret_{{ forloop.counter }}").style.display="block"; this.style.display="none";'>Show</button>
48- <code id="secret_{{ forloop.counter }}" style="display: none;">{{ token.secret }}</code>
49+ <code style="overflow: auto; width: 25em; display:none;" id="secret_{{ forloop.counter }}">{{ token.secret }}</code>
50 </td>
51 <td>
52 <a href="{% url linaro_django_xmlrpc.views.delete_token token.pk %}">delete this token</a>
53+ <a href="{% url linaro_django_xmlrpc.views.edit_token token.pk %}">edit the description</a>
54 </td>
55 </tr>
56 {% endfor %}
57@@ -29,5 +31,5 @@
58 {% else %}
59 <p>There are no tokens associated with your account yet</p>
60 {% endif %}
61-<p>You can <a href="{% url linaro_django_xmlrpc.views.create_token %}">create authentication tokens</a> manually.</p>
62+<p>You can <a href="{% url linaro_django_xmlrpc.views.create_token %}">create new authentication token</a>.</p>
63 {% endblock %}
64
65=== modified file 'linaro_django_xmlrpc/test_project/manage.py'
66--- linaro_django_xmlrpc/test_project/manage.py 2011-05-16 11:30:50 +0000
67+++ linaro_django_xmlrpc/test_project/manage.py 2011-05-30 09:57:29 +0000
68@@ -1,11 +1,11 @@
69 #!/usr/bin/env python
70 from django.core.management import execute_manager
71 try:
72- import settings # Assumed to be in the same directory.
73-except ImportError:
74- import sys
75- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
76- sys.exit(1)
77+ from linaro_django_xmlrpc.test_project import settings
78+except ImportError as ex:
79+ import logging
80+ logging.exception("Unable to import application settings")
81+ raise SystemExit(ex)
82
83 if __name__ == "__main__":
84 execute_manager(settings)
85
86=== modified file 'linaro_django_xmlrpc/tests.py'
87--- linaro_django_xmlrpc/tests.py 2011-05-30 09:51:43 +0000
88+++ linaro_django_xmlrpc/tests.py 2011-05-30 09:57:29 +0000
89@@ -24,7 +24,6 @@
90
91 from django.contrib.auth.models import User
92 from django.core.urlresolvers import reverse
93-from django.template import RequestContext
94 from django_testscenarios.ubertest import TestCase, TestCaseWithScenarios
95
96 from linaro_django_xmlrpc.models import (
97
98=== modified file 'linaro_django_xmlrpc/urls.py'
99--- linaro_django_xmlrpc/urls.py 2011-05-26 23:50:33 +0000
100+++ linaro_django_xmlrpc/urls.py 2011-05-30 09:57:29 +0000
101@@ -26,4 +26,5 @@
102 url(r'^tokens/$', "tokens"),
103 url(r'^tokens/create/$', "create_token"),
104 url(r'^tokens/(?P<object_id>\d+)/delete/$', "delete_token"),
105+ url(r'^tokens/(?P<object_id>\d+)/edit/$', "edit_token"),
106 )
107
108=== modified file 'linaro_django_xmlrpc/views.py'
109--- linaro_django_xmlrpc/views.py 2011-05-30 09:51:43 +0000
110+++ linaro_django_xmlrpc/views.py 2011-05-30 09:57:29 +0000
111@@ -21,6 +21,7 @@
112 """
113
114 import base64
115+import logging
116
117 from django.contrib.auth.decorators import login_required
118 from django.contrib.csrf.middleware import csrf_exempt
119@@ -71,7 +72,6 @@
120 try:
121 user = AuthToken.get_user_for_secret(username, secret)
122 except Exception:
123- import logging
124 logging.exception("bug")
125 if user is None:
126 response = HttpResponse("Invalid token", status=401)
127@@ -85,6 +85,8 @@
128 response['Content-length'] = str(len(response.content))
129 return response
130 else:
131+ # Split this to different view, redirect.
132+ # TODO: check xml-rpc spec to see what is recommended on GET requests.
133 system = SystemAPI(mapper)
134 methods = [{
135 'name': method,
136@@ -139,7 +141,10 @@
137 form = AuthTokenForm()
138 return render_to_response(
139 "linaro_django_xmlrpc/create_token.html",
140- {"form": form}, RequestContext(request))
141+ {
142+ "form": form,
143+ },
144+ RequestContext(request))
145
146
147 @login_required
148@@ -155,3 +160,23 @@
149 'token': token,
150 },
151 RequestContext(request))
152+
153+
154+@login_required
155+def edit_token(request, object_id):
156+ token = get_object_or_404(AuthToken, pk=object_id, user=request.user)
157+ if request.method == "POST":
158+ form = AuthTokenForm(request.POST, instance=token)
159+ if form.is_valid():
160+ form.save()
161+ return HttpResponseRedirect(
162+ reverse("linaro_django_xmlrpc.views.tokens"))
163+ else:
164+ form = AuthTokenForm(instance=token)
165+ return render_to_response(
166+ "linaro_django_xmlrpc/edit_token.html",
167+ {
168+ "token": token,
169+ "form": form,
170+ },
171+ RequestContext(request))
172
173=== added file 'setup.cfg'
174--- setup.cfg 1970-01-01 00:00:00 +0000
175+++ setup.cfg 2011-05-30 09:57:29 +0000
176@@ -0,0 +1,5 @@
177+[upload_docs]
178+upload-dir=build/sphinx/html
179+
180+[upload]
181+sign=True

Subscribers

People subscribed via source and target branches