Compare commits

...

15 commits

Author SHA1 Message Date
Martin Pépin
8191d72d7c
Allow BDS staff members to update a user's account 2020-06-08 18:30:40 +02:00
Martin Pépin
f6e1f39cff
Factor out the CSS code for messages 2020-06-08 18:26:04 +02:00
Martin Pépin
c5e0e633e8
BDS: fancier home page 2020-06-07 23:49:51 +02:00
Martin Pépin
1767259efd
Restrict bds views to the staff 2020-06-07 23:49:50 +02:00
Martin Pépin
de2a013a16
BDS: user search on the home page 2020-06-07 23:49:50 +02:00
Martin Pépin
2cff19cee1
Add user-search in the BDS app 2020-06-07 23:49:50 +02:00
Martin Pépin
001a832116
Move the 'utils' template tags to the shared app 2020-06-07 23:49:42 +02:00
Martin Pépin
87184eaadc
Make events tests independent of LOGIN_URL 2020-06-04 18:02:40 +02:00
Martin Pépin
3946032362
only run relevant tests in cof/bds CI 2020-06-04 18:02:40 +02:00
Martin Pépin
ee3b197ad4
Fix settings.local.ALLOWED_HOSTS 2020-06-04 18:02:40 +02:00
Martin Pépin
2d7cd5408b
Use the new settings in gitlab-ci 2020-06-04 18:02:40 +02:00
Martin Pépin
586df45a2f
Add wsgi file 2020-06-04 18:02:40 +02:00
Martin Pépin
0d8c97dbf7
One url file to rule them all,
one url file to find them
One url file to bring them all,
and in the darkness bind them.
2020-06-04 18:02:40 +02:00
Martin Pépin
d8e3cd6566
Split settings between COF / BDS / Local 2020-06-04 18:02:40 +02:00
Martin Pépin
035a8cce3b
Merge local and dev settings 2020-06-04 18:02:36 +02:00
30 changed files with 1067 additions and 383 deletions

View file

@ -2,7 +2,6 @@ image: "python:3.7"
variables:
# GestioCOF settings
DJANGO_SETTINGS_MODULE: "cof.settings.prod"
DBHOST: "postgres"
REDIS_HOST: "redis"
REDIS_PASSWD: "dummy"
@ -18,8 +17,7 @@ variables:
# psql password authentication
PGPASSWORD: $POSTGRES_PASSWORD
test:
stage: test
.test_template:
before_script:
- mkdir -p vendor/{pip,apt}
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client
@ -29,8 +27,6 @@ test:
- psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB"
- pip install --upgrade -r requirements-prod.txt coverage tblib
- python --version
script:
- coverage run manage.py test --parallel
after_script:
- coverage report
services:
@ -44,6 +40,22 @@ test:
# Keep this disabled for now, as it may kill GitLab...
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
coftest:
stage: test
extends: .test_template
variables:
DJANGO_SETTINGS_MODULE: "cof.settings.cof_prod"
script:
- coverage run manage.py test gestioncof bda kfet petitscours shared --parallel
bdstest:
stage: test
extends: .test_template
variables:
DJANGO_SETTINGS_MODULE: "cof.settings.bds_prod"
script:
- coverage run manage.py test bds clubs events --parallel
linters:
stage: test
before_script:
@ -60,8 +72,7 @@ linters:
- vendor/
# Check whether there are some missing migrations.
migration_checks:
stage: test
.migration_checks_template:
before_script:
- mkdir -p vendor/{pip,apt}
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client
@ -76,3 +87,15 @@ migration_checks:
key: migration_checks
paths:
- vendor/
cof_migration_checks:
stage: test
extends: .migration_checks_template
variables:
DJANGO_SETTINGS_MODULE: "cof.settings.cof_prod"
bds_migration_checks:
stage: test
extends: .migration_checks_template
variables:
DJANGO_SETTINGS_MODULE: "cof.settings.bds_prod"

37
bds/autocomplete.py Normal file
View file

@ -0,0 +1,37 @@
from django.contrib.auth import get_user_model
from django.db.models import Q
from shared.views import autocomplete
User = get_user_model()
class BDSMemberSearch(autocomplete.ModelSearch):
model = User
search_fields = ["username", "first_name", "last_name"]
def get_queryset_filter(self, *args, **kwargs):
qset_filter = super().get_queryset_filter(*args, **kwargs)
qset_filter &= Q(bds__is_member=True)
return qset_filter
class BDSOthersSearch(autocomplete.ModelSearch):
model = User
search_fields = ["username", "first_name", "last_name"]
def get_queryset_filter(self, *args, **kwargs):
qset_filter = super().get_queryset_filter(*args, **kwargs)
qset_filter &= Q(bds__isnull=True) | Q(bds__is_member=False)
return qset_filter
class BDSSearch(autocomplete.Compose):
search_units = [
("members", "username", BDSMemberSearch),
("others", "username", BDSOthersSearch),
("clippers", "clipper", autocomplete.LDAPSearch),
]
bds_search = BDSSearch()

30
bds/forms.py Normal file
View file

@ -0,0 +1,30 @@
from django import forms
from django.contrib.auth import get_user_model
from bds.models import BDSProfile
User = get_user_model()
class BDSUserForm(forms.ModelForm):
class Meta:
model = User
fields = ["first_name", "last_name", "email"]
class BDSProfileForm(forms.ModelForm):
class Meta:
model = BDSProfile
fields = [
"phone",
"occupation",
"departement",
"birthdate",
"mails_bds",
"has_certificate",
"ASPSL_number",
"FFSU_number",
"is_member",
"cotisation_period",
"cotisation_type",
]

5
bds/mixins.py Normal file
View file

@ -0,0 +1,5 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
class StaffRequiredMixin(PermissionRequiredMixin):
permission_required = "bds:is_team"

121
bds/static/bds/css/bds.css Normal file
View file

@ -0,0 +1,121 @@
html, body {
padding: 0;
margin: 0;
background: #ddcecc;
font-size: 18px;
}
input {
font-size: 18px;
border: 0;
padding: 10px;
}
a {
text-decoration: none;
color: #a82305;
}
/* header */
nav {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
background: #3e2263;
height: 3em;
padding: 0.4em 1em;
}
nav a, nav a img {
height: 100%;
}
#search_autocomplete {
flex: 1;
width: 480px;
}
.highlight {
text-decoration: underline;
font-weight: bold;
}
.yourlabs-autocomplete ul {
width: 500px;
list-style: none;
padding: 0;
margin: 0;
}
.yourlabs-autocomplete ul li {
height: 2em;
line-height: 2em;
width: 500px;
padding: 0;
}
.yourlabs-autocomplete ul li.hilight {
background: #e8554e;
}
.yourlabs-autocomplete ul li a {
color: inherit;
}
.autocomplete-item {
display: block;
width: 480px;
height: 100%;
padding: 2px 10px;
margin: 0;
}
.autocomplete-header {
background: #b497e1;
}
.autocomplete-value, .autocomplete-new, .autocomplete-more {
background: white;
}
/* Forms */
form {
width: 50%;
margin: auto;
}
.form-field {
width: 90%;
margin: auto;
padding-top: 1em;
}
.form-field label {
display: inline-block;
padding 0;
}
.form-field input {
display: inline-block;
width: 99%;
padding: 1% 0.5%;
}
.form-field input[type="checkbox"] {
width: 1em;
}
form input[type="submit"] {
display: block;
width: 30%;
margin: auto;
margin-top: 1em;
margin-bottom: 1em;
}
form input[type="submit"]:hover {
background: #e8554e;
}

View file

@ -0,0 +1,15 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="300px" height="246px" viewBox="0 0 3000 2460" preserveAspectRatio="xMidYMid meet">
<g id="layer101" fill="#ffffff" stroke="none">
<path d="M0 1230 l0 -1230 1500 0 1500 0 0 1230 0 1230 -1500 0 -1500 0 0 -1230z"/>
</g>
<g id="layer102" fill="#3e2263" stroke="none">
<path d="M0 1230 l0 -1230 1500 0 1500 0 0 1230 0 1230 -1500 0 -1500 0 0 -1230z m1716 765 c103 -17 204 -46 284 -83 l55 -25 -40 -8 c-80 -16 -169 -10 -245 16 -123 42 -232 59 -385 59 -126 0 -278 -18 -341 -40 -13 -5 -16 -4 -9 4 14 15 166 60 254 76 102 19 315 19 427 1z m-703 -217 c15 -6 27 -13 27 -17 0 -4 -37 -25 -82 -47 -86 -43 -182 -120 -193 -155 -8 -26 32 -113 78 -167 44 -52 46 -62 10 -62 -39 1 -106 33 -165 80 -40 31 -54 38 -64 29 -21 -18 -17 -50 16 -116 57 -113 151 -199 259 -235 49 -16 51 -18 16 -13 -123 19 -260 151 -322 310 -15 39 -14 -81 1 -147 25 -107 55 -176 112 -251 49 -65 52 -73 38 -88 -21 -23 -104 -62 -216 -100 -51 -18 -97 -35 -102 -40 -4 -4 32 -10 80 -14 106 -9 256 13 317 48 l39 22 56 -33 c32 -18 114 -61 184 -95 80 -39 126 -67 123 -74 -6 -19 12 -16 19 3 9 24 28 5 22 -22 -7 -26 8 -34 18 -9 11 29 28 16 21 -18 -6 -30 -5 -31 10 -13 8 11 15 24 15 29 0 4 5 5 10 2 6 -3 8 -18 4 -33 -5 -26 -5 -26 10 -8 15 19 18 19 118 -12 113 -35 284 -72 329 -72 24 0 29 4 29 25 0 34 -36 125 -63 158 l-22 28 -59 -30 c-74 -39 -165 -43 -233 -10 -24 11 -43 25 -43 30 0 4 28 6 63 2 49 -4 71 -2 98 12 46 23 79 55 79 75 0 16 -48 66 -135 139 l-40 33 43 -23 c55 -30 166 -121 188 -154 9 -13 13 -29 9 -36 -15 -23 -100 -69 -129 -69 -17 0 -38 -5 -46 -10 -12 -8 -10 -10 10 -10 49 1 104 19 149 51 l45 31 24 -28 c33 -40 72 -128 79 -180 10 -79 -25 -96 -233 -114 -84 -7 -148 -7 -218 0 -106 12 -269 51 -317 76 -28 14 -31 13 -62 -10 -56 -43 -167 -89 -225 -94 l-55 -5 6 29 c2 16 14 55 26 86 21 57 27 112 15 142 -3 9 -34 38 -68 64 l-62 49 -104 7 c-166 12 -192 34 -83 70 34 12 65 24 68 28 4 4 -7 27 -24 52 -118 171 -124 402 -16 571 18 29 50 88 70 131 42 93 99 154 168 184 82 35 212 44 280 18z m540 -39 c60 -16 70 -41 75 -196 l5 -134 -39 3 -39 3 -5 114 c-4 93 -8 116 -22 125 -31 19 -41 -7 -47 -126 l-6 -113 -32 -3 c-41 -4 -44 6 -34 151 9 143 25 172 101 186 3 0 22 -4 43 -10z m322 -34 c0 -30 0 -30 -64 -33 l-64 -3 7 -130 7 -129 -35 0 -36 0 0 165 0 166 93 -3 92 -3 0 -30z m115 -55 l5 -84 18 27 c21 33 39 34 60 5 15 -22 16 -18 16 60 l1 82 35 0 35 0 -2 -162 -3 -163 -40 0 c-38 0 -41 2 -53 43 -16 49 -24 48 -42 -7 -12 -38 -16 -41 -50 -41 -34 0 -38 3 -44 31 -8 43 -8 284 1 293 4 4 19 6 33 4 24 -3 25 -6 30 -88z m370 -42 c193 -243 228 -505 100 -759 -61 -120 -195 -260 -328 -343 -66 -41 -60 -26 13 33 36 29 92 85 125 126 182 230 209 500 75 753 -42 79 -45 89 -45 163 0 44 4 79 9 79 5 0 28 -24 51 -52z m-1111 -294 c76 -30 94 -102 41 -156 -27 -27 -29 -32 -17 -47 34 -40 25 -100 -19 -120 -30 -13 -143 -15 -164 -1 -11 7 -15 42 -18 164 l-4 156 23 9 c37 15 115 13 158 -5z m571 -9 c84 -43 61 -135 -43 -173 -46 -18 -52 -23 -52 -48 0 -39 30 -42 79 -9 l37 25 -3 -41 c-4 -49 -32 -76 -90 -85 -32 -6 -41 -2 -68 24 -24 25 -30 39 -30 74 0 57 21 85 87 114 40 18 54 29 51 42 -5 29 -71 28 -111 -2 -19 -14 -36 -26 -39 -26 -11 0 -16 55 -7 72 24 45 131 63 189 33z m-303 -12 c56 -26 75 -65 71 -150 -3 -67 -6 -75 -38 -108 -43 -44 -94 -61 -146 -48 l-39 9 -3 144 c-1 79 0 150 2 157 8 19 110 17 153 -4z"/>
<path d="M1503 633 c4 -3 10 -3 14 0 3 4 0 7 -7 7 -7 0 -10 -3 -7 -7z"/>
<path d="M1532 448 c3 -7 15 -14 29 -16 23 -2 23 -2 5 13 -24 18 -39 20 -34 3z"/>
<path d="M1140 1231 c0 -45 10 -61 36 -61 26 0 64 32 64 53 0 23 -23 37 -62 37 -35 0 -38 -2 -38 -29z"/>
<path d="M1140 1070 c0 -35 17 -45 56 -36 20 5 25 12 22 34 -3 23 -8 27 -40 30 -36 3 -38 2 -38 -28z"/>
<path d="M1430 1151 c0 -72 3 -91 14 -91 28 0 47 13 61 41 31 60 10 121 -47 135 l-28 6 0 -91z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:ns1="http://sozi.baierouge.fr"
xmlns:cc="http://web.resource.org/cc/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
id="Layer_1"
enable-background="new 0 0 40 40"
xml:space="preserve"
viewBox="0 0 40 40"
version="1.1"
y="0px"
x="0px"
>
<polygon
points="36.351 32.435 25.5 36.271 25.5 3.94 36.351 6.242"
fill="#ffffff"
/>
<g
fill="#ffffff"
>
<path
d="m13.627 29.253l8.123-8.941c0.241-0.241 0.379-0.58 0.379-0.934s-0.138-0.693-0.379-0.934l-8.123-8.943c-0.346-0.348-0.853-0.44-1.286-0.238-0.436 0.203-0.717 0.662-0.717 1.171v3.193h-7.745c-0.658 0-1.191 0.572-1.191 1.277v8.943c0 0.705 0.533 1.276 1.191 1.276h7.745v3.194c0 0.509 0.281 0.969 0.716 1.172 0.434 0.204 0.94 0.112 1.287-0.236z"
/>
<path
d="m13.627 29.253l8.123-8.941c0.241-0.241 0.379-0.58 0.379-0.934s-0.138-0.693-0.379-0.934l-8.123-8.943c-0.346-0.348-0.853-0.44-1.286-0.238-0.436 0.203-0.717 0.662-0.717 1.171v3.193h-7.745c-0.658 0-1.191 0.572-1.191 1.277v8.943c0 0.705 0.533 1.276 1.191 1.276h7.745v3.194c0 0.509 0.281 0.969 0.716 1.172 0.434 0.204 0.94 0.112 1.287-0.236z"
/>
</g
>
<path
stroke-linejoin="round"
d="m24.166 6.224h-1.288c-1.78 0-3.223 1.442-3.223 3.223v3.981"
stroke="#ffffff"
stroke-linecap="round"
stroke-miterlimit="10"
fill="none"
/>
<path
stroke-linejoin="round"
d="m19.655 25.495v3.733c0 1.78 1.442 3.223 3.223 3.223h1.288"
stroke="#ffffff"
stroke-linecap="round"
stroke-miterlimit="10"
fill="none"
/>
<metadata
><rdf:RDF
><cc:Work
><dc:format
>image/svg+xml</dc:format
><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
/><cc:license
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
/><dc:publisher
><cc:Agent
rdf:about="http://openclipart.org/"
><dc:title
>Openclipart</dc:title
></cc:Agent
></dc:publisher
></cc:Work
><cc:License
rdf:about="http://creativecommons.org/licenses/publicdomain/"
><cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction"
/><cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution"
/><cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
/></cc:License
></rdf:RDF
></metadata
></svg
>

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,25 @@
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>{{ site.name }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{# CSS #}
<link rel="stylesheet" href="{% static "bds/css/bds.css" %}">
<link rel="stylesheet" href="{% static "shared/css/messages.css" %}">
{# Javascript #}
<script src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script>
<script src="{% static "vendor/jquery/jquery.autocomplete-light.min.js" %}"></script>
</head>
<body>
{% include "bds/nav.html" %}
{% include "bds/messages.html" %}
{% block content %}{% endblock %}
</body>
</html>

View file

@ -0,0 +1,22 @@
{% extends "bds/base.html" %}
{% block content %}
<div style="width: 60%; margin: auto; padding-top: 2em;">
Bienvenue sur GestioBDS&#8239;!
<br>
<br>
Le site est encore en développement.
<br>
Suivez notre avancement sur
<a href="https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/merge_requests?milestone_title=Int%C3%A9gration+du+BDS">
cette milestone</a> sur le gitlab de l'ENS.
<br>
Faites vos remarques par mail à
<a href="mailto:klub-dev@ens.fr"><tt>klub-dev@ens.fr</tt></a>
ou en ouvrant une
<a href="#https://git.eleves.ens.fr/klub-dev-ens/gestioCOF/issues?milestone_title=Int%C3%A9gration+du+BDS">
issue</a>.
</div>
{% endblock %}

View file

@ -0,0 +1,9 @@
{% if messages %}
{% for message in messages %}
<div class="messages">
<div class="alert alert-{{ message.level_tag }} alert-dismissible fade in{% if message.tags %} {{ message.tags }}{% endif %}">
{{ message }}
</div>
</div>
{% endfor %}
{% endif %}

View file

@ -0,0 +1,40 @@
{% load i18n %}
{% load static %}
<nav id="search-bar">
<a href="{% url "bds:home" %}">
<img src="{% static "bds/images/logo.svg" %}" alt="bds-logo">
</a>
<div>
<input
type="text"
name="q"
id="search_autocomplete"
spellcheck="false"
placeholder="{% trans "Chercher une personne" %}" />
<div class="yourlabs-autocomplete"></div>
</div>
<a href="#TODO">
<img src="{% static "bds/images/logout.svg" %}" alt="logout">
</a>
</nav>
<script type="text/javascript">
$(document).ready(function() {
$('input#search_autocomplete').yourlabsAutocomplete({
url: '{% url 'bds:autocomplete' %}',
minimumCharacters: 3,
id: 'search_autocomplete',
choiceSelector: 'li:has(a)',
box: $(".yourlabs-autocomplete"),
});
$('input#search_autocomplete').bind(
'selectChoice',
function(e, choice, autocomplete) {
window.location = choice.find('a:first').attr('href');
}
);
});
</script>

View file

@ -0,0 +1,73 @@
{% load i18n %}
{% load search_utils %}
<ul>
{% if members %}
<li class="autocomplete-header">
<span class="autocomplete-item">{% trans "Membres" %}</span>
</li>
{% for user in members %}
{% if forloop.counter < 5 %}
<li class="autocomplete-value">
<a class="autocomplete-item" href="{% url "bds:user.update" user.id %}">
{{ user|highlight_user:q }}
</a>
</li>
{% elif forloop.counter == 5 %}
<li class="autocomplete-more">
<span class="autocomplete-item">...</span>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% if others %}
<li class="autocomplete-header">
<span class="autocomplete-item">{% trans "Non-membres" %}</span>
</li>
{% for user in others %}
{% if forloop.counter < 5 %}
<li class="autocomplete-value">
<a class="autocomplete-item" href="{% url "bds:user.update" user.id %}">
{{ user|highlight_user:q }}
</a>
</li>
{% elif forloop.counter == 5 %}
<li class="autocomplete-more">
<span class="autocomplete-item">...</span>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% if clippers %}
<li class="autocomplete-header">{% trans "Utilisateurs <tt>clipper</tt>" %}</li>
{% for clipper in clippers %}
{% if forloop.counter < 5 %}
<li class="autocomplete-value">
<a class="autocomplete-item" href="#TODO">
{{ clipper|highlight_clipper:q }}
</a>
</li>
{% elif forloop.counter == 5 %}
<li class="autocomplete-more">
<span class="autocomplete-item">...</span>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% if total %}
<li class="autocomplete-header">
<span class="autocomplete-item">{% trans "Pas dans la liste ?" %}</span>
</li>
{% else %}
<li class="autocomplete-header">
<span class="autocomplete-item">{% trans "Aucune correspondance trouvée" %}</span>
</li>
{% endif %}
<li class="autocomplete-new">
<a class="autocomplete-item" href="#TODO">{% trans "Créer un compte" %}</a>
</li>
</ul>

View file

@ -0,0 +1,31 @@
{% extends "bds/base.html" %}
{% load i18n %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{% for field in user_form %}
<div class="form-field">
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
{% for field in profile_form %}
<div class="form-field">
{{ field.errors }}
{{ field.label_tag }} {{ field }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
<input type="submit" value="{% trans "Enregistrer" %}">
</form>
{% endblock %}

10
bds/urls.py Normal file
View file

@ -0,0 +1,10 @@
from django.urls import path
from bds import views
app_name = "bds"
urlpatterns = [
path("", views.Home.as_view(), name="home"),
path("autocomplete", views.AutocompleteView.as_view(), name="autocomplete"),
path("user/update/<pk>", views.UserUpdateView.as_view(), name="user.update"),
]

View file

@ -1 +1,72 @@
# Create your views here.
from django.contrib import messages
from django.contrib.auth import get_user_model
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from bds.autocomplete import bds_search
from bds.forms import BDSProfileForm, BDSUserForm
from bds.mixins import StaffRequiredMixin
User = get_user_model()
class AutocompleteView(StaffRequiredMixin, TemplateView):
template_name = "bds/search_results.html"
def get_context_data(self, *args, **kwargs):
ctx = super().get_context_data(*args, **kwargs)
if "q" not in self.request.GET:
raise Http404
q = self.request.GET["q"]
ctx["q"] = q
results = bds_search.search(q.split())
ctx.update(results)
ctx["total"] = sum((len(r) for r in results.values()))
return ctx
class Home(StaffRequiredMixin, TemplateView):
template_name = "bds/home.html"
class UserUpdateView(StaffRequiredMixin, TemplateView):
template_name = "bds/user_update.html"
def setup(self, *args, **kwargs):
super().setup(*args, **kwargs)
self.user = get_object_or_404(User, pk=self.kwargs["pk"])
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
form_data = self.request.POST if self.request.method == "POST" else None
profile = getattr(self.user, "bds", None)
ctx["user_form"] = BDSUserForm(prefix="user", intance=self.user, data=form_data)
ctx["profile_form"] = BDSProfileForm(
prefix="profile", instance=profile, data=form_data
)
return ctx
def post(self, *args, **kwargs):
ctx = self.get_context_data()
user_form = ctx["user_form"]
profile_form = ctx["profile_form"]
if user_form.is_valid() and profile_form.is_valid():
user_form.save()
profile_form.save()
messages.add_message(
self.request, messages.SUCCESS, _("Compte mis à jour avec succès !")
)
else:
messages.add_message(
self.request,
messages.ERROR,
_("Le formulaire de mise à jour du compte contient des erreurs."),
)
# Redirect here.
return HttpResponseRedirect("")

View file

@ -6,14 +6,15 @@ The settings that are not listed here are imported from .common
import os
from .common import * # NOQA
from .common import BASE_DIR, INSTALLED_APPS, TESTING, import_secret
from .common import BASE_DIR, INSTALLED_APPS
DEBUG = False
# ---
# BDS-only Django settings
# ---
ALLOWED_HOSTS = ["cof.ens.fr", "www.cof.ens.fr", "dev.cof.ens.fr"]
ALLOWED_HOSTS = ["bds.ens.fr", "www.bds.ens.fr", "dev.cof.ens.fr"]
if TESTING:
INSTALLED_APPS += ["events", "clubs"]
INSTALLED_APPS += ["bds", "events", "clubs"]
STATIC_ROOT = os.path.join(
os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static"
@ -24,5 +25,9 @@ MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")
MEDIA_URL = "/gestion/media/"
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
# ---
# Auth-related stuff
# ---
LOGIN_URL = "admin:login"
LOGIN_REDIRECT_URL = "bds:home"

162
cof/settings/cof_prod.py Normal file
View file

@ -0,0 +1,162 @@
"""
Django development settings for the cof project.
The settings that are not listed here are imported from .common
"""
import os
from .common import * # NOQA
from .common import (
AUTHENTICATION_BACKENDS,
BASE_DIR,
INSTALLED_APPS,
MIDDLEWARE,
TEMPLATES,
import_secret,
)
# ---
# COF-specific secrets
# ---
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
# ---
# COF-only Django settings
# ---
ALLOWED_HOSTS = ["cof.ens.fr", "www.cof.ens.fr", "dev.cof.ens.fr"]
INSTALLED_APPS = (
[
"gestioncof",
# Must be before django admin
# https://github.com/infoportugal/wagtail-modeltranslation/issues/193
"wagtail_modeltranslation",
"wagtail_modeltranslation.makemigrations",
"wagtail_modeltranslation.migrate",
"modeltranslation",
]
+ INSTALLED_APPS
+ [
"bda",
"petitscours",
"captcha",
"kfet",
"kfet.open",
"channels",
"custommail",
"djconfig",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail.core",
"wagtail.contrib.modeladmin",
"wagtail.contrib.routable_page",
"wagtailmenus",
"modelcluster",
"taggit",
"kfet.auth",
"kfet.cms",
"gestioncof.cms",
"django_js_reverse",
]
)
MIDDLEWARE = (
["corsheaders.middleware.CorsMiddleware"]
+ MIDDLEWARE
+ [
"djconfig.middleware.DjConfigMiddleware",
"wagtail.core.middleware.SiteMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
]
)
TEMPLATES[0]["OPTIONS"]["context_processors"] += [
"wagtailmenus.context_processors.wagtailmenus",
"djconfig.context_processors.config",
"gestioncof.shared.context_processor",
"kfet.auth.context_processors.temporary_auth",
"kfet.context_processors.config",
]
STATIC_ROOT = os.path.join(
os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static"
)
STATIC_URL = "/gestion/static/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")
MEDIA_URL = "/gestion/media/"
CORS_ORIGIN_WHITELIST = ("bda.ens.fr", "www.bda.ens.fr" "cof.ens.fr", "www.cof.ens.fr")
# ---
# Auth-related stuff
# ---
AUTHENTICATION_BACKENDS += [
"gestioncof.shared.COFCASBackend",
"kfet.auth.backends.GenericBackend",
]
LOGIN_URL = "cof-login"
LOGIN_REDIRECT_URL = "home"
# ---
# reCAPTCHA settings
# https://github.com/praekelt/django-recaptcha
#
# Default settings authorize reCAPTCHA usage for local developement.
# Public and private keys are appended in the 'prod' module settings.
# ---
NOCAPTCHA = True
RECAPTCHA_USE_SSL = True
# ---
# Wagtail settings
# ---
WAGTAIL_SITE_NAME = "GestioCOF"
WAGTAIL_ENABLE_UPDATE_CHECK = False
TAGGIT_CASE_INSENSITIVE = True
# ---
# Django-js-reverse settings
# ---
JS_REVERSE_JS_VAR_NAME = "django_urls"
# Quand on aura namespace les urls...
# JS_REVERSE_INCLUDE_ONLY_NAMESPACES = ['k-fet']
# ---
# Mail config
# ---
MAIL_DATA = {
"petits_cours": {
"FROM": "Le COF <cof@ens.fr>",
"BCC": "archivescof@gmail.com",
"REPLYTO": "cof@ens.fr",
},
"rappels": {"FROM": "Le BdA <bda@ens.fr>", "REPLYTO": "Le BdA <bda@ens.fr>"},
"revente": {
"FROM": "BdA-Revente <bda-revente@ens.fr>",
"REPLYTO": "BdA-Revente <bda-revente@ens.fr>",
},
}

View file

@ -8,6 +8,10 @@ the local development server should be here.
import os
import sys
# ---
# Secrets
# ---
try:
from . import secret
except ImportError:
@ -42,19 +46,19 @@ REDIS_DB = import_secret("REDIS_DB")
REDIS_HOST = import_secret("REDIS_HOST")
REDIS_PORT = import_secret("REDIS_PORT")
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL")
# ---
# Default Django settings
# ---
DEBUG = False # False by default feels safer
TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
TESTING = sys.argv[1] == "test"
# Application definition
INSTALLED_APPS = [
"shared",
"gestioncof",
# Must be before 'django.contrib.admin'.
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
"dal",
@ -64,51 +68,15 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"cof.apps.IgnoreSrcStaticFilesConfig",
# Must be before django admin
# https://github.com/infoportugal/wagtail-modeltranslation/issues/193
"wagtail_modeltranslation",
"wagtail_modeltranslation.makemigrations",
"wagtail_modeltranslation.migrate",
"modeltranslation",
"django.contrib.admin",
"django.contrib.admindocs",
"bda",
"petitscours",
"captcha",
"cof.apps.IgnoreSrcStaticFilesConfig",
"django_cas_ng",
"bootstrapform",
"kfet",
"kfet.open",
"channels",
"widget_tweaks",
"custommail",
"djconfig",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
"wagtail.snippets",
"wagtail.documents",
"wagtail.images",
"wagtail.search",
"wagtail.admin",
"wagtail.core",
"wagtail.contrib.modeladmin",
"wagtail.contrib.routable_page",
"wagtailmenus",
"modelcluster",
"taggit",
"kfet.auth",
"kfet.cms",
"gestioncof.cms",
"django_js_reverse",
]
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
@ -116,9 +84,6 @@ MIDDLEWARE = [
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.security.SecurityMiddleware",
"djconfig.middleware.DjConfigMiddleware",
"wagtail.core.middleware.SiteMiddleware",
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
"django.middleware.locale.LocaleMiddleware",
]
@ -127,7 +92,6 @@ ROOT_URLCONF = "cof.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
@ -138,11 +102,6 @@ TEMPLATES = [
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.static",
"wagtailmenus.context_processors.wagtailmenus",
"djconfig.context_processors.config",
"gestioncof.shared.context_processor",
"kfet.auth.context_processors.temporary_auth",
"kfet.context_processors.config",
]
},
}
@ -158,43 +117,28 @@ DATABASES = {
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = "fr-fr"
TIME_ZONE = "Europe/Paris"
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGES = (("fr", "Français"), ("en", "English"))
# Various additional settings
SITE_ID = 1
GRAPPELLI_ADMIN_HEADLINE = "GestioCOF"
GRAPPELLI_ADMIN_TITLE = '<a href="/">GestioCOF</a>'
MAIL_DATA = {
"petits_cours": {
"FROM": "Le COF <cof@ens.fr>",
"BCC": "archivescof@gmail.com",
"REPLYTO": "cof@ens.fr",
},
"rappels": {"FROM": "Le BdA <bda@ens.fr>", "REPLYTO": "Le BdA <bda@ens.fr>"},
"revente": {
"FROM": "BdA-Revente <bda-revente@ens.fr>",
"REPLYTO": "BdA-Revente <bda-revente@ens.fr>",
},
}
# ---
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
# ---
LOGIN_URL = "cof-login"
LOGIN_REDIRECT_URL = "home"
LANGUAGE_CODE = "fr-fr"
TIME_ZONE = "Europe/Paris"
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGES = (("fr", "Français"), ("en", "English"))
FORMAT_MODULE_PATH = "cof.locale"
# ---
# Auth-related stuff
# ---
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
CAS_VERSION = "2"
@ -203,37 +147,23 @@ CAS_IGNORE_REFERER = True
CAS_REDIRECT_URL = "/"
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"gestioncof.shared.COFCASBackend",
"kfet.auth.backends.GenericBackend",
)
# reCAPTCHA settings
# https://github.com/praekelt/django-recaptcha
#
# Default settings authorize reCAPTCHA usage for local developement.
# Public and private keys are appended in the 'prod' module settings.
NOCAPTCHA = True
RECAPTCHA_USE_SSL = True
CORS_ORIGIN_WHITELIST = ("bda.ens.fr", "www.bda.ens.fr" "cof.ens.fr", "www.cof.ens.fr")
# ---
# Cache settings
# ---
CACHES = {
"default": {
"BACKEND": "redis_cache.RedisCache",
"LOCATION": "redis://:{passwd}@{host}:{port}/db".format(
"LOCATION": "redis://:{passwd}@{host}:{port}/{db}".format(
passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB
),
}
}
# ---
# Channels settings
# ---
CHANNEL_LAYERS = {
"default": {
@ -253,16 +183,3 @@ CHANNEL_LAYERS = {
"ROUTING": "cof.routing.routing",
}
}
FORMAT_MODULE_PATH = "cof.locale"
# Wagtail settings
WAGTAIL_SITE_NAME = "GestioCOF"
WAGTAIL_ENABLE_UPDATE_CHECK = False
TAGGIT_CASE_INSENSITIVE = True
# Django-js-reverse settings
JS_REVERSE_JS_VAR_NAME = "django_urls"
# Quand on aura namespace les urls...
# JS_REVERSE_INCLUDE_ONLY_NAMESPACES = ['k-fet']

View file

@ -1,55 +0,0 @@
"""
Django development settings for the cof project.
The settings that are not listed here are imported from .common
"""
import os
from .common import * # NOQA
from .common import INSTALLED_APPS, MIDDLEWARE, TESTING
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
DEBUG = True
if TESTING:
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
# As long as these apps are not ready for production, they are only available
# in development mode
INSTALLED_APPS += ["events", "bds", "clubs"]
# ---
# Apache static/media config
# ---
STATIC_URL = "/static/"
STATIC_ROOT = "/srv/gestiocof/static/"
MEDIA_ROOT = "/srv/gestiocof/media/"
MEDIA_URL = "/media/"
# ---
# Debug tool bar
# ---
def show_toolbar(request):
"""
On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar
car cela interfère avec l'utilisation de Vagrant. En effet, l'adresse de la
machine physique n'est pas forcément connue, et peut difficilement être
mise dans les INTERNAL_IPS.
"""
env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None))
return DEBUG and not env_no_ddt and not request.path.startswith("/admin/")
if not TESTING:
INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}

View file

@ -1,14 +1,36 @@
"""
Django local settings for the cof project.
The settings that are not listed here are imported from .common
"""
"""Django local development settings."""
import os
from .dev import * # NOQA
from .dev import BASE_DIR
from . import bds_prod
from .cof_prod import * # NOQA
from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING
# ---
# Merge COF and BDS configs
# ---
for app in bds_prod.INSTALLED_APPS:
if app not in INSTALLED_APPS:
INSTALLED_APPS.append(app)
# ---
# Tweaks for debug/local development
# ---
ALLOWED_HOSTS = []
DEBUG = True
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
if TESTING:
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
STATIC_URL = "/static/"
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
# Use sqlite for local development
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
@ -27,5 +49,24 @@ CHANNEL_LAYERS = {
}
}
# No need to run collectstatic -> unset STATIC_ROOT
STATIC_ROOT = None
# ---
# Debug tool bar
# ---
def show_toolbar(request):
"""
On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar
car cela interfère avec l'utilisation de Vagrant. En effet, l'adresse de la
machine physique n'est pas forcément connue, et peut difficilement être
mise dans les INTERNAL_IPS.
"""
env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None))
return DEBUG and not env_no_ddt and not request.path.startswith("/admin/")
if not TESTING:
INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}

View file

@ -8,129 +8,141 @@ from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth import views as django_auth_views
from django.urls import include, path
from django.views.decorators.cache import cache_page
from django.views.generic.base import TemplateView
from django_cas_ng import views as django_cas_views
from django_js_reverse.views import urls_js
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 gestioncof import csv_views, views as gestioncof_views
from gestioncof.autocomplete import autocomplete
from gestioncof.urls import (
calendar_patterns,
clubs_patterns,
events_patterns,
export_patterns,
surveys_patterns,
)
admin.autodiscover()
urlpatterns = [
# Page d'accueil
path("", gestioncof_views.HomeView.as_view(), name="home"),
# Le BdA
path("bda/", include("bda.urls")),
# Les exports
path("export/", include(export_patterns)),
# Les petits cours
path("petitcours/", include("petitscours.urls")),
# Les sondages
path("survey/", include(surveys_patterns)),
# Evenements
path("event/", include(events_patterns)),
# Calendrier
path("calendar/", include(calendar_patterns)),
# Clubs
path("clubs/", include(clubs_patterns)),
# Authentification
path(
"cof/denied",
TemplateView.as_view(template_name="cof-denied.html"),
name="cof-denied",
),
path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"),
path("cas/logout", django_cas_views.LogoutView.as_view()),
path(
"outsider/login", gestioncof_views.LoginExtView.as_view(), name="ext_login_view"
),
path(
"outsider/logout", django_auth_views.LogoutView.as_view(), {"next_page": "home"}
),
path("login", gestioncof_views.login, name="cof-login"),
path("logout", gestioncof_views.logout, name="cof-logout"),
# Infos persos
path("profile", gestioncof_views.profile, name="profile"),
path(
"outsider/password-change",
django_auth_views.PasswordChangeView.as_view(),
name="password_change",
),
path(
"outsider/password-change-done",
django_auth_views.PasswordChangeDoneView.as_view(),
name="password_change_done",
),
# Inscription d'un nouveau membre
path("registration", gestioncof_views.registration, name="registration"),
path(
"registration/clipper/<slug:login_clipper>/<fullname>",
gestioncof_views.registration_form2,
name="clipper-registration",
),
path(
"registration/user/<username>",
gestioncof_views.registration_form2,
name="user-registration",
),
path(
"registration/empty",
gestioncof_views.registration_form2,
name="empty-registration",
),
# Autocompletion
path(
"autocomplete/registration", autocomplete, name="cof.registration.autocomplete"
),
path(
"user/autocomplete",
gestioncof_views.user_autocomplete,
name="cof-user-autocomplete",
),
# Interface admin
path("admin/logout/", gestioncof_views.logout),
path("admin/doc/", include("django.contrib.admindocs.urls")),
path(
"admin/<slug:app_label>/<slug:model_name>/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
path("admin/", admin.site.urls),
# Liens utiles du COF et du BdA
path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"),
path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"),
path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"),
path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"),
path(
"utile_bda/bda_revente",
gestioncof_views.liste_bdarevente,
name="ml_bda_revente",
),
path("k-fet/", include("kfet.urls")),
path("cms/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
# djconfig
path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
# js-reverse
path("jsreverse/", urls_js, name="js_reverse"),
]
if "gestioncof" in settings.INSTALLED_APPS:
from gestioncof import csv_views, views as gestioncof_views
from gestioncof.autocomplete import autocomplete
from gestioncof.urls import (
calendar_patterns,
clubs_patterns,
events_patterns,
export_patterns,
surveys_patterns,
)
from django_js_reverse.views import urls_js
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
# Also includes BdA, K-Fêt, etc.
urlpatterns += [
path("admin/logout/", gestioncof_views.logout),
path(
"admin/<slug:app_label>/<slug:model_name>/csv/",
csv_views.admin_list_export,
{"fields": ["username"]},
),
# Page d'accueil
path("", gestioncof_views.HomeView.as_view(), name="home"),
# Le BdA
path("bda/", include("bda.urls")),
# Les exports
path("export/", include(export_patterns)),
# Les petits cours
path("petitcours/", include("petitscours.urls")),
# Les sondages
path("survey/", include(surveys_patterns)),
# Evenements
path("event/", include(events_patterns)),
# Calendrier
path("calendar/", include(calendar_patterns)),
# Clubs
path("clubs/", include(clubs_patterns)),
# Authentification
path(
"cof/denied",
TemplateView.as_view(template_name="cof-denied.html"),
name="cof-denied",
),
path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"),
path("cas/logout", django_cas_views.LogoutView.as_view()),
path(
"outsider/login",
gestioncof_views.LoginExtView.as_view(),
name="ext_login_view",
),
path(
"outsider/logout",
django_auth_views.LogoutView.as_view(),
{"next_page": "home"},
),
path("login", gestioncof_views.login, name="cof-login"),
path("logout", gestioncof_views.logout, name="cof-logout"),
# Infos persos
path("profile", gestioncof_views.profile, name="profile"),
path(
"outsider/password-change",
django_auth_views.PasswordChangeView.as_view(),
name="password_change",
),
path(
"outsider/password-change-done",
django_auth_views.PasswordChangeDoneView.as_view(),
name="password_change_done",
),
# Inscription d'un nouveau membre
path("registration", gestioncof_views.registration, name="registration"),
path(
"registration/clipper/<slug:login_clipper>/<fullname>",
gestioncof_views.registration_form2,
name="clipper-registration",
),
path(
"registration/user/<username>",
gestioncof_views.registration_form2,
name="user-registration",
),
path(
"registration/empty",
gestioncof_views.registration_form2,
name="empty-registration",
),
# Autocompletion
path(
"autocomplete/registration",
autocomplete,
name="cof.registration.autocomplete",
),
path(
"user/autocomplete",
gestioncof_views.user_autocomplete,
name="cof-user-autocomplete",
),
# Liens utiles du COF et du BdA
path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"),
path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"),
path("utile_bda/bda_diff", gestioncof_views.liste_bdadiff, name="ml_diffbda"),
path("utile_cof/diff_cof", gestioncof_views.liste_diffcof, name="ml_diffcof"),
path(
"utile_bda/bda_revente",
gestioncof_views.liste_bdarevente,
name="ml_bda_revente",
),
path("k-fet/", include("kfet.urls")),
path("cms/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
# djconfig
path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
# js-reverse
path("jsreverse/", urls_js, name="js_reverse"),
]
if "bds" in settings.INSTALLED_APPS:
urlpatterns.append(path("bds/", include("bds.urls")))
if "events" in settings.INSTALLED_APPS:
# The new event application is still in development
# → for now it is namespaced below events_v2
# → when the old events system is out, move this above in the others apps
# → rename this when the old events system is out
urlpatterns += [path("event_v2/", include("events.urls"))]
if "debug_toolbar" in settings.INSTALLED_APPS:
@ -144,6 +156,9 @@ if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Wagtail for uncatched
urlpatterns += i18n_patterns(
path("", include(wagtail_urls)), prefix_default_language=False
)
if "wagtail.core" in settings.INSTALLED_APPS:
from wagtail.core import urls as wagtail_urls
urlpatterns += i18n_patterns(
path("", include(wagtail_urls)), prefix_default_language=False
)

6
cof/wsgi.py Normal file
View file

@ -0,0 +1,6 @@
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings.bds_prod")
application = get_wsgi_application()

View file

@ -1,5 +1,6 @@
from unittest import mock
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
from django.test import Client, TestCase
@ -59,9 +60,8 @@ class CSVExportAccessTest(MessagePatch, TestCase):
def test_anonymous(self):
client = Client()
r = client.get(self.url)
self.assertRedirects(
r, "/login?next={}".format(self.url), fetch_redirect_response=False
)
login_url = "{}?next={}".format(reverse(settings.LOGIN_URL), self.url)
self.assertRedirects(r, login_url, fetch_redirect_response=False)
def test_unauthorised(self):
client = Client()

View file

@ -1090,47 +1090,6 @@ tr.awesome{
}
/* Messages */
.messages .alert .close {
top:0;
right:0;
}
.messages .alert {
padding:10px 15px;
margin:0;
border:0;
border-radius:0;
}
div.messages div.alert-info {
background-color: #659C94;
}
div.messages div.alert-success {
background-color: #41C342;
}
div.messages div.alert-warning {
background-color: #efa50f;
}
div.messages div.alert-error {
background-color: #e14b4b;
}
div.messages div.alert-info div.container,
div.messages div.alert-error div.container,
div.messages div.alert-warning div.container,
div.messages div.alert-success div.container {
color: white;
}
div.messages div.alert div.container a {
color: inherit;
}
/* Help text */
p.help-block {

View file

@ -14,6 +14,7 @@
<link type="text/css" rel="stylesheet" href="{% static 'fonts/Dosis/dosis.css' %}" />
<link type="text/css" rel="stylesheet" href="{% static 'gestioncof/css/cof.css' %}" />
<link type="text/css" rel="stylesheet" href="{% static 'gestioncof/vendor/font-awesome/css/font-awesome.min.css' %}">
<link type="text/css" rel="stylesheet" href="{% static 'shared/css/messages.css' %}" />
{# JS #}
<script src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script>

View file

@ -1,4 +1,4 @@
{% load utils %}
{% load search_utils %}
<ul>
{% if members %}

View file

@ -1,7 +1,4 @@
import re
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@ -15,29 +12,3 @@ def key(d, key_name):
value = settings.TEMPLATE_STRING_IF_INVALID
return value
def highlight_text(text, q):
q2 = "|".join(re.escape(word) for word in q.split())
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
return mark_safe(
re.sub(pattern, r"<span class='highlight'>\g<filter></span>", text)
)
@register.filter
def highlight_user(user, q):
if user.first_name and user.last_name:
text = "%s %s (<tt>%s</tt>)" % (user.first_name, user.last_name, user.username)
else:
text = user.username
return highlight_text(text, q)
@register.filter
def highlight_clipper(clipper, q):
if clipper.fullname:
text = "%s (<tt>%s</tt>)" % (clipper.fullname, clipper.clipper)
else:
text = clipper.clipper
return highlight_text(text, q)

View file

@ -0,0 +1,38 @@
.messages .alert .close {
top:0;
right:0;
}
.messages .alert {
padding:10px 15px;
margin:0;
border:0;
border-radius:0;
}
div.messages div.alert-info {
background-color: #659C94;
}
div.messages div.alert-success {
background-color: #41C342;
}
div.messages div.alert-warning {
background-color: #efa50f;
}
div.messages div.alert-error {
background-color: #e14b4b;
}
div.messages div.alert-info div.container,
div.messages div.alert-error div.container,
div.messages div.alert-warning div.container,
div.messages div.alert-success div.container {
color: white;
}
div.messages div.alert div.container a {
color: inherit;
}

View file

@ -0,0 +1,32 @@
import re
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
def highlight_text(text, q):
q2 = "|".join(re.escape(word) for word in q.split())
pattern = re.compile(r"(?P<filter>%s)" % q2, re.IGNORECASE)
return mark_safe(
re.sub(pattern, r"<span class='highlight'>\g<filter></span>", text)
)
@register.filter
def highlight_user(user, q):
if user.first_name and user.last_name:
text = "%s %s (<tt>%s</tt>)" % (user.first_name, user.last_name, user.username)
else:
text = user.username
return highlight_text(text, q)
@register.filter
def highlight_clipper(clipper, q):
if clipper.fullname:
text = "%s (<tt>%s</tt>)" % (clipper.fullname, clipper.clipper)
else:
text = clipper.clipper
return highlight_text(text, q)