-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: add bootstrap styling to tagging app (#4551)
- Loading branch information
1 parent
d502b8c
commit 2884cc5
Showing
19 changed files
with
283 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.conf import settings | ||
|
||
|
||
def tagging(request): | ||
""" | ||
Add some constants to the context. | ||
""" | ||
return { | ||
'HEADER_LOGO_URL': settings.HEADER_LOGO_URL, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
from django.conf import settings | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.core.exceptions import PermissionDenied | ||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin | ||
|
||
|
||
class VerticalTaggingAdministratorPermissionRequiredMixin(LoginRequiredMixin): | ||
class VerticalTaggingAdministratorPermissionRequiredMixin( | ||
LoginRequiredMixin, UserPassesTestMixin | ||
): | ||
""" | ||
A mixin to enforce permission on VERTICALS_MANAGEMENT_GROUPS for class-based views. | ||
""" | ||
|
||
def dispatch(self, request, *args, **kwargs): | ||
response = super().dispatch(request, *args, **kwargs) | ||
if response.status_code == 403: | ||
return response | ||
|
||
in_vertical_management_group = request.user.groups.filter( | ||
def test_func(self): | ||
""" | ||
Check if the user is in the VERTICALS_MANAGEMENT_GROUPS group or is a superuser. | ||
""" | ||
return self.request.user.is_superuser or self.request.user.groups.filter( | ||
name__in=settings.VERTICALS_MANAGEMENT_GROUPS | ||
).exists() | ||
|
||
if not request.user.is_superuser and not in_vertical_management_group: | ||
raise PermissionDenied("You do not have permission to access this page.") | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{% load static %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
|
@@ -7,31 +8,48 @@ | |
<!-- Bootstrap CSS --> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet"> | ||
<script src="https://unpkg.com/htmx.org"></script> | ||
<link href="{% static 'css/tagging.css' %}" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
<header class="site-header mb-3 py-3 border-bottom border-gray-300"> | ||
<div class="container"> | ||
<a class="navbar-brand" href="{% url 'tagging:course_list' %}">Course Tagging</a> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav me-auto"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'tagging:vertical_list' %}">Verticals</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'tagging:sub_vertical_list' %}">Sub-Verticals</a> | ||
</li> | ||
</ul> | ||
<ul class="navbar-nav mr-10"> | ||
{% if user.is_authenticated %} | ||
<li class="nav-item"> | ||
<a class="nav-link text-light" href="#">{{ user.username }}</a> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
<div class="d-flex justify-content-between align-items-center"> | ||
<div class="d-flex align-items-center"> | ||
<a class="navbar-brand" href="{% url 'tagging:course_list' %}"> | ||
<img src="{{ HEADER_LOGO_URL }}" alt="header logo" height="30" class="d-inline-block align-middle" /> | ||
<span class="fw-bold ml-2 me-3">Course Tagging</span> | ||
</a> | ||
<nav class="navbar navbar-expand-lg"> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item {% if request.resolver_match.url_name == 'vertical_list' %}active{% endif %}"> | ||
<a class="nav-link" href="{% url 'tagging:vertical_list' %}">Verticals</a> | ||
</li> | ||
<li class="nav-item {% if request.path == '/tagging/sub_verticals/' %}active{% endif %}"> | ||
<a class="nav-link" href="{% url 'tagging:sub_vertical_list' %}">Sub-Verticals</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
</div> | ||
|
||
<div class="d-flex align-items-center"> | ||
<div class="dropdown"> | ||
|
||
<button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false" style="text-decoration: none; color: #454545;"> | ||
<i class="bi bi-person-circle fs-4 me-2"></i> <span class="fs-5">{{ user.username }}</span> | ||
</button> | ||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton"> | ||
<li><a class="dropdown-item" href="{% url 'logout' %}">Sign Out</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
|
||
<main class="py-4"> | ||
{% block content %} | ||
|
2 changes: 1 addition & 1 deletion
2
course_discovery/apps/tagging/templates/tagging/course_list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 22 additions & 11 deletions
33
course_discovery/apps/tagging/templates/tagging/sub_vertical_detail.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.