Browse Source

added login form

master
Holger Frey 7 years ago
parent
commit
9ee42880e9
  1. 10
      ordr2/templates/layout.jinja2
  2. 1
      tests/_functional/account.py
  3. 15
      tests/_functional/layout_and_pages.py

10
ordr2/templates/layout.jinja2

@ -36,7 +36,7 @@
<li class="nav-item {{ 'active' if request.context.nav_section == 'admin' }}"><a class="nav-link" href="{{ request.resource_url(request.root, 'admin') }}">Admin</a></li> <li class="nav-item {{ 'active' if request.context.nav_section == 'admin' }}"><a class="nav-link" href="{{ request.resource_url(request.root, 'admin') }}">Admin</a></li>
</ul> </ul>
<!-- user login and setting stuff on the right --> <!-- account stuff on the right -->
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item dropdown" id="user-options"> <li class="nav-item dropdown" id="user-options">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownUserSettings" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownUserSettings" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -58,6 +58,14 @@
<li class="nav-item {{ 'active' if request.context.nav_section == 'root' and request.view_name == 'faq' }}"><a class="nav-link" href="{{ request.resource_url(request.root, 'faq') }}">FAQs</a></li> <li class="nav-item {{ 'active' if request.context.nav_section == 'root' and request.view_name == 'faq' }}"><a class="nav-link" href="{{ request.resource_url(request.root, 'faq') }}">FAQs</a></li>
<li class="nav-item {{ 'active' if request.context.nav_section == 'account' and request.view_name == 'register'}}"><a class="nav-link" href="{{ request.resource_url(request.root, 'account', 'register') }}">Register</a></li> <li class="nav-item {{ 'active' if request.context.nav_section == 'account' and request.view_name == 'register'}}"><a class="nav-link" href="{{ request.resource_url(request.root, 'account', 'register') }}">Register</a></li>
</ul> </ul>
<!-- login form on the right -->
<form action="{{ request.resource_url(request.root, 'account', 'login') }}" method="POST" class="login-form form-inline">
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}">
<input name="username" type="text" placeholder="Username" class="form-control form-control-sm">
<input name="password" type="password" placeholder="Password" class="form-control form-control-sm">
<button type="submit" class="btn btn-sm btn-outline-secondary">Log in</button>
</form>
{% endif %} {% endif %}
</nav> </nav>

1
tests/_functional/account.py

@ -11,7 +11,6 @@ def test_account_register_unauthenticated(testapp):
# basic content test # basic content test
assert 'Ordr | Account Registration' in response assert 'Ordr | Account Registration' in response
assert '<!-- No logged in user -->' in response
# test the main nav section links and highlighting # test the main nav section links and highlighting
li_one, li_two = response.html.find_all('li', class_='nav-item') li_one, li_two = response.html.find_all('li', class_='nav-item')
assert 'active' not in li_one['class'] assert 'active' not in li_one['class']

15
tests/_functional/layout_and_pages.py

@ -3,6 +3,19 @@
from . import testapp from . import testapp
def test_layout_unauthenticated_user(testapp):
''' test the layout template elements for unauthenticated users
The '/faq' path is used; '/' will redirect on authenticated users
'''
testapp.reset()
response = testapp.get('/faq')
assert '<!-- No logged in user -->' in response
assert 'class="login-form' in response
def test_page_welcome_unauthenticated(testapp): def test_page_welcome_unauthenticated(testapp):
''' test the welcome page for a unauthenticated user ''' ''' test the welcome page for a unauthenticated user '''
testapp.reset() testapp.reset()
@ -11,7 +24,6 @@ def test_page_welcome_unauthenticated(testapp):
# basic content test # basic content test
assert 'Ordr | Welcome' in response assert 'Ordr | Welcome' in response
assert '<!-- No logged in user -->' in response
# test that no sections are highlightet # test that no sections are highlightet
assert '<li class="nav-item active">' not in response assert '<li class="nav-item active">' not in response
@ -24,7 +36,6 @@ def test_faq_unauthenticated(testapp):
# basic content test # basic content test
assert 'Ordr | FAQ' in response assert 'Ordr | FAQ' in response
assert '<!-- No logged in user -->' in response
# test the main nav section links and highlighting # test the main nav section links and highlighting
li_one, li_two = response.html.find_all('li', class_='nav-item') li_one, li_two = response.html.find_all('li', class_='nav-item')
assert 'active' in li_one['class'] assert 'active' in li_one['class']