diff --git a/Pipfile b/Pipfile index 7d344b5..92738f1 100644 --- a/Pipfile +++ b/Pipfile @@ -12,6 +12,7 @@ django-cors-headers = "<4.0,>=3.3" libsass = "<1.0,>=0.20" django-compressor = "<3.0,>=2.4" django-sass-processor = "<1.0,>=0.8" +django-bulma = "<1.0,>=0.8" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 7ddd8e2..0d622f2 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "dc5e09cf5a83f95b807af9b31a20744b8519865aa55ea7e2c98c5d6270dcacbf" + "sha256": "d6c40583e1aacc68edcdd2ff170436da48130d6c02c24118eb56402040b495d7" }, "pipfile-spec": 6, "requires": { @@ -18,11 +18,11 @@ "default": { "asgiref": { "hashes": [ - "sha256:8036f90603c54e93521e5777b2b9a39ba1bad05773fcf2d208f0299d1df58ce5", - "sha256:9ca8b952a0a9afa61d30aa6d3d9b570bb3fd6bafcf7ec9e6bed43b936133db1c" + "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a", + "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed" ], "markers": "python_version >= '3.5'", - "version": "==3.2.7" + "version": "==3.2.10" }, "beautifulsoup4": { "hashes": [ @@ -34,10 +34,10 @@ }, "certifi": { "hashes": [ - "sha256:5ad7e9a056d25ffa5082862e36f119f7f7cec6457fa07ee2f8c339814b80c9b1", - "sha256:9cd41137dc19af6a5e03b630eefe7d1f458d964d406342dd3edf625839b944cc" + "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3", + "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41" ], - "version": "==2020.4.5.2" + "version": "==2020.6.20" }, "chardet": { "hashes": [ @@ -61,6 +61,14 @@ ], "version": "==1.0.4" }, + "django-bulma": { + "hashes": [ + "sha256:27b1ba2491e407f87e35e9be685c26cdd6b214eea8ea9dcf4e30f215e85512b6", + "sha256:f8c08ba8612556785dc20d0f56f7ac9784b3b0c59a996c4abec1a04372bb35c8" + ], + "index": "pypi", + "version": "==0.8.0" + }, "django-compressor": { "hashes": [ "sha256:57ac0a696d061e5fc6fbc55381d2050f353b973fb97eee5593f39247bc0f30af", @@ -71,11 +79,11 @@ }, "django-cors-headers": { "hashes": [ - "sha256:48d267c10d11d8e17805bf896071c0a3e8efb6f79f6634a90e6faac4c2f8a1a0", - "sha256:73d654950b5f5e7e4f67c05183d2169d4f7518ceb87734eb0d68f9e43be59f1c" + "sha256:5240062ef0b16668ce8a5f43324c388d65f5439e1a30e22c38684d5ddaff0d15", + "sha256:f5218f2f0bb1210563ff87687afbf10786e080d8494a248e705507ebd92d7153" ], "index": "pypi", - "version": "==3.3.0" + "version": "==3.4.0" }, "django-modelcluster": { "hashes": [ @@ -204,11 +212,11 @@ }, "requests": { "hashes": [ - "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee", - "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6" + "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b", + "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==2.23.0" + "version": "==2.24.0" }, "rjsmin": { "hashes": [ diff --git a/home/templates/home/user_view.html b/home/templates/home/user_view.html new file mode 100644 index 0000000..5e65f14 --- /dev/null +++ b/home/templates/home/user_view.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} + +{% block title %}{{ object.get_full_name }}{% endblock %} + +{% block header %} +
+
{{ block.super }}
+
+
+
+
+
+
+ {{ object.username }} +
+
+
+
+
+

{{ object.get_full_name }}

+

{{ object.username }}

+
+
+
+
+
+
+{% endblock %} + +{% block content %} +
+
{% lorem 10 %}
+
+{% endblock %} \ No newline at end of file diff --git a/home/urls.py b/home/urls.py new file mode 100644 index 0000000..76b4fa6 --- /dev/null +++ b/home/urls.py @@ -0,0 +1,11 @@ +from django.urls import path, include +from wagtail.core import urls as wagtail_urls + +from home import views + +app_name = "home" + +urlpatterns = [ + path("", include(wagtail_urls)), + path("profil/", views.UserView.as_view(), name="profile") +] diff --git a/home/views.py b/home/views.py new file mode 100644 index 0000000..0f91a5e --- /dev/null +++ b/home/views.py @@ -0,0 +1,8 @@ +from django.contrib.auth import get_user_model +from django.views.generic import DetailView + + +class UserView(DetailView): + template_name = "home/user_view.html" + model = get_user_model() + slug_field = "username" diff --git a/server/settings/base.py b/server/settings/base.py index 33cf846..d114ff7 100644 --- a/server/settings/base.py +++ b/server/settings/base.py @@ -13,6 +13,8 @@ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +from django.urls import reverse_lazy as reverse + PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(PROJECT_DIR) @@ -25,6 +27,7 @@ INSTALLED_APPS = [ 'api', 'home', + 'user', 'search', 'wagtail.contrib.forms', @@ -44,6 +47,7 @@ 'taggit', 'corsheaders', 'sass_processor', + 'bulma', 'django.contrib.admin', 'django.contrib.auth', @@ -130,6 +134,10 @@ USE_TZ = True +LOGIN_URL = reverse("user:login") +LOGOUT_URL = reverse("user:logout") +LOGIN_REDIRECT_URL = LOGOUT_REDIRECT_URL = "/" + # CORS CORS_ORIGIN_WHITELIST = [ @@ -153,9 +161,6 @@ # SASS configure -SASS_PROCESSOR_INCLUDE_PATHS = [ - os.path.join(BASE_DIR, "node_modules") -] SASS_PROCESSOR_INCLUDE_FILE_PATTERN = r'.s[ac]ss$' SASS_OUTPUT_STYLE = 'compact' diff --git a/server/static/js/navbar.js b/server/static/js/interaction-base.js similarity index 77% rename from server/static/js/navbar.js rename to server/static/js/interaction-base.js index 9b18a3e..65ab4ba 100644 --- a/server/static/js/navbar.js +++ b/server/static/js/interaction-base.js @@ -22,4 +22,7 @@ document.addEventListener('DOMContentLoaded', () => { }); } + // Destroy notification with close buttons + const $notificationDeleteButtons = document.querySelectorAll(".notification .delete"); + $notificationDeleteButtons.forEach(n => console.log("notification delete", n)); }); \ No newline at end of file diff --git a/server/static/sass/_overrides.sass b/server/static/sass/_overrides.sass index c041066..fdfaa80 100644 --- a/server/static/sass/_overrides.sass +++ b/server/static/sass/_overrides.sass @@ -2,4 +2,9 @@ text-align: justify max-width: 60em margin-left: auto - margin-right: auto \ No newline at end of file + margin-right: auto + +.form-wrapper + max-width: 10em + margin-left: auto + margin-right: auto diff --git a/server/static/sass/_variables.sass b/server/static/sass/_variables.sass index 877eb17..baec3cb 100644 --- a/server/static/sass/_variables.sass +++ b/server/static/sass/_variables.sass @@ -12,6 +12,6 @@ $scheme-main: #eee1e1 $scheme-bis: darken($scheme-main, 3) $scheme-ter: darken($scheme-main, 8) -$link: $accent +$link: $secondary $custom-colors: ("accent": ($accent, findColorInvert($accent)), "secondary": ($secondary, findColorInvert($secondary))) diff --git a/server/templates/base.html b/server/templates/base.html index 849299d..9ece628 100644 --- a/server/templates/base.html +++ b/server/templates/base.html @@ -11,7 +11,7 @@ {% endblock %} {% block title_suffix %} {% with self.get_site.site_name as site_name %} - {% if site_name %}- {{ site_name }}{% endif %} + {% if site_name %}- {{ site_name }}{% else %}- Tutorat Associatif Toulousain{% endif %} {% endwith %} {% endblock %} @@ -31,11 +31,10 @@ {% wagtailuserbar %} {% block header %}{% include "include/navbar.html" %}{% endblock %} - +
{% include "include/messages.html" %}
{% block content %}{% endblock %}
- - + {% block extra_js %} {# Override this in templates to add extra javascript #} {% endblock %} diff --git a/server/templates/form_view_base.html b/server/templates/form_view_base.html new file mode 100644 index 0000000..ae09ba1 --- /dev/null +++ b/server/templates/form_view_base.html @@ -0,0 +1,14 @@ +{% extends "transitive_base.html" %} +{% load bulma_tags %} + +{% block transitive %} +
+

{{ title }}

+

{{ subtitle|safe|default:"" }}

+ + {% csrf_token %} + {{ form|bulma }} + + +
+{% endblock %} \ No newline at end of file diff --git a/server/templates/include/messages.html b/server/templates/include/messages.html new file mode 100644 index 0000000..4d59d05 --- /dev/null +++ b/server/templates/include/messages.html @@ -0,0 +1,7 @@ +
+
+ {% for message in messages %} +
{{ message }}
+ {% endfor %} +
+
\ No newline at end of file diff --git a/server/templates/include/navbar.html b/server/templates/include/navbar.html index c477bff..bba11d2 100644 --- a/server/templates/include/navbar.html +++ b/server/templates/include/navbar.html @@ -31,6 +31,16 @@ + {% if request.user.is_authenticated %} + Déconnexion + {% else %} + + + {% endif %} \ No newline at end of file diff --git a/server/templates/transitive_base.html b/server/templates/transitive_base.html new file mode 100644 index 0000000..4368c68 --- /dev/null +++ b/server/templates/transitive_base.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block header %} +
+
{{ block.super }}
+
+ {% block transitive %}{% endblock %} +
+
+{% endblock %} + +{% block content %} + +{% endblock %} \ No newline at end of file diff --git a/server/urls.py b/server/urls.py index f2c1af8..fc2fa69 100644 --- a/server/urls.py +++ b/server/urls.py @@ -1,28 +1,24 @@ from django.conf import settings -from django.conf.urls import include, url from django.contrib import admin - +from django.urls import path, include from wagtail.admin import urls as wagtailadmin_urls -from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls from search import views as search_views from server.api import api_router urlpatterns = [ - url(r'^django-admin/', admin.site.urls), - url(r'^api/v2/', api_router.urls), - url(r'^admin/', include(wagtailadmin_urls)), - url(r'^documents/', include(wagtaildocs_urls)), + path('django-admin/', admin.site.urls), + path('api/v2/', api_router.urls), + path('admin/', include(wagtailadmin_urls)), + path('documents/', include(wagtaildocs_urls)), - url(r'^search/$', search_views.search, name='search'), + path('search/', search_views.search, name='search'), - # For anything not caught by a more specific rule above, hand over to - # Wagtail's page serving mechanism. This should be the last pattern in - # the list: - url(r'', include(wagtail_urls)), -] + path("", include("user.urls")), + path('', include("home.urls")), +] if settings.DEBUG: from django.conf.urls.static import static diff --git a/user/__init__.py b/user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/user/apps.py b/user/apps.py new file mode 100644 index 0000000..35048d4 --- /dev/null +++ b/user/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserConfig(AppConfig): + name = 'user' diff --git a/user/migrations/__init__.py b/user/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/user/models.py b/user/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/user/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/user/templates/user/login.html b/user/templates/user/login.html new file mode 100644 index 0000000..d9db3fc --- /dev/null +++ b/user/templates/user/login.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% load bulma_tags %} + +{% block header %} +
+
{{ block.super }}
+
+
+

Se connecter

+

Pas de compte ? Créez-en vous un dès maintenant !

+
+
+ {% csrf_token %} + {{ form|bulma }} + +
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/templates/user/signup.html b/user/templates/user/signup.html new file mode 100644 index 0000000..da987bf --- /dev/null +++ b/user/templates/user/signup.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% load bulma_tags %} + +{% block header %} +
+
{{ block.super }}
+
+
+
Créer un compte
+

Compte déjà créé ? Connectez-vous ici !

+
+
+
+ {% csrf_token %} + {{ form | bulma }} + +
+
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/user/urls.py b/user/urls.py new file mode 100644 index 0000000..2074b5c --- /dev/null +++ b/user/urls.py @@ -0,0 +1,13 @@ +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.views import LogoutView +from django.urls import path + +from user.views import SignupView, LoginView + +app_name = "user" + +urlpatterns = [ + path("signup", SignupView.as_view(), name="signup"), + path("login", LoginView.as_view(), name="login"), + path("logout", LogoutView.as_view(), name="logout") +] diff --git a/user/views.py b/user/views.py new file mode 100644 index 0000000..611b3bb --- /dev/null +++ b/user/views.py @@ -0,0 +1,22 @@ +from django.contrib.auth.forms import UserCreationForm +from django.urls import reverse_lazy as reverse +from django.views.generic import FormView +from wagtail.admin.forms.auth import LoginForm + + +class SignupView(FormView): + form_class = UserCreationForm + template_name = "form_view_base.html" + title = "Créer un compte" + subtitle = f'Compte déjà créé ? Connectez-vous ici !' + action = reverse("user:signup") + method = "post" + + +class LoginView(FormView): + form_class = LoginForm + template_name = "form_view_base.html" + title = "Se connecter" + subtitle = f'Pas de compte ? Créez-vous un compte dès maintenant !' + action = reverse("user:signup") + method = "post"