Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tup-cms): tup-348 portal nav #58

Merged
merged 11 commits into from
Nov 3, 2022
2 changes: 1 addition & 1 deletion apps/tup-cms/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM taccwma/core-cms:07426b3
FROM taccwma/core-cms:977ecc0
wesleyboar marked this conversation as resolved.
Show resolved Hide resolved

WORKDIR /code

Expand Down
Empty file.
5 changes: 5 additions & 0 deletions apps/tup-cms/src/apps/portal_nav/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class PortalNavConfig(AppConfig):
name = 'portal_nav'
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{# @var user #}
<!-- FAQ: This template loads independently at a unique url (see `urls.py`)
so CMS and User Guide can render this markup into their markup. -->
wesleyboar marked this conversation as resolved.
Show resolved Hide resolved

{# GH-101: Remove style tag i.e. rely only on `site.header.css` #}
<style type="text/css">
.s-portal-nav .icon {
margin-right: 0.25em;

/* Copied from FontAwesome `.fa-lg` */
font-size: 1.3em;
vertical-align: text-bottom; /* tweaked to align better */
}
.s-portal-nav .nav-link .icon {
font-size: 1.5em;
vertical-align: middle; /* tweaked to align better */
}
</style>
wesleyboar marked this conversation as resolved.
Show resolved Hide resolved
{% if user.is_authenticated %}
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
<i class="icon icon-user"></i>
<span>{{ user.get_username }}</span>
<span class="sr-only">Toggle Dropdown</span>
</a>
<nav class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="/dashboard">
<i class="icon icon-dashboard"></i> My Dashboard
</a>

{# WARNING: Some markup is duplicated in other repositories #} {# SEE:
https://confluence.tacc.utexas.edu/x/LoCnCQ #} {# FAQ: Extra space makes
eases comparison of similar templates #}

<a class="dropdown-item" href="/dashboard/logout">
<i class="icon icon-exit"></i> Log Out
</a>
</nav>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="/dashboard/login">
<i class="icon icon-user"></i> Log in
</a>
</li>
{% endif %}
7 changes: 7 additions & 0 deletions apps/tup-cms/src/apps/portal_nav/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import re_path
from .views import PortalNavView

app_name = 'portal_nav'
urlpatterns = [
re_path('', PortalNavView, name='index'),
]
10 changes: 10 additions & 0 deletions apps/tup-cms/src/apps/portal_nav/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.http import HttpResponse
from django.template import loader, Context
from django.contrib.auth import authenticate


def PortalNavView(request):
user = authenticate(request)
context = {'user': user}
template = loader.get_template('portal_nav/nav_portal.raw.html')
return HttpResponse(template.render(context, request))
2 changes: 1 addition & 1 deletion apps/tup-cms/src/taccsite_cms/custom_app_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CUSTOM_APPS = ['apps.dashboard']
CUSTOM_APPS = ['apps.portal_nav', 'apps.dashboard']
CUSTOM_MIDDLEWARE = []
STATICFILES_DIRS = ()
1 change: 1 addition & 0 deletions apps/tup-cms/src/taccsite_cms/urls_custom.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.urls import path, include

custom_urls = [
path('core/markup/nav/', include('apps.portal_nav.urls', namespace='portal_nav')),
Copy link
Member Author

@wesleyboar wesleyboar Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path('dashboard/', include('apps.dashboard.urls', namespace='dashboard')),
]