]> git.ipfire.org Git - thirdparty/patchwork.git/commit
views: Don't render token section of user profile if REST API disabled
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Tue, 19 Dec 2017 05:41:27 +0000 (16:41 +1100)
committerStephen Finucane <stephen@that.guru>
Thu, 4 Jan 2018 11:29:58 +0000 (11:29 +0000)
commit14034e8a44a497d32f56f31a0fdc4473336d92af
treebe563f3cd93471f7a6f92d92cec3415d67e54dce
parent8ac8e7a618e0c94a7d2c9aacb3c005949b3cb694
views: Don't render token section of user profile if REST API disabled

In profile.html, if settings.ENABLE_REST_API == False, trying to render a
link to the generate_token page will raise a NoReverseMatch exception, so
we shouldn't render that. In any case, if the REST API is disabled, we
really shouldn't render the API token section of the page at all.

Only render the API token and generation link if settings.ENABLE_REST_API
is True.

Reported-by: Tomas Novotny <tomas@novotny.cz>
Closes: #138 ("NoReverseMatch exception on user login with disabled REST API")
Fixes: 85c8f369204a ("views: Provide a way to view, (re)generate tokens")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/templates/patchwork/profile.html
patchwork/views/user.py