File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,6 @@ table.form th.headerrow {
369
369
}
370
370
371
371
table .form th {
372
- font-weight : normal;
373
372
text-align : left;
374
373
vertical-align : top;
375
374
padding-top : 0.6em ;
Original file line number Diff line number Diff line change @@ -134,7 +134,35 @@ <h2>Settings</h2>
134
134
135
135
< div class ="box ">
136
136
< h2 > Authentication</ h2 >
137
- < a href ="{% url 'password_change' %} "> Change password</ a >
137
+
138
+ < table class ="form ">
139
+ < tr >
140
+ < th > Password:</ th >
141
+ < td > < a href ="{% url 'password_change' %} "> Change password</ a >
142
+ </ tr >
143
+ < tr >
144
+ < th > API Token:</ th >
145
+ < td >
146
+ {% if api_token %}
147
+ < input id ="token " style ="width: 25em; " readonly value ="{{ api_token }} ">
148
+ < button type ="button " class ="btn-copy " title ="Copy to clipboard "
149
+ data-clipboard-target ="#token "> Copy</ button >
150
+ {% endif %}
151
+ </ td >
152
+ < tr >
153
+ < th > </ th >
154
+ < td >
155
+ < form method ="post " action ="{% url 'generate_token' %} ">
156
+ {% csrf_token %}
157
+ {% if api_token %}
158
+ < input type ="submit " value ="Regenerate token "/>
159
+ {% else %}
160
+ < input type ="submit " value ="Generate token "/>
161
+ {% endif %}
162
+ </ form >
163
+ </ td >
164
+ </ tr >
165
+ </ table >
138
166
</ div >
139
167
140
168
</ div >
Original file line number Diff line number Diff line change 235
235
236
236
urlpatterns += [
237
237
url (r'^api/(?:(?P<version>(1.0))/)?' , include (api_patterns )),
238
+
239
+ # token change
240
+ url (r'^user/generate-token/$' , user_views .generate_token ,
241
+ name = 'generate_token' ),
238
242
]
239
243
240
244
Original file line number Diff line number Diff line change 41
41
from patchwork .models import Project
42
42
from patchwork .models import State
43
43
from patchwork .views import generic_list
44
+ from patchwork .views import utils
44
45
45
46
46
47
def register (request ):
@@ -126,6 +127,7 @@ def profile(request):
126
127
.extra (select = {'is_optout' : optout_query })
127
128
context ['linked_emails' ] = people
128
129
context ['linkform' ] = EmailForm ()
130
+ context ['api_token' ] = request .user .profile .token
129
131
130
132
return render (request , 'patchwork/profile.html' , context )
131
133
@@ -232,3 +234,9 @@ def todo_list(request, project_id):
232
234
context ['action_required_states' ] = \
233
235
State .objects .filter (action_required = True ).all ()
234
236
return render (request , 'patchwork/todo-list.html' , context )
237
+
238
+
239
+ @login_required
240
+ def generate_token (request ):
241
+ utils .regenerate_token (request .user )
242
+ return HttpResponseRedirect (reverse ('user-profile' ))
You can’t perform that action at this time.
0 commit comments