Added navbar, login, signup, and forgot password

This commit is contained in:
Yamozha 2021-02-09 01:06:19 +02:00
parent 3a3da23827
commit 6044270579
23 changed files with 256 additions and 36 deletions

Binary file not shown.

View File

@ -1,3 +1,6 @@
from django.db import models
# Create your models here.
# class Navbar(models.Model):
# title=models.CharField(max_length=50)
# url=models.CharField(max_length=50)
#

View File

@ -22,12 +22,14 @@ html {
background-position: 100%;
}
body {
.centered {
position: absolute;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
top: 50%;
}
body{
font-size: 1.2em;
font-family: 'Roboto', sans-serif;
line-height: 1.4;
@ -65,4 +67,38 @@ p > strong {
}
}
ul.navbar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width:100%;
text-align:center;
}
li a.navbar {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li {
float:left;
}
li a:hover.navbar {
background-color: #111;
}
#active {
background-color: #4CAF50;
}

View File

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
<meta charset="utf-8">
<title>Home</title>
<meta name="description" content="Start throwing out trash in an eco-friendly way!">
<meta name="author" content="Yamozha">
<link rel="stylesheet" href="{% static "css/style.css" %}">
</head>
<body>
{% block content %}
{% endblock %}
{% csrf_token %}
<h1>Test!</h1>
<h2><strong>{{ currencyTotal }}</strong></h2>
</body>
</html>

View File

@ -1,8 +0,0 @@
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 15.6">
<style>
.st0{fill:#f3bc34}
</style>
<path class="st0" d="M206.8 7.3l-.1.3c.1-.2.2-.3.1-.3zM234.7 10h-.1c-.2.4-.1.3.1 0zM54.8 4.2l-.6-.4c.2.4.4.5.6.4zM17.1 5.1zM34.5 9.6l.1.3c0-.2 0-.3-.1-.3zM22.4 10.8c-.3-.1-.7-.1-1-.1.2.1.7.1 1 .1zM17.5 5c-.1.1-.2.1-.4.2.2-.1.3-.2.4-.2z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3-.9 1.3-.4 2.6-.8 4.5-.4.7.3-.7 1.1.7 1 .7-.5.4-1.5 2.2-1.3l-.1.9 1.2-.9c-.7-.7-2.6-.4-1.3-1.2 1.6.8 1.3-.9 3.3 0-.4.1-1 .8-1.3 1.2 2 .4 3.4.1 4.8-.1 1.4-.3 2.8-.6 4.9-.2 2-.8 4.6-1.2 5.9-1.9 0 .9 0 1.7-.8 2.4 1.8 0 2.4-2.1 3.7-.9.7-1.3 4.7-1.2 5-3l2-.8z"/>
<path class="st0" d="M58.1 11.1c-1 0-1.9 0-2.3.2.2.2 2.3.6 2.3-.2zM208.2 13.3c-.1 0-.3.1-.4.1.1 0 .3 0 .4-.1zM216.3 12.9c-.1-.1-.2-.2-.4-.3 0 .3.1.5.4.3zM132.6 11.5zM178.5 13.7c.7-.4 1-.7 1-1-.4.1-.7.3-1 1zM163 12.6c-.1.1-.2.1-.3.2.3-.1.3-.2.3-.2zM130.2 12c.7-.4 1.6-.3 2.4-.5-.7.2-1.9-.3-2.4.5zM226.1 11.4l-.7.6.8-.4zM218.6 12c-.3-.1-1.7.3-1.3.6.4-.3.9-.5 1.3-.6zM189.6 11.4l-.3.6.7-.5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -0,0 +1,25 @@
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: Password reset on 127.0.0.1:8000
From: webmaster@localhost
To: pederas@pederasov.pl
Date: Mon, 08 Feb 2021 22:19:44 -0000
Message-ID: <161282278468.9046.5088568393660450551@Spudnik>
You're receiving this email because you requested a password reset for your user account at 127.0.0.1:8000.
Please go to the following page and choose a new password:
http://127.0.0.1:8000/users/reset/Mg/ahs0ww-f913be8dd50f0a6adf4815cf32e8183a/
Your username, in case youve forgotten: bobi
Thanks for using our site!
The 127.0.0.1:8000 team
-------------------------------------------------------------------------------

View File

@ -0,0 +1,25 @@
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: Password reset on 127.0.0.1:8000
From: webmaster@localhost
To: pederas@pederasov.pl
Date: Mon, 08 Feb 2021 22:20:07 -0000
Message-ID: <161282280735.9109.220494091957288379@Spudnik>
You're receiving this email because you requested a password reset for your user account at 127.0.0.1:8000.
Please go to the following page and choose a new password:
http://127.0.0.1:8000/users/reset/Mg/ahs0xj-30b0b07164a6b8b220b0e9cbbb048aa0/
Your username, in case youve forgotten: bobi
Thanks for using our site!
The 127.0.0.1:8000 team
-------------------------------------------------------------------------------

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}CurrencyProj{% endblock %}</title>
{% load static %}
<ul class="navbar">
<li class="navbar" ><a class="navbar" href="/">Home</a></li>
<li class="navbar"><a class="navbar" href="/users/signup">Sign up</a></li>
<li class="navbar"><a class="navbar" id="login" href="/users/login"style="float:right">Login</a></li>
</ul>
<meta name="description" content="Start throwing out trash in an eco-friendly way!">
<meta name="author" content="Yamozha">
<link rel="stylesheet" href="{% static "home/css/style.css" %}">
</head>
<body>
<div class="centered">
{% block content %}
{% endblock %}
</div>
</body>
</html>

View File

@ -0,0 +1,16 @@
<!-- templates/home.html -->
{% extends 'base.html' %}
{% block title %}Home{% endblock %}
{% block content %}
{% if user.is_authenticated %}
Hi {{ user.username }}!
{{ currencyTotal }}
<p><a href="{% url 'logout' %}">Log Out</a></p>
<p><a href="{% url 'password_reset' %}">Reset Password</a></p>
{% else %}
<p>You are not logged in</p>
<a href="{% url 'login' %}">Log In</a>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,12 @@
{% 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 %}

View File

@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block title %}Password reset complete{% endblock %}
{% block content %}
<h1>Password reset complete</h1>
<p>Your new password has been set. You can log in now on the <a href="{% url 'login' %}">log in page</a>.</p>
{% endblock %}

View File

@ -0,0 +1,20 @@
{% extends 'base.html' %}
{% block title %}Enter new password{% endblock %}
{% block content %}
{% if validlink %}
<h1>Set a new password!</h1>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Change my password">
</form>
{% else %}
<p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
{% endif %}

View File

@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% block title %}Email Sent{% endblock %}
{% block content %}
<h1>Check your inbox.</h1>
<p>We've emailed you instructions for setting your password. You should receive the email shortly!</p>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends 'base.html' %}
{% block title %}Forgot Your Password?{% endblock %}
{% block content %}
<h1>Forgot your password?</h1>
<p>Enter your email address below, and we'll email instructions for setting a new one.</p>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Send me instructions!">
</form>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% 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 %}

3
website/users/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
website/users/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = 'users'

3
website/users/models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
website/users/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
website/users/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.urls import path
from .views import SignUpView
urlpatterns = [
path('signup/', SignUpView.as_view(), name='signup'),
]

11
website/users/views.py Normal file
View File

@ -0,0 +1,11 @@
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views import generic
# need to make oauth facebook login
class SignUpView(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'registration/signup.html'

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -38,6 +39,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
'users',
]
MIDDLEWARE = [
@ -55,7 +57,7 @@ ROOT_URLCONF = 'website.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -120,3 +122,9 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT= "/media/kanina/AtmoSphere/Projects/CurrencySite/website/static/"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = str(BASE_DIR.joinpath('sent_emails'))

View File

@ -14,13 +14,17 @@ Including another URLconf
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 home.views import homePage
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth import views
from django.views.generic.base import TemplateView
urlpatterns = [
path("", homePage, name="home"),
path("", homePage, name='home'),
path('admin/', admin.site.urls),
path("users/", include('django.contrib.auth.urls')),
path('users/', include('users.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)