diff --git a/accounts/static/css/styles.css b/accounts/static/css/styles.css new file mode 100644 index 0000000..d7009ee --- /dev/null +++ b/accounts/static/css/styles.css @@ -0,0 +1,5 @@ +.sidebar-nav { + margin-top: 20px; + padding: 0; + list-style: none; +} \ No newline at end of file diff --git a/accounts/templates/base_generic.html b/accounts/templates/base_generic.html new file mode 100644 index 0000000..d400ea4 --- /dev/null +++ b/accounts/templates/base_generic.html @@ -0,0 +1,33 @@ + + + + {% block title %}Ambitious Server{% endblock %} + + + + {% load static %} + + + +
+
+
+ {% block sidebar %} + + {% endblock %} +
+
{% block content %}{% endblock %}
+
+
+ + \ No newline at end of file diff --git a/accounts/templates/index.html b/accounts/templates/index.html index 027a773..f47c226 100644 --- a/accounts/templates/index.html +++ b/accounts/templates/index.html @@ -1,10 +1,6 @@ - - - - - Highscore - - +{% extends "base_generic.html" %} + +{% block content %}

Highscore

{% if best_players %} @@ -25,7 +21,5 @@ {% endif %} Register now! -Login - - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/accounts/templates/login.html b/accounts/templates/login.html index 4a9787c..c3913da 100644 --- a/accounts/templates/login.html +++ b/accounts/templates/login.html @@ -1,10 +1,6 @@ - - - - - Login - - +{% extends "base_generic.html" %} + +{% block content %}

Login

@@ -13,5 +9,4 @@
- - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/logged_out.html b/accounts/templates/registration/logged_out.html new file mode 100644 index 0000000..5d28e65 --- /dev/null +++ b/accounts/templates/registration/logged_out.html @@ -0,0 +1,6 @@ +{% extends "base_generic.html" %} + +{% block content %} +

Logged out!

+ Click here to login again. +{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/login.html b/accounts/templates/registration/login.html new file mode 100644 index 0000000..f5f2bea --- /dev/null +++ b/accounts/templates/registration/login.html @@ -0,0 +1,40 @@ +{% extends "base_generic.html" %} + +{% block content %} + +{% if form.errors %} +

Your username and password didn't match. Please try again.

+{% endif %} + +{% if next %} + {% if user.is_authenticated %} +

Your account doesn't have access to this page. To proceed, + please login with an account that has access.

+ {% else %} +

Please login to see this page.

+ {% endif %} +{% endif %} + +
+{% csrf_token %} + + + + + + + + + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + + +
+ +{# Assumes you setup the password_reset view in your URLconf #} +

Lost password?

+ +{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/password_reset_complete.html b/accounts/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..a498b4b --- /dev/null +++ b/accounts/templates/registration/password_reset_complete.html @@ -0,0 +1,6 @@ +{% extends "base_generic.html" %} + +{% block content %} +

The password has been changed!

+

log in again?

+{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/password_reset_confirm.html b/accounts/templates/registration/password_reset_confirm.html new file mode 100644 index 0000000..b00c368 --- /dev/null +++ b/accounts/templates/registration/password_reset_confirm.html @@ -0,0 +1,29 @@ +{% extends "base_generic.html" %} + +{% block content %} + {% if validlink %} +

Please enter (and confirm) your new password.

+
+ {% csrf_token %} + + + + + + + + + + + + + +
{{ form.new_password1.errors }} + {{ form.new_password1 }}
{{ form.new_password2.errors }} + {{ form.new_password2 }}
+
+ {% else %} +

Password reset failed

+

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

+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/password_reset_done.html b/accounts/templates/registration/password_reset_done.html new file mode 100644 index 0000000..373b3fb --- /dev/null +++ b/accounts/templates/registration/password_reset_done.html @@ -0,0 +1,5 @@ +{% extends "base_generic.html" %} + +{% block content %} +

We've emailed you instructions for setting your password. If they haven't arrived in a few minutes, check your spam folder.

+{% endblock %} \ No newline at end of file diff --git a/accounts/templates/registration/password_reset_email.html b/accounts/templates/registration/password_reset_email.html new file mode 100644 index 0000000..61fba5c --- /dev/null +++ b/accounts/templates/registration/password_reset_email.html @@ -0,0 +1,2 @@ +Someone asked for password reset for email {{ email }}. Follow the link below: +{{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} \ No newline at end of file diff --git a/accounts/templates/registration/password_reset_form.html b/accounts/templates/registration/password_reset_form.html new file mode 100644 index 0000000..0f811c9 --- /dev/null +++ b/accounts/templates/registration/password_reset_form.html @@ -0,0 +1,12 @@ +{% extends "base_generic.html" %} + +{% block content %} +
+ {% csrf_token %} + {% if form.email.errors %} + {{ form.email.errors }} + {% endif %} +

{{ form.email }}

+ +
+{% endblock %} \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py index 296705b..44e221b 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -30,4 +30,4 @@ class IndexView(generic.ListView): context_object_name = 'best_players' def get_queryset(self): - return Players.objects.filter(group_id=1).order_by('-level')[:10] \ No newline at end of file + return Players.objects.filter(group_id=1).order_by('-level').values('name', 'level')[:10] \ No newline at end of file diff --git a/tibia_website/settings.py b/tibia_website/settings.py index 3f4b906..d6354ad 100644 --- a/tibia_website/settings.py +++ b/tibia_website/settings.py @@ -55,7 +55,7 @@ ROOT_URLCONF = 'tibia_website.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -123,3 +123,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' + +# Redirect to home URL after login (Default redirects to /accounts/profile/) +LOGIN_REDIRECT_URL = '/' + diff --git a/tibia_website/urls.py b/tibia_website/urls.py index 21b6cd1..decd944 100644 --- a/tibia_website/urls.py +++ b/tibia_website/urls.py @@ -18,5 +18,6 @@ from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), - path('accounts/', include('accounts.urls') ) + path('accounts/', include('accounts.urls')), + path('auth/', include('django.contrib.auth.urls')), ]