Skip to content

Commit b83e0d2

Browse files
committed
Unify the URL name handling in ietfauth, i.e. just refer directly to
the view behind the URL instead of naming it. - Legacy-Id: 11172
1 parent 4d4cf93 commit b83e0d2

15 files changed

Lines changed: 36 additions & 34 deletions

ietf/ietfauth/forms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ class ResetPasswordForm(forms.Form):
8585
username = forms.EmailField(label="Your email (lowercase)")
8686

8787
def clean_username(self):
88+
import ietf.ietfauth.views
8889
username = self.cleaned_data["username"]
8990
if not User.objects.filter(username=username).exists():
90-
raise forms.ValidationError(mark_safe("Didn't find a matching account. If you don't have an account yet, you can <a href=\"{}\">create one</a>.".format(urlreverse("create_account"))))
91+
raise forms.ValidationError(mark_safe("Didn't find a matching account. If you don't have an account yet, you can <a href=\"{}\">create one</a>.".format(urlreverse(ietf.ietfauth.views.create_account))))
9192
return username
9293

9394

ietf/ietfauth/tests.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pyquery import PyQuery
66

77
from django.core.urlresolvers import reverse as urlreverse
8+
import django.contrib.auth.views
89
from django.contrib.auth.models import User
910
from django.conf import settings
1011

@@ -14,6 +15,7 @@
1415
from ietf.person.models import Person, Email
1516
from ietf.group.models import Group, Role, RoleName
1617
from ietf.ietfauth.htpasswd import update_htpasswd_file
18+
import ietf.ietfauth.views
1719

1820
class IetfAuthTests(TestCase):
1921
def setUp(self):
@@ -36,29 +38,29 @@ def tearDown(self):
3638
settings.HTDIGEST_REALM = self.saved_htdigest_realm
3739

3840
def test_index(self):
39-
self.assertEqual(self.client.get(urlreverse("ietf.ietfauth.views.index")).status_code, 200)
41+
self.assertEqual(self.client.get(urlreverse(ietf.ietfauth.views.index)).status_code, 200)
4042

4143
def test_login_and_logout(self):
4244
make_test_data()
4345

4446
# try logging in without a next
45-
r = self.client.get(urlreverse("account_login"))
47+
r = self.client.get(urlreverse(django.contrib.auth.views.login))
4648
self.assertEqual(r.status_code, 200)
4749

48-
r = self.client.post(urlreverse("account_login"), {"username":"plain", "password":"plain+password"})
50+
r = self.client.post(urlreverse(django.contrib.auth.views.login), {"username":"plain", "password":"plain+password"})
4951
self.assertEqual(r.status_code, 302)
50-
self.assertEqual(urlsplit(r["Location"])[2], "/accounts/profile/")
52+
self.assertEqual(urlsplit(r["Location"])[2], urlreverse(ietf.ietfauth.views.profile))
5153

5254
# try logging out
53-
r = self.client.get(urlreverse("account_logout"))
55+
r = self.client.get(urlreverse(django.contrib.auth.views.logout))
5456
self.assertEqual(r.status_code, 200)
5557

56-
r = self.client.get(urlreverse("account_profile"))
58+
r = self.client.get(urlreverse(ietf.ietfauth.views.profile))
5759
self.assertEqual(r.status_code, 302)
58-
self.assertEqual(urlsplit(r["Location"])[2], "/accounts/login/")
60+
self.assertEqual(urlsplit(r["Location"])[2], urlreverse(django.contrib.auth.views.login))
5961

6062
# try logging in with a next
61-
r = self.client.post(urlreverse("account_login") + "?next=/foobar", {"username":"plain", "password":"plain+password"})
63+
r = self.client.post(urlreverse(django.contrib.auth.views.login) + "?next=/foobar", {"username":"plain", "password":"plain+password"})
6264
self.assertEqual(r.status_code, 302)
6365
self.assertEqual(urlsplit(r["Location"])[2], "/foobar")
6466

@@ -87,7 +89,7 @@ def username_in_htpasswd_file(self, username):
8789
def test_create_account(self):
8890
make_test_data()
8991

90-
url = urlreverse('create_account')
92+
url = urlreverse(ietf.ietfauth.views.create_account)
9193

9294
# get
9395
r = self.client.get(url)
@@ -126,7 +128,7 @@ def test_profile(self):
126128
username = "plain"
127129
email_address = Email.objects.filter(person__user__username=username).first().address
128130

129-
url = urlreverse('account_profile')
131+
url = urlreverse(ietf.ietfauth.views.profile)
130132
login_testing_unauthorized(self, username, url)
131133

132134

@@ -228,7 +230,7 @@ def test_profile(self):
228230

229231

230232
def test_reset_password(self):
231-
url = urlreverse('password_reset')
233+
url = urlreverse(ietf.ietfauth.views.password_reset)
232234

233235
user = User.objects.create(username="someone@example.com", email="someone@example.com")
234236
user.set_password("forgotten")

ietf/ietfauth/urls.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
from django.contrib.auth.views import login, logout
55

66
urlpatterns = patterns('ietf.ietfauth.views',
7-
url(r'^$', 'index', name='account_index'),
7+
url(r'^$', 'index'),
88
# url(r'^login/$', 'ietf_login'),
99
url(r'^login/$', login, name="account_login"),
10-
url(r'^logout/$', logout, name="account_logout"),
10+
url(r'^logout/$', logout),
1111
# url(r'^loggedin/$', 'ietf_loggedin'),
1212
# url(r'^loggedout/$', 'logged_out'),
13-
url(r'^profile/$', 'profile', name="account_profile"),
13+
url(r'^profile/$', 'profile'),
1414
# (r'^login/(?P<user>[a-z0-9.@]+)/(?P<passwd>.+)$', 'url_login'),
1515
url(r'^testemail/$', 'test_email'),
16-
url(r'^create/$', 'create_account', name='create_account'),
17-
url(r'^create/confirm/(?P<auth>[^/]+)/$', 'confirm_account', name='confirm_account'),
18-
url(r'^reset/$', 'password_reset', name='password_reset'),
19-
url(r'^reset/confirm/(?P<auth>[^/]+)/$', 'confirm_password_reset', name='confirm_password_reset'),
20-
url(r'^confirmnewemail/(?P<auth>[^/]+)/$', 'confirm_new_email', name='confirm_new_email'),
16+
url(r'^create/$', 'create_account'),
17+
url(r'^create/confirm/(?P<auth>[^/]+)/$', 'confirm_account'),
18+
url(r'^reset/$', 'password_reset'),
19+
url(r'^reset/confirm/(?P<auth>[^/]+)/$', 'confirm_password_reset'),
20+
url(r'^confirmnewemail/(?P<auth>[^/]+)/$', 'confirm_new_email'),
2121
)

ietf/ietfauth/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def confirm_account(request, auth):
114114
raise Http404("Invalid or expired auth")
115115

116116
if User.objects.filter(username=email).exists():
117-
return redirect("account_profile")
117+
return redirect(profile)
118118

119119
success = False
120120
if request.method == 'POST':

ietf/meeting/tests_js.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def absreverse(self,*args,**kwargs):
4545
return '%s%s'%(self.live_server_url,urlreverse(*args,**kwargs))
4646

4747
def login(self):
48-
#url = self.absreverse('ietf.ietfauth.views.login')
49-
url = '%s%s'%(self.live_server_url,'/accounts/login')
48+
url = '%s%s'%(self.live_server_url, urlreverse('django.contrib.auth.views.login'))
5049
self.driver.get(url)
5150
self.driver.find_element_by_name('username').send_keys('plain')
5251
self.driver.find_element_by_name('password').send_keys('plain+password')

ietf/templates/base/menu_user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{% endif %}
2323
{% endif %}
2424

25-
<li><a href="{% url "create_account" %}">{% if request.user.is_authenticated %}Manage account{% else %}New account{% endif %}</a></li>
25+
<li><a href="{% url "ietf.ietfauth.views.create_account" %}">{% if request.user.is_authenticated %}Manage account{% else %}New account{% endif %}</a></li>
2626
<li><a href="{%url "ietf.cookies.views.preferences" %}" rel="nofollow">Preferences</a></li>
2727

2828
{% if user|has_role:"Area Director" %}

ietf/templates/doc/change_shepherd.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<h1>Change document shepherd<br><small>{{ doc.name }}-{{ doc.rev }}</small></h1>
1717

1818
<p>The shepherd needs to have a Datatracker account. A new account can be
19-
<a href="{% url "create_account" %}">created here</a>.</p>
19+
<a href="{% url "ietf.ietfauth.views.create_account" %}">created here</a>.</p>
2020

2121
<form enctype="multipart/form-data" method="post">
2222
{% csrf_token %}

ietf/templates/group/edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>
3232

3333
<p class="alert alert-info">Note that persons with authorization to manage information, e.g.
3434
chairs and delegates, need a datatracker account to actually do
35-
so. New accounts can be <a href="{% url "create_account" %}">created here</a>.</p>
35+
so. New accounts can be <a href="{% url "ietf.ietfauth.views.create_account" %}">created here</a>.</p>
3636

3737
<form class="form-horizontal" method="post">
3838
{% csrf_token %}

ietf/templates/group/stream_edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h1>Manage {{ group.name }} RFC stream</h1>
2727
<p>
2828
Delegates can be assigned with permission to do the tasks of the
2929
chair{{ chairs|pluralize }}. Note that in order to actually do so, the delegates need a
30-
datatracker account. New accounts can be <a href="{% url "create_account" %}">created here</a>.
30+
datatracker account. New accounts can be <a href="{% url "ietf.ietfauth.views.create_account" %}">created here</a>.
3131
</p>
3232

3333
<form method="post">

ietf/templates/registration/add_email_email.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Hello,
33

44
{% filter wordwrap:73 %}We have received a request to add the email address {{ email }} to the user account '{{ person.user }}' at {{ domain }}. If you requested this change, please confirm that this is your email address by clicking on following link:{% endfilter %}
55

6-
https://{{ domain }}{% url "confirm_new_email" auth %}
6+
https://{{ domain }}{% url "ietf.ietfauth.views.confirm_new_email" auth %}
77

88
This link will expire in {{ expire }} days.
99

0 commit comments

Comments
 (0)