New admin theme

This commit is contained in:
Alexandre Iooss 2019-08-02 15:33:38 +02:00
parent c5f98991aa
commit 1100681952
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
33 changed files with 534 additions and 65 deletions

View File

@ -6,6 +6,7 @@ source =
search
static
templates
theme
users
omit =
media/tests/*.py

View File

@ -29,6 +29,9 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
# Theme overrides Django Admin templates
'theme',
# External apps
'bootstrap3',
'reversion',
@ -177,7 +180,6 @@ LOGIN_REDIRECT_URL = '/'
SITE_NAME = "Med"
# Association information
LOGO_PATH = "static_files/logo.png"
ASSO_NAME = "Med"
ASSO_ADDRESS_LINE1 = "61 Avenue du président Wilson"
ASSO_ADDRESS_LINE2 = "94230 Cachan"
@ -185,9 +187,6 @@ ASSO_SIRET = ""
ASSO_EMAIL = "med@lists.crans.org"
ASSO_PHONE = "01 02 03 04 05"
services_urls = {
}
# Number of hours a token remains valid after having been created. Numeric and string
# versions should have the same meaning.
REQ_EXPIRE_HRS = 48

View File

@ -1,26 +1,6 @@
{% extends "med/sidebar.html" %}
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
quelques clics.
Copyright © 2017 Gabriel Détraz
Copyright © 2017 Goulven Kermarec
Copyright © 2017 Augustin Lemesle
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load bootstrap3 %}
@ -30,15 +10,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
<h1>Bienvenue sur {{ site_name }}, notre base de données.</h1>
<h1>Welcome to procrastination heaven !</h1>
<h1>Welcome to procrastination heaven ! </h1>
<center>
<div class="thumbnail">
<img src="/static/logo/logo.png" alt="logo">
</div>
</center>
<p class="lead">
Le site va subir progressivement des mises à jour pendant ces vacances.
Si vous rencontrez des instabilités,
veuillez nous faire remonter les problèmes <a href="mailto:a@crans.org,club-med@crans.org">au webmaster</a>.
</p>
<div class="text-center">
<img src="{% static "images/splash.png" %}" class="img-responsive" alt="Poulpy">
</div>
{% endblock %}

View File

@ -4,17 +4,32 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.shortcuts import render
from django.views.generic import RedirectView
def index(request):
"""
Static home page
"""
return render(request, 'med/index.html', {})
from .views import index
urlpatterns = [
url(r'^$', index),
url('^logout/', auth_views.logout, {'next_page': '/'}),
url('^', include('django.contrib.auth.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^$', index, name='index'),
# Include project routers
url(r'^users/', include('users.urls', namespace='users')),
url(r'^media/', include('media.urls', namespace='media')),
url(r'^search/', include('search.urls', namespace='search')),
url(r'^logs/', include('logs.urls', namespace='logs')),
# Include Django Contrib and Core routers
# admin/login/ is redirected to the non-admin login page
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^accounts/profile/',
RedirectView.as_view(pattern_name='index')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', admin.site.urls),
]

View File

@ -1,26 +0,0 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.shortcuts import render
from django.template.context_processors import csrf
from med.settings import services_urls
def form(ctx, template, request):
c = ctx
c.update(csrf(request))
return render(request, template, c)
def index(request):
i = 0
services = [{}]
for key, s in services_urls.items():
if len(services) <= i:
services += [{}]
services[i][key] = s
i = i + 1 if i < 2 else 0
return form({'services_urls': services}, 'med/index.html', request)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

0
theme/__init__.py Normal file
View File

View File

@ -0,0 +1,87 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-02 15:17+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: templates/admin/base_site.html:22
msgid "Welcome,"
msgstr ""
#: templates/admin/base_site.html:27 templates/registration/logged_out.html:9
#: templates/registration/password_change_done.html:9
#: templates/registration/password_change_form.html:9
#: templates/registration/password_reset_complete.html:9
#: templates/registration/password_reset_confirm.html:9
#: templates/registration/password_reset_done.html:9
#: templates/registration/password_reset_form.html:9
msgid "Home"
msgstr ""
#: templates/admin/base_site.html:32 templates/admin/base_site.html:51
msgid "View admin"
msgstr "Administration"
#: templates/admin/base_site.html:44
msgid "Documentation"
msgstr ""
#: templates/admin/base_site.html:53
msgid "Log out"
msgstr ""
#: templates/registration/logged_out.html:14
msgid "Thanks for spending some quality time with the Web site today."
msgstr ""
#: templates/registration/logged_out.html:15
msgid "Log in again"
msgstr ""
#: templates/registration/login.html:8
msgid "Log in"
msgstr ""
#: templates/registration/password_change_done.html:9
#: templates/registration/password_change_form.html:9
msgid "Password change"
msgstr ""
#: templates/registration/password_reset_complete.html:9
#: templates/registration/password_reset_done.html:9
#: templates/registration/password_reset_form.html:9
msgid "Password reset"
msgstr ""
#: templates/registration/password_reset_confirm.html:9
msgid "Password reset confirmation"
msgstr ""
#: templates/registration/password_reset_email.html:2
#, python-format
msgid ""
"You're receiving this email because you requested a password reset for your "
"user account at %(site_name)s."
msgstr ""
#: templates/registration/password_reset_email.html:4
msgid "Please go to the following page and choose a new password:"
msgstr ""
#: templates/registration/password_reset_email.html:9
msgid "Thanks for using our site!"
msgstr ""
#: templates/registration/password_reset_email.html:11
#, python-format
msgid "The %(site_name)s team"
msgstr ""

140
theme/static/css/admin.css Normal file
View File

@ -0,0 +1,140 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Copyright © 2019 Alexandre Iooss
*
* This is the custom style for Django Contrib Admin
*/
/* Colors */
#header {
background-color: #151515;
border-bottom: solid 5px #d8660f;
}
.module h2, .module caption, .inline-group h2 {
background: #e6e0d8;
color: #222;
}
a.section:link, a.section:visited {
color: #222;
}
#user-tools a {
border-bottom: none;
font-weight: bold;
}
div.breadcrumbs {
background: #3c3c3c;
}
.button, input[type=submit], input[type=button], .submit-row input, a.button {
background: #d8a456;
}
.button:active, input[type=submit]:active, input[type=button]:active, .button:focus, input[type=submit]:focus,
input[type=button]:focus, .button:hover, input[type=submit]:hover, input[type=button]:hover {
background: #b98d4a;
}
.button.default, input[type=submit].default, .submit-row input.default {
background: #b98d4a;
}
.button.default:active, input[type=submit].default:active, .button.default:focus, input[type=submit].default:focus,
.button.default:hover, input[type=submit].default:hover {
background: #a7752b;
}
/* User tools top menu */
#user-tools .dropdown:hover > a, #user-tools .dropdown:focus > a {
color: #79aec8;
}
#user-tools .dropdown {
position: relative; /* needed to position the dropdown content */
display: inline-block;
}
#user-tools .dropdown-content {
display: block;
position: absolute;
background-color: #444444;
min-width: 180px;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
z-index: 2000;
text-align: left;
/* Hide menu by making it transparent */
transition: opacity 100ms, visibility 100ms;
opacity: 0;
visibility: hidden;
}
#user-tools .dropdown-content a {
color: #fff;
padding: 7px 8px;
text-decoration: none;
display: block;
line-height: 16px;
}
#user-tools .dropdown-content a:hover {
background-color: #636363;
}
#user-tools .dropdown:hover .dropdown-content {
opacity: 1;
visibility: visible;
}
/* Fix navigation hidden */
#header {
overflow: visible;
}
.login #header {
overflow: hidden;
}
/* Footer */
#footer {
padding: 20px 40px;
color: #999;
}
.login #footer {
padding: 10px;
font-size: 10pt;
}
#footer a {
color: #777;
}
#footer select {
height: 24px;
padding: 0;
}
/* Pull footer to bottom */
#content {
min-height: calc(100vh - 190px);
}
.login #content {
min-height: 0;
}
/* Recenter login button */
.login .submit-row {
padding: 1em 0 0 0 !important;
text-align: center !important;
}
/* Dashboard should take all page */
.dashboard #content {
width: auto;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="static/images/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

View File

@ -0,0 +1,96 @@
{% extends "admin/base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n staticfiles %}
{% block title %}{{ title }} | {{ request.site.name }}{% endblock %}
{% block branding %}
<strong id="site-name">
<a href="/">
<img src="{% static "images/logo.png" %}" height="40px" alt="{{ request.site.name }}" />
</a>
</strong>
{% endblock %}
{% block usertools %}
{% if user.is_authenticated %}
<div id="user-tools">
{% block welcome-msg %}
{% trans 'Welcome,' %}
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
{% endblock %}
{% block userlinks %}
{# Link to our apps outside of admin #}
<a href="{% url 'index' %}">{% trans 'Home' %}</a> /
{% if available_apps %}
{# When in admin site, list all admin pages and documentation #}
<span class="dropdown">
<a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a>
<span class="dropdown-content">
{% for app in available_apps %}
{% for model in app.models %}
{% if model.admin_url %}
<a href="{{ model.admin_url }}">{{ model.name }}</a>
{% endif %}
{% endfor %}
{% endfor %}
{% if user.is_active and user.is_superuser %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a>
{% endif %}
{% endif %}
</span>
</span> /
{% elif user.is_staff %}
{# When not in admin site, but user is staff then add a link #}
<a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a> /
{% endif %}
<a href="{% url 'logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{% static "css/admin.css" %}"/>
{# Favicon #}
<link rel="apple-touch-icon" sizes="180x180" href="{% static "favicon/apple-touch-icon.png" %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static "favicon/favicon-32x32.png" %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static "favicon/favicon-16x16.png" %}">
<link rel="manifest" href="{% static "favicon/site.webmanifest" %}">
<link rel="mask-icon" href="{% static "favicon/safari-pinned-tab.svg" %}" color="#5bbad5">
<link rel="shortcut icon" href="{% static "favicon/favicon.ico" %}">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="{% static "favicon/browserconfig.xml" %}">
<meta name="theme-color" content="#ffffff">
{% endblock %}
{% block footer %}
{% if not is_popup %}
<div id="footer">
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<select title="language" name="language" onchange="this.form.submit()">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<noscript>
<input type="submit">
</noscript>
Mediatek 2017-2020 &mdash; <a href="mailto:club-med@crans.org">Nous contactez</a>
</form>
</div>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,16 @@
{% extends "registration/logged_out.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a>
</div>
{% endblock %}
{% block content %}
<p>{% trans "Thanks for spending some quality time with the Web site today." %}</p>
<p><a href="{% url 'index' %}">{% trans 'Log in again' %}</a></p>
{% endblock %}

View File

@ -0,0 +1,8 @@
{% extends "admin/login.html" %}
{% comment %}
SPDX-License-Identifier: GPL-2.0-or-later
{% endcomment %}
{% load i18n %}
{% block title %}{% trans "Log in" %}{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_change_done.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_change_form.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password change' %}
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_reset_complete.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_reset_confirm.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset confirmation' %}
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_reset_done.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
{% trans "Thanks for using our site!" %}
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
{% endautoescape %}

View File

@ -0,0 +1,11 @@
{% extends "registration/password_reset_form.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'index' %}">{% trans 'Home' %}</a> &rsaquo; {% trans 'Password reset' %}
</div>
{% endblock %}

0
theme/tests/__init__.py Normal file
View File

View File

@ -0,0 +1,44 @@
# -*- mode: python; coding: utf-8 -*-
# SPDX-License-Identifier: GPL-3.0-or-later
from django.contrib.auth.models import User
from django.test import TestCase
"""
Test that every themed page still works
"""
class TemplateLoggedOutTests(TestCase):
def test_login_page(self):
response = self.client.get('/admin/login/')
self.assertEqual(response.status_code, 200)
class TemplateLoggedInTests(TestCase):
def setUp(self):
self.user = User.objects.create_superuser(
username="admin",
password="adminadmin",
email="admin@example.com",
)
self.client.force_login(self.user)
def test_login_page(self):
"""
Login page should redirect
"""
response = self.client.get('/admin/login/')
self.assertEqual(response.status_code, 302)
def test_admin_index(self):
response = self.client.get('/admin/')
self.assertEqual(response.status_code, 200)
def test_accounts_password_reset(self):
response = self.client.get('/accounts/password_reset/')
self.assertEqual(response.status_code, 200)
def test_logout_page(self):
response = self.client.get('/accounts/logout/')
self.assertEqual(response.status_code, 200)