Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 11bc1dd5 authored by Jon Yu's avatar Jon Yu
Browse files

Add UI app, with Bootstrap and UM styling

... and stub login, logout views, urls
parent 2b2442a9
......@@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'um_django_ui'
]
MIDDLEWARE = [
......
"""um_django_template_project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from .views import login, logout
urlpatterns = [
path('admin/', admin.site.urls),
path('login/', login, name='login'),
path('logout/', logout, name='logout'),
path('', include('um_django_ui.urls')),
]
from django.contrib.auth import logout as auth_logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.shortcuts import render
def login(request):
return render(request, 'um_django_ui/index.html')
@login_required
def logout(request):
auth_logout(request)
return HttpResponseRedirect(reverse('home'))
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class UmDjangoUiConfig(AppConfig):
name = 'um_django_ui'
from django.db import models
# Create your models here.
body {
color: #333333;
font-family: 'Roboto', sans-serif;
background-color: #FFFEFE;
padding-top: 5rem;
}
.dropdown-item:hover {
background-color: #CC6600;
}
.navbar {
background-color: #00274c;
}
.navbar-dark .navbar-nav .nav-link, .navbar-dark .navbar-toggler {
color: white;
}
.navbar-brand img {
max-width: 100%;
max-height: 42px;
}
.btn-primary {
background-color: #40658f;
}
.alert-warning {
background-color: #FFA000;
}
.alert-danger {
background-color: #D32F2F;
}
.alert-primary {
background-color: #1976D2;
}
.alert-success {
background-color: #388E3C;
}
h1, h3 {
color: #00274C
}
h2 {
color: #40658F;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Roboto Slab', serif;
}
a {
color: #0075BC;
}
a:hover {
color: #CC3300;
}
a:active {
color: #CC6600;
}
footer {
background-color: #333333;
color: #999999;
}
@media (max-width: 767px) {
body {
padding-top: 8rem;
}
}
\ No newline at end of file
{% load static %}
<!doctype html>
<html lang="en">
<head>
{% block head %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" type="image/png" href="{% static 'images/favicon.png' %}"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Slab&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/main.css' %}" />
{% block styles %}{% endblock %}
<title>University of Michigan {% block title %}{% endblock %}</title>
{% endblock %}
</head>
<body>
<nav class="navbar navbar-dark navbar-expand-md fixed-top">
<a class="navbar-brand" href="{% url 'um_django_ui:home' %}"><img class="img-fluid my-1 py-1" src="{% static 'images/its-logo.png' %}" /></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarLinks" aria-controls="navbarLinks" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarLinks">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{% url 'um_django_ui:home' %}">Home</a>
</li>
</ul>
<div class="navbar-nav ml-auto">
{% if request.user.is_authenticated %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ request.user.username }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userMenu">
<a href="{% url 'logout' %}" class="dropdown-item">Logout</a>
</div>
</li>
{% else %}
<a href="{% url 'login' %}?next={{ request.get_full_path }}" class="nav-link">Login</a>
{% endif %}
</div>
</div>
</nav>
<main role="main" class="container-fluid pt-2">
<div>
{% block content %}
{% endblock %}
</div>
</main><!-- /.container -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
{% block scripts %}{% endblock %}
</body>
</html>
{% extends 'base.html' %}
{% block content %}
<h1>Welcome to the UM Django Template Project</h1>
{% endblock %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import IndexView
app_name = 'um_django_ui'
urlpatterns = [
path('', IndexView.as_view(), name='home')
]
from django.views.generic import TemplateView
class IndexView(TemplateView):
template_name = 'um_django_ui/index.html'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment