From 6044270579f20ce187f536d667847ce382e47bc6 Mon Sep 17 00:00:00 2001 From: Yamozha Date: Tue, 9 Feb 2021 01:06:19 +0200 Subject: [PATCH] Added navbar, login, signup, and forgot password --- website/db.sqlite3 | Bin 131072 -> 131072 bytes website/home/models.py | 5 ++- website/home/static/{ => home}/css/style.css | 38 +++++++++++++++++- website/home/templates/home.html | 23 ----------- website/home/templates/underline.svg | 8 ---- .../20210209-001944-140059386095208.log | 25 ++++++++++++ .../20210209-002007-139656085868384.log | 25 ++++++++++++ website/templates/base.html | 26 ++++++++++++ website/templates/home.html | 16 ++++++++ website/templates/registration/login.html | 12 ++++++ .../registration/password_reset_complete.html | 8 ++++ .../registration/password_reset_confirm.html | 20 +++++++++ .../registration/password_reset_done.html | 8 ++++ .../registration/password_reset_form.html | 14 +++++++ website/templates/registration/signup.html | 13 ++++++ website/users/admin.py | 3 ++ website/users/apps.py | 5 +++ website/users/models.py | 3 ++ website/users/tests.py | 3 ++ website/users/urls.py | 8 ++++ website/users/views.py | 11 +++++ website/website/settings.py | 10 ++++- website/website/urls.py | 8 +++- 23 files changed, 256 insertions(+), 36 deletions(-) rename website/home/static/{ => home}/css/style.css (70%) delete mode 100644 website/home/templates/home.html delete mode 100644 website/home/templates/underline.svg create mode 100644 website/sent_emails/20210209-001944-140059386095208.log create mode 100644 website/sent_emails/20210209-002007-139656085868384.log create mode 100644 website/templates/base.html create mode 100644 website/templates/home.html create mode 100644 website/templates/registration/login.html create mode 100644 website/templates/registration/password_reset_complete.html create mode 100644 website/templates/registration/password_reset_confirm.html create mode 100644 website/templates/registration/password_reset_done.html create mode 100644 website/templates/registration/password_reset_form.html create mode 100644 website/templates/registration/signup.html create mode 100644 website/users/admin.py create mode 100644 website/users/apps.py create mode 100644 website/users/models.py create mode 100644 website/users/tests.py create mode 100644 website/users/urls.py create mode 100644 website/users/views.py diff --git a/website/db.sqlite3 b/website/db.sqlite3 index 84cb1acc15428f18b7b760e9d76aa3fc9a15cab2..cd50d13643617b8a772cb0ac2b89ddb9224bbb5b 100644 GIT binary patch delta 551 zcmZo@;Am*zm>|ulH&Mo!QEy|yB6*Qn3~c;m4E!(ouki2YFXQj#U&CLqu`z*va+$u0 z8Uq7^5D+5)UOr}d#>CQ+jQG;x)FLKvR%T53VQ!fb59%*?u+n{VoC8*ni3on_$9 z$=&&3 zQfTs)RtBbe7KUcV#>SH$<|}hB@xNo>|IYtzvtYp^eohW%QAUtWOq;*g3koptE!x;P zi;syhZewE<;Z#dm<}uJSXgOl(wGG(lj~1QvnCEEg`YF!KLq*jUiVKXF1TKMOM> zCkq!acp3TsF!2A`EZFd#Ul7P;X6EGN1q-iW;9mhWXC8k<7$YZxBfn@WBPSzrx&Qj3d~Vry$- YS(vt6VB}C>;(r9R|t4Gf~EwQD$SpB6*P&3~c;m4E!(ouki2YFXQj#pT%FXu`z*va+$u0 z8V?_{JZEBQNk)8WacU6*1A{OSBLi_(W@EsEuVUn7Xw+nwT$mp=`C+~?Q0hAa|M$&;4R855Ihe&c6H{_C^EPc@QP|9~;g9^H d4Fa1kuw2;8^5Bm=P*7ky%LPWD6i34kegNL3HID!Q diff --git a/website/home/models.py b/website/home/models.py index 71a83623..b55e5304 100644 --- a/website/home/models.py +++ b/website/home/models.py @@ -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) + # diff --git a/website/home/static/css/style.css b/website/home/static/home/css/style.css similarity index 70% rename from website/home/static/css/style.css rename to website/home/static/home/css/style.css index 21bbb5dc..a451b1af 100644 --- a/website/home/static/css/style.css +++ b/website/home/static/home/css/style.css @@ -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; +} + diff --git a/website/home/templates/home.html b/website/home/templates/home.html deleted file mode 100644 index 24feec72..00000000 --- a/website/home/templates/home.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {% load static %} - - - Home - - - - - - - - {% block content %} - {% endblock %} -{% csrf_token %} - -

Test!

-

{{ currencyTotal }}

- - diff --git a/website/home/templates/underline.svg b/website/home/templates/underline.svg deleted file mode 100644 index 7bbe7581..00000000 --- a/website/home/templates/underline.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/website/sent_emails/20210209-001944-140059386095208.log b/website/sent_emails/20210209-001944-140059386095208.log new file mode 100644 index 00000000..e20b3c8a --- /dev/null +++ b/website/sent_emails/20210209-001944-140059386095208.log @@ -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 you’ve forgotten: bobi + +Thanks for using our site! + +The 127.0.0.1:8000 team + + + +------------------------------------------------------------------------------- diff --git a/website/sent_emails/20210209-002007-139656085868384.log b/website/sent_emails/20210209-002007-139656085868384.log new file mode 100644 index 00000000..ef08d1c2 --- /dev/null +++ b/website/sent_emails/20210209-002007-139656085868384.log @@ -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 you’ve forgotten: bobi + +Thanks for using our site! + +The 127.0.0.1:8000 team + + + +------------------------------------------------------------------------------- diff --git a/website/templates/base.html b/website/templates/base.html new file mode 100644 index 00000000..ad6a1974 --- /dev/null +++ b/website/templates/base.html @@ -0,0 +1,26 @@ + + + + + + {% block title %}CurrencyProj{% endblock %} + {% load static %} + + + + + + + + + +
+ {% block content %} + {% endblock %} +
+ + diff --git a/website/templates/home.html b/website/templates/home.html new file mode 100644 index 00000000..6769b8d6 --- /dev/null +++ b/website/templates/home.html @@ -0,0 +1,16 @@ + +{% extends 'base.html' %} + +{% block title %}Home{% endblock %} + +{% block content %} +{% if user.is_authenticated %} + Hi {{ user.username }}! + {{ currencyTotal }} +

Log Out

+

Reset Password

+{% else %} +

You are not logged in

+ Log In +{% endif %} +{% endblock %} diff --git a/website/templates/registration/login.html b/website/templates/registration/login.html new file mode 100644 index 00000000..c6eb2df7 --- /dev/null +++ b/website/templates/registration/login.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} + +{% block title %}Login{% endblock %} + +{% block content %} +

Log In

+
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/website/templates/registration/password_reset_complete.html b/website/templates/registration/password_reset_complete.html new file mode 100644 index 00000000..ab769f65 --- /dev/null +++ b/website/templates/registration/password_reset_complete.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}Password reset complete{% endblock %} + +{% block content %} +

Password reset complete

+

Your new password has been set. You can log in now on the log in page.

+{% endblock %} diff --git a/website/templates/registration/password_reset_confirm.html b/website/templates/registration/password_reset_confirm.html new file mode 100644 index 00000000..2f343fd3 --- /dev/null +++ b/website/templates/registration/password_reset_confirm.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} + +{% block title %}Enter new password{% endblock %} + +{% block content %} + +{% if validlink %} + +

Set a new password!

+
+ {% csrf_token %} + {{ form.as_p }} + +
+ +{% else %} + +

The password reset link was invalid, possibly because it has already been used. Please request a new password reset.

+ +{% endif %} diff --git a/website/templates/registration/password_reset_done.html b/website/templates/registration/password_reset_done.html new file mode 100644 index 00000000..8a47de55 --- /dev/null +++ b/website/templates/registration/password_reset_done.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}Email Sent{% endblock %} + +{% block content %} +

Check your inbox.

+

We've emailed you instructions for setting your password. You should receive the email shortly!

+{% endblock %} diff --git a/website/templates/registration/password_reset_form.html b/website/templates/registration/password_reset_form.html new file mode 100644 index 00000000..1d39fc3a --- /dev/null +++ b/website/templates/registration/password_reset_form.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block title %}Forgot Your Password?{% endblock %} + +{% block content %} +

Forgot your password?

+

Enter your email address below, and we'll email instructions for setting a new one.

+ +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} diff --git a/website/templates/registration/signup.html b/website/templates/registration/signup.html new file mode 100644 index 00000000..cdfd15a6 --- /dev/null +++ b/website/templates/registration/signup.html @@ -0,0 +1,13 @@ +{% extends 'base.html' %} + +{% block title %}Sign Up{% endblock %} + +{% block content %} +

Sign up

+
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} + diff --git a/website/users/admin.py b/website/users/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/website/users/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/website/users/apps.py b/website/users/apps.py new file mode 100644 index 00000000..4ce1fabc --- /dev/null +++ b/website/users/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' diff --git a/website/users/models.py b/website/users/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/website/users/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/website/users/tests.py b/website/users/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/website/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/website/users/urls.py b/website/users/urls.py new file mode 100644 index 00000000..3dc60e32 --- /dev/null +++ b/website/users/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from .views import SignUpView + + +urlpatterns = [ + path('signup/', SignUpView.as_view(), name='signup'), +] diff --git a/website/users/views.py b/website/users/views.py new file mode 100644 index 00000000..c4214a4d --- /dev/null +++ b/website/users/views.py @@ -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' + diff --git a/website/website/settings.py b/website/website/settings.py index da82ad63..73035865 100644 --- a/website/website/settings.py +++ b/website/website/settings.py @@ -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')) diff --git a/website/website/urls.py b/website/website/urls.py index 39d80ee8..ae37dbef 100644 --- a/website/website/urls.py +++ b/website/website/urls.py @@ -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)