Skip to content

Commit

Permalink
Refactor user app
Browse files Browse the repository at this point in the history
  • Loading branch information
nanokm committed Dec 22, 2024
1 parent f9d4c96 commit 0f34802
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 639 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pull official base image
# pull official gd_backend image
FROM python:3.12.0-bookworm

# set work directory
Expand Down
2 changes: 1 addition & 1 deletion apps/map/templates/map/map.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base/base.html" %}
{% extends "gd_backend/base.html" %}
{% load static %}
{% load i18n %}
{% block css %}
Expand Down
2 changes: 1 addition & 1 deletion apps/map/templates/map/saved_searches.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base/base.html' %}
{% extends 'gd_backend/base.html' %}
{% load i18n %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion apps/shared/templates/shared/about.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base/base.html' %}
{% extends 'gd_backend/base.html' %}
{% load i18n %}
{% load static %}
{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion apps/shared/templates/shared/under_construction.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base/base.html' %}
{% extends 'gd_backend/base.html' %}
{% load static %}
{% block css %}
<style>
Expand Down
4 changes: 2 additions & 2 deletions apps/user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class Meta:
verbose_name_plural = _("GD Users")

def get_menubar_string(self) -> str:
name = f"{self.first_name.strip().capitalize()} {self.last_name.strip().capitalize()}"
return name or self.email.strip()
name = f"{self.first_name.capitalize()} {self.last_name.capitalize()}"
return name.strip() or self.email.strip()

def __str__(self):
return f"{self.email} joined: {self.date_joined:%d-%m-%Y}"
File renamed without changes.
166 changes: 166 additions & 0 deletions apps/user/templates/user/_login_register_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{% load i18n %}
{% load static %}
{% load allauth account %}
{% load allauth %}

<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8"/>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=2, user-scalable=no"
/>
<meta
name="description"
content="Semantic-UI-Forest, collection of design, themes and templates for Semantic-UI."
/>
<meta name="keywords" content="Semantic-UI, Theme, Design, Template"/>
<meta name="author" content="PPType"/>
<meta name="theme-color" content="#ffffff"/>
<title>Login Template for Semantic-UI</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"
type="text/css"
/>
<style type="text/css">
body {
background-color: #fafafa;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: grayscale;
}

body > .ui.grid {
height: 100%;
}

.column {
max-width: 450px;
}

.gsi-material-button {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-appearance: none;
background-color: WHITE;
background-image: none;
border: 1px solid #747775;
-webkit-border-radius: 4px;
border-radius: 4px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #1f1f1f;
cursor: pointer;
font-family: 'Roboto', arial, sans-serif;
font-size: 14px;
height: 40px;
letter-spacing: 0.25px;
outline: none;
overflow: hidden;
padding: 0 12px;
position: relative;
text-align: center;
-webkit-transition: background-color .218s, border-color .218s, box-shadow .218s;
transition: background-color .218s, border-color .218s, box-shadow .218s;
vertical-align: middle;
white-space: nowrap;
width: auto;
max-width: 400px;
min-width: min-content;
}

.gsi-material-button .gsi-material-button-icon {
height: 20px;
margin-right: 12px;
min-width: 20px;
width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
-webkit-align-items: center;
align-items: center;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
flex-wrap: nowrap;
height: 100%;
justify-content: center;
position: relative;
width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
-webkit-flex-grow: 0;
flex-grow: 0;
font-family: 'Roboto', arial, sans-serif;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
-webkit-transition: opacity .218s;
transition: opacity .218s;
bottom: 0;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
}

.gsi-material-button:disabled {
cursor: default;
background-color: #ffffff61;
border-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
background-color: #303030;
opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
-webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
background-color: #303030;
opacity: 8%;
}

#remember_me_checkbox {
text-align: left;
}

</style>
</head>

<body id="root">
{% block login_register_content %}
{% endblock %}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.min.js"></script>
<script>
$(document).ready(function () {
$(".ui.form").form({})
});
</script>
</body>
</html>
3 changes: 1 addition & 2 deletions apps/user/templates/user/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends 'base/base.html' %}

{% extends 'gd_backend/base.html' %}
{% block content %}
<div class="ui grid">
<div class="ui row">
Expand Down
58 changes: 58 additions & 0 deletions apps/user/templates/user/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% extends 'user/_login_register_base.html' %}
{% load i18n %}
{% load socialaccount %}

{% block login_register_content %}

<div class="ui middle aligned center aligned grid">
<div class="column">
<h2 class="ui violet center aligned header">
{% trans 'Zaloguj się' %}
</h2>
<div class="ui stacked segment">
<form class="ui large form" method="POST" action="{% url 'user:login' %}">
{% csrf_token %}
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="email" name="login" placeholder="E-mail" type="text"/>
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input name="password" placeholder="{% trans 'Hasło' %}" type="password"/>
</div>
</div>
<div class="field" id="remember_me_checkbox">
<div class="ui checked checkbox">
<input type="checkbox" name="remember" id="id_remember">
<label for="id_remember">{% trans 'Zapamiętaj mnie' %}</label>
</div>
</div>
<div class="ui fluid large violet submit button">{% trans 'Zaloguj' %}</div>
{% if form.errors %}
<div class="ui small negative message">
<p>{% trans 'Niepoprawny email lub hasło.' %}</p>
</div>
{% endif %}

</form>
<div class="ui horizontal divider">
{% trans 'Lub' %}
</div>
<button class="gsi-material-button" style="width:400px"
onclick="window.location.href='{% provider_login_url 'google' %}'">
<div class="gsi-material-button-state"></div>
<div class="gsi-material-button-content-wrapper">
{% include 'user/partial/_google_button.html' %}
<span class="gsi-material-button-contents">{% trans 'Zaloguj się z Google' %}</span>
<span style="display: none;">Sign in with Google</span>
</div>
</button>
</div>
<div class="ui message">{% trans 'Nie masz konta?' %}<a
href="{% url 'user:register' %}"> {% trans 'Zarejestruj się' %}</a></div>
</div>
</div>
{% endblock %}
14 changes: 14 additions & 0 deletions apps/user/templates/user/partial/_google_button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="gsi-material-button-icon">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"
xmlns:xlink="http://www.w3.org/1999/xlink" style="display: block;">
<path fill="#EA4335"
d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"></path>
<path fill="#4285F4"
d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"></path>
<path fill="#FBBC05"
d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"></path>
<path fill="#34A853"
d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"></path>
<path fill="none" d="M0 0h48v48H0z"></path>
</svg>
</div>
81 changes: 81 additions & 0 deletions apps/user/templates/user/register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{% extends 'user/_login_register_base.html' %}
{% load i18n %}
{% load socialaccount %}

{% block login_register_content %}
<div class="ui middle aligned center aligned grid">
<div class="column">
<h2 class="ui violet center aligned header">
{% trans 'Zarejestruj się' %}
</h2>
<div class="ui stacked segment">
<form class="ui large form" method="POST" action="{% url 'user:register' %}">
{% csrf_token %}
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="email" autocomplete="email" name="email" placeholder="E-mail" id="email"/>
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input name="password1" autocomplete="new-password" placeholder="{% trans 'Hasło' %}"
type="password" id="id_password1"/>
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" name="password2" placeholder="{% trans 'Hasło (powtórz)' %}"
autocomplete="new-password" required id="id_password2"/>
</div>
</div>
<div class="ui fluid large violet submit button">{% trans 'Zarejestruj' %}</div>
{% if form.errors %}
<div class="ui small negative message">
{% if form.errors.email %}
<p>{% trans 'Email' %}:</p>
{{ form.errors.email|join:"<br />"|escape }}
{% endif %}
{% if form.errors.password1 %}
<p>{% trans 'Password' %}:</p>
{{ form.errors.password1|join:" <br />"|escape }}

{% endif %}
</div>
{% endif %}

</form>
<div class="ui horizontal divider">
{% trans 'Lub' %}
</div>
<button class="gsi-material-button" style="width:400px"
onclick="window.location.href='{% provider_login_url 'google' %}'">
<div class="gsi-material-button-state"></div>
<div class="gsi-material-button-content-wrapper">
<div class="gsi-material-button-icon">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"
xmlns:xlink="http://www.w3.org/1999/xlink" style="display: block;">
<path fill="#EA4335"
d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"></path>
<path fill="#4285F4"
d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"></path>
<path fill="#FBBC05"
d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"></path>
<path fill="#34A853"
d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"></path>
<path fill="none" d="M0 0h48v48H0z"></path>
</svg>
</div>
<span class="gsi-material-button-contents">{% trans 'Zarejestruj się z Google' %}</span>
<span style="display: none;">{% trans 'Zarejestruj się z Google' %}</span>
</div>
</button>
</div>
<div class="ui message">{% trans 'Masz konto?' %}<a
href="{% url 'user:login' %}"> {% trans 'Zaloguj się' %}</a>
</div>
</div>
</div>
{% endblock %}
11 changes: 4 additions & 7 deletions apps/user/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from django.urls import path

from apps.user.views import DashboardView, LoginNormalView, SignupNormalView
from apps.user.views import DashboardView, UserLoginView, UserLogoutView, UserSignupView

app_name = "user"
urlpatterns = [
# path(r"login/", LoginAPIView.as_view(), name="knox_login"),
# path(r"logout/", knox_views.LogoutView.as_view(), name="knox_logout"),
# path(r"logoutall/", knox_views.LogoutAllView.as_view(), name="knox_logoutall"),
# path(r"login/", LoginVIew.as_view(), name="login"),
path(r"login/", LoginNormalView.as_view(), name="login"),
path(r"signup/", SignupNormalView.as_view(), name="register"),
path(r"login/", UserLoginView.as_view(), name="login"),
path(r"signup/", UserSignupView.as_view(), name="register"),
path(r"signup/", UserLogoutView.as_view(), name="logout"),
path(r"dashboard/", DashboardView.as_view(), name="dashboard"),
]
Loading

0 comments on commit 0f34802

Please sign in to comment.