Skip to content

Commit

Permalink
Town6: Move login from header to footer.
Browse files Browse the repository at this point in the history
LINK: SEA-345
  • Loading branch information
Marc Sommerhalder committed May 21, 2021
1 parent c801b0e commit 3c5dd81
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/onegov/org/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def login_to_url(self, to, skip=False):
auth = Auth.from_request(self.request, to=to, skip=skip)
return self.request.link(auth, 'login')

def login_from_path(self):
auth = Auth.from_request_path(self.request)
return self.request.link(auth, name='login')

def export_formatter(self, format):
""" Returns a formatter function which takes a value and returns
the value ready for export.
Expand Down
8 changes: 8 additions & 0 deletions src/onegov/town6/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from onegov.core.i18n import default_locale_negotiator
from onegov.core.utils import module_path
from onegov.foundation6.integration import FoundationApp
from onegov.town6.custom import get_global_tools
from onegov.town6.initial_content import create_new_organisation
from onegov.org.app import get_i18n_localedirs as get_org_i18n_localedirs, \
OrgApp, org_content_security_policy
Expand Down Expand Up @@ -43,6 +44,13 @@ def get_template_directory():
return 'templates'


@TownApp.template_variables()
def get_template_variables(request):
return {
'global_tools': tuple(get_global_tools(request))
}


@TownApp.setting(section='core', name='theme')
def get_theme():
return TownTheme()
Expand Down
10 changes: 10 additions & 0 deletions src/onegov/town6/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from onegov.org.custom import get_global_tools as get_global_tools_base


def get_global_tools(request):
for item in get_global_tools_base(request):

if getattr(item, 'attrs', {}).get('class') == {'login'}:
continue

yield item
5 changes: 5 additions & 0 deletions src/onegov/town6/templates/macros.pt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
</a>
</span>
</tal:b>
<span tal:condition="not request.is_logged_in">
<a href="${layout.login_from_path()}" i18n:translate>
Login
</a>
</span>
<span tal:define="about_url layout.org.meta.about_url|nothing" tal:condition="about_url">
<a href="${about_url}" i18n:translate>
About
Expand Down
9 changes: 9 additions & 0 deletions tests/onegov/town6/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ def test_clipboard_separation(client):
client.login_admin()

assert 'paste-link' not in client.get('/topics/organisation')


def test_gobal_tools(client):
links = client.get('/').pyquery('.globals a')
assert links == []

client.login_admin()
links = client.get('/').pyquery('.globals a')
assert links != []

0 comments on commit 3c5dd81

Please sign in to comment.