Enable Accounts
This commit is contained in:
parent
5eb1972c41
commit
f9f7f624b1
@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import environ
|
|
||||||
import os
|
import os
|
||||||
import environ
|
import environ
|
||||||
|
|
||||||
@ -51,6 +50,7 @@ INSTALLED_APPS = [
|
|||||||
'rest_framework',
|
'rest_framework',
|
||||||
'rest_framework.authtoken',
|
'rest_framework.authtoken',
|
||||||
'django_filters',
|
'django_filters',
|
||||||
|
'accounts',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -185,3 +185,7 @@ STATICFILES_DIRS = [
|
|||||||
BASE_DIR / "api/static",
|
BASE_DIR / "api/static",
|
||||||
("assets", BASE_DIR / "api/static/assets"),
|
("assets", BASE_DIR / "api/static/assets"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
LOGIN_REDIRECT_URL = "index"
|
||||||
|
LOGOUT_REDIRECT_URL = "index"
|
||||||
|
65
api/api/templates/base.html
Normal file
65
api/api/templates/base.html
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{% load static %}
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Bootstrap demo</title>
|
||||||
|
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="p-3 text-bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
|
||||||
|
<a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none">
|
||||||
|
<svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap"><use xlink:href="#bootstrap"></use></svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
|
||||||
|
<li><a href="#" class="nav-link px-2 text-secondary">Home</a></li>
|
||||||
|
<li><a href="#" class="nav-link px-2 text-white">Features</a></li>
|
||||||
|
<li><a href="#" class="nav-link px-2 text-white">Pricing</a></li>
|
||||||
|
<li><a href="#" class="nav-link px-2 text-white">FAQs</a></li>
|
||||||
|
<li><a href="#" class="nav-link px-2 text-white">About</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<form class="col-12 col-lg-auto mb-3 mb-lg-0 me-lg-3" role="search">
|
||||||
|
<input type="search" class="form-control form-control-dark text-bg-dark" placeholder="Search..." aria-label="Search">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="text-end">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<a href="{% url 'logout' %}" class="btn btn-outline-light me-2">Logout</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'login' %}" class="btn btn-outline-light me-2">Login</a>
|
||||||
|
<a href="{% url 'signup' %}" class="btn btn-warning">Sign-up</a>
|
||||||
|
{% endif %}
|
||||||
|
<!-- <button type="button" class="btn btn-outline-light me-2">Login</button> -->
|
||||||
|
<!-- <button type="button" class="btn btn-warning">Sign-up</button> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<script src="{% static 'js/bootstrap.bundle.min.js' %}" crossorigin="anonymous"></script>
|
||||||
|
<!-- end header -->
|
||||||
|
<div class="col-lg-8 mx-auto p-4 py-md-5">
|
||||||
|
<!-- main -->
|
||||||
|
<main>
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ section.title }}</h1>
|
||||||
|
|
||||||
|
{% for story in story_list %}
|
||||||
|
<h2>
|
||||||
|
<a href="{{ story.get_absolute_url }}">
|
||||||
|
{{ story.headline|upper }}
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<p>{{ story.tease|truncatewords:"100" }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</main>
|
||||||
|
<!-- end main -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
13
api/api/templates/home.html
Normal file
13
api/api/templates/home.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- templates/home.html -->
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Home{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
Hi {{ user.username }}!
|
||||||
|
{% else %}
|
||||||
|
<p>You are not logged in</p>
|
||||||
|
<a href="{% url 'login' %}">Log In</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -28,8 +28,14 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="text-end">
|
<div class="text-end">
|
||||||
<button type="button" class="btn btn-outline-light me-2">Login</button>
|
{% if user.is_authenticated %}
|
||||||
<button type="button" class="btn btn-warning">Sign-up</button>
|
<a href="{% url 'logout' %}" class="btn btn-outline-light me-2">Logout</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'login' %}" class="btn btn-outline-light me-2">Login</a>
|
||||||
|
<a href="{% url 'signup' %}" class="btn btn-warning">Sign-up</a>
|
||||||
|
{% endif %}
|
||||||
|
<!-- <button type="button" class="btn btn-outline-light me-2">Login</button> -->
|
||||||
|
<!-- <button type="button" class="btn btn-warning">Sign-up</button> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,6 +45,7 @@
|
|||||||
<div class="col-lg-8 mx-auto p-4 py-md-5">
|
<div class="col-lg-8 mx-auto p-4 py-md-5">
|
||||||
<!-- main -->
|
<!-- main -->
|
||||||
<main>
|
<main>
|
||||||
|
|
||||||
<h1>Bills</h1>
|
<h1>Bills</h1>
|
||||||
<p class="fs-5 col-md-8">Quickly and easily start adding your bills and service costs to get a better understanding of your operational expenses.</p>
|
<p class="fs-5 col-md-8">Quickly and easily start adding your bills and service costs to get a better understanding of your operational expenses.</p>
|
||||||
|
|
||||||
@ -74,8 +81,11 @@
|
|||||||
<!-- end main -->
|
<!-- end main -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% block base %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
||||||
|
13
api/api/templates/registration/login.html
Normal file
13
api/api/templates/registration/login.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- templates/registration/login.html -->
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Login{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Log In</h2>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">Log In</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
13
api/api/templates/registration/signup.html
Normal file
13
api/api/templates/registration/signup.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- templates/registration/signup.html -->
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Sign Up{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Sign up</h2>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">Sign Up</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
@ -13,17 +13,16 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.urls import path
|
from django.urls import include, path
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from django.urls import include, path
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# url(r'^$', view=TemplateView.as_view(template_name='bills/home.html')),
|
|
||||||
# url(r'^$', view=TemplateView.as_view(template_name='main_api/home.html')),
|
|
||||||
path('', views.index, name='index'),
|
|
||||||
path('bills/', include('bills.urls')),
|
path('bills/', include('bills.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('accounts/', include('accounts.urls')),
|
||||||
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
|
path('', TemplateView.as_view(template_name='index.html'), name='index'),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user