Browse Source

feat(base): ajoute une page d'accueil pour les visiteurs

pull/100/head
Jérôme Lebleu 3 years ago
parent
commit
05a6443a33
  1. 4
      .stylelintrc
  2. BIN
      assets/img/hand_bottom-left.png
  3. BIN
      assets/img/hand_bottom-right.png
  4. BIN
      assets/img/hand_top-left.png
  5. BIN
      assets/img/hand_top-right.png
  6. BIN
      assets/img/logo-home.png
  7. 2
      assets/scss/app.scss
  8. 47
      assets/scss/pages/_home.scss
  9. 32
      benevalibre/base/tests/test_views.py
  10. 38
      benevalibre/base/views.py
  11. 2
      benevalibre/templates/base.html
  12. 16
      benevalibre/templates/base/home.html

4
.stylelintrc

@ -268,9 +268,9 @@ @@ -268,9 +268,9 @@
"selector-no-vendor-prefix": true,
"string-quotes": "double",
"value-keyword-case": "lower",
"value-list-comma-newline-after": "never-multi-line",
"value-list-comma-newline-after": "always-multi-line",
"value-list-comma-newline-before": "never-multi-line",
"value-list-comma-space-after": "always",
"value-list-comma-space-after": "always-single-line",
"value-no-vendor-prefix": true
}
}

BIN
assets/img/hand_bottom-left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/img/hand_bottom-right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
assets/img/hand_top-left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
assets/img/hand_top-right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
assets/img/logo-home.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

2
assets/scss/app.scss

@ -28,4 +28,4 @@ @@ -28,4 +28,4 @@
@import "components/tables";
// Page-specific styles
//@import "pages/home";
@import "pages/home";

47
assets/scss/pages/_home.scss

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
// -----------------------------------------------------------------------------
// Specific styles for the homepage
// -----------------------------------------------------------------------------
.homepage {
color: $white;
background-color: $primary;
background-image:
url("#{$img-path}/hand_top-left.png"),
url("#{$img-path}/hand_top-right.png"),
url("#{$img-path}/hand_bottom-right.png"),
url("#{$img-path}/hand_bottom-left.png");
background-repeat: no-repeat;
background-position:
left 5%,
95% top,
right 95%,
left 101%;
background-size: auto 30%;
@media (orientation: portrait) and (min-height: 540px) {
background-size: 40% auto;
}
@media (min-width: 1024px), (min-height: 768px) {
background-size: auto;
}
}
.homepage-header {
position: absolute;
top: 1rem;
right: 2rem;
z-index: $zindex-sticky;
}
.homepage-content {
@include grid-cell(shrink);
max-width: 600px;
padding: 2rem;
}
.homepage-lead {
@include media-breakpoint-up(md) {
font-size: $lead-font-size;
}
}

32
benevalibre/base/tests/test_views.py

@ -10,27 +10,21 @@ from benevalibre.association.models import Association @@ -10,27 +10,21 @@ from benevalibre.association.models import Association
from benevalibre.utils.tests import count_text_in_content, is_login_view
@pytest.mark.django_db
class TestLandingPage:
@pytest.mark.parametrize(
'use, expected',
[
(None, 'association:index'),
('user', 'base:board'),
('staff', 'association:index'),
],
)
def test_get_index(
self, client, association, engagement, user, superuser, use, expected
):
if use == 'staff':
client.force_login(superuser)
elif use:
client.force_login(user)
class TestHome:
url = reverse_lazy('base:home')
def test_anonymous(self, client):
response = client.get(self.url)
assert response.status_code == 200
assert count_text_in_content(response, reverse('association:index'))
@pytest.mark.django_db
def test_user_redirect(self, client, user):
client.force_login(user)
response = client.get(reverse('base:home'))
response = client.get(self.url)
assert response.status_code == 302
assert response.url == reverse(expected)
assert response.url == reverse('base:board')
@pytest.mark.django_db

38
benevalibre/base/views.py

@ -6,7 +6,7 @@ from django.http import Http404 @@ -6,7 +6,7 @@ from django.http import Http404
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse, reverse_lazy
from django.utils.text import slugify
from django.views import generic
from django.views.generic import FormView, TemplateView
from cruditor.views import (
CruditorAddView,
@ -25,7 +25,7 @@ from benevalibre.association.views import ( @@ -25,7 +25,7 @@ from benevalibre.association.views import (
)
from benevalibre.benevalo.models import Benevalo
from benevalibre.utils.html import fa_icon
from benevalibre.utils.views import CruditorPageMixin
from benevalibre.utils.views import CruditorPageMixin, PageMixin
from . import forms, tables
@ -59,30 +59,20 @@ class ExportTable(ExportMixin): @@ -59,30 +59,20 @@ class ExportTable(ExportMixin):
return context
# ----------------------------------------------------------------------------
# Board
# ----------------------------------------------------------------------------
class Home(PageMixin, TemplateView):
template_name = 'base/home.html'
page_title = "Accueil"
def get(self, *args, **kwargs):
# Redirect to the board if the user is logged in
if not self.request.user.is_anonymous:
return redirect('base:board')
return super().get(*args, **kwargs)
class Home(generic.RedirectView):
"""
La page d'accueil de l'application vous oriente :
* soit vers la page « liste des associations » si votre compte ne contient
pas d'engagement associatif ;
* soit vers votre « tableau de bord ».
"""
def get_redirect_url(self, *args, **kwargs):
"""Dispatch between Board and AssociationIndex depending on things
user has to see in Board"""
if (
not self.request.user.is_anonymous
and self.request.user.engagement_set.exists()
):
return reverse('base:board')
else:
return reverse('association:index')
# ----------------------------------------------------------------------------
# Board
# ----------------------------------------------------------------------------
class AssociationEngage(
@ -90,7 +80,7 @@ class AssociationEngage( @@ -90,7 +80,7 @@ class AssociationEngage(
AssociationManageMenu,
CruditorPageMixin,
SuccessMessageMixin,
generic.FormView,
FormView,
):
"""
Pour s'engager comme bénévole auprès d'une association, il suffit de

2
benevalibre/templates/base.html

@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
{% block extra_head %}{% endblock %}
</head>
<body>
{% block container %}
<div class="app-container">
{% block header %}
<header class="app-header">
@ -60,6 +61,7 @@ @@ -60,6 +61,7 @@
</footer>
{% endblock %}
</div>
{% endblock container %}
{% block javascript %}
<script src="{% minified "js/app.js" %}"></script>

16
benevalibre/templates/base/home.html

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load static %}
{% block container %}
<div class="app-container align-items-center justify-content-center homepage">
<header class="homepage-header">
<a href="{% url "accounts:login" %}" class="text-secondary">Se connecter</a>
</header>
<main class="homepage-content text-center">
<img src="{% static "img/logo-home.png" %}" alt="Bénévalibre" class="img-fluid mb-2 mb-md-3">
<p class="homepage-lead mb-md-4">Le logiciel libre qui facilite la gestion et la valorisation du bénévolat dans les associations.</p>
<a href="{% url "association:index" %}" class="btn btn-light btn-lg">Voir les associations</a>
</main>
</div>
{% endblock %}
Loading…
Cancel
Save
Map all the world