Verified Commit cf2e498e authored by erdnaxe's avatar erdnaxe 🎇

Use Django sites framework

parent fcc6b63b
Pipeline #1167 passed with stage
in 2 minutes and 57 seconds
......@@ -12,3 +12,7 @@ from django.contrib.auth.models import Permission
permissions = Permission.objects.filter(codename__startswith='view')
permissions.delete()
```
## MR 2
With the addition of Django Sites, you will need to change the site name in the management interface (sites menu).
\ No newline at end of file
......@@ -35,6 +35,7 @@ What have been done so far in Aube that is not in Re2o :
* New login form ;
* Drop custom password reset mechanics in favor of Django Contrib Auth ;
* Filter interfaces with port opening profile rather than listing all machine per profile ;
* Use Django Contrib Sites to manage different domains ;
* More coming soon…
## How to migrate from Re2o to Aube
......
......@@ -37,9 +37,6 @@ def context_user(request):
return {
'request_user': user,
'interfaces': interfaces,
# Must takes a different name because djang.auth.contrib.views.login()
# overrides 'site_name' context variable.
'name_website': GeneralOption.get_cached_value('site_name'),
'ipv6_enabled': OptionalMachine.get_cached_value('ipv6'),
}
......
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-24 09:44+0200\n"
"POT-Creation-Date: 2019-04-24 11:16+0200\n"
"PO-Revision-Date: 2018-03-31 16:09+0002\n"
"Last-Translator: Laouen Fernet <laouen.fernet@supelec.fr>\n"
"Language-Team: \n"
......@@ -60,11 +60,11 @@ msgstr "Vous n'avez pas le droit de voir tous les objets %s."
msgid "You don't have the right to view a %s object."
msgstr "Vous n'avez pas le droit de voir un objet %s."
#: re2o/settings.py:144
#: re2o/settings.py:146
msgid "English"
msgstr "Anglais"
#: re2o/settings.py:145
#: re2o/settings.py:147
msgid "French"
msgstr "Français"
......@@ -180,8 +180,8 @@ msgstr "Accueil"
#: re2o/templates/re2o/index.html:33
#, python-format
msgid "Welcome to %(name_website)s"
msgstr "Bienvenue sur %(name_website)s"
msgid "Welcome to %(request.site.name)s"
msgstr "Bienvenue sur %(request.site.name)s"
#: re2o/templates/re2o/index.html:42
msgid "Registration"
......
......@@ -48,6 +48,7 @@ DJANGO_CONTRIB_APPS = (
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
)
EXTERNAL_CONTRIB_APPS = (
'bootstrap3',
......@@ -82,6 +83,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.admindocs.middleware.XViewMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'reversion.middleware.RevisionMiddleware',
)
......@@ -174,6 +176,9 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
# The URL to access the static files
MEDIA_URL = os.path.join(BASE_DIR,'/media/')
# Django main site
SITE_ID = 1
# Models to use for graphs
GRAPH_MODELS = {
'all_applications': True,
......
......@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block content %}
<div class="panel-heading">
<h2>{% blocktrans %}Welcome to {{ name_website }}{% endblocktrans %}</h2>
<h2>{% blocktrans %}Welcome to {{ request.site.name }}{% endblocktrans %}</h2>
</div>
{% if not request.user.is_authenticated %}
<div class="row">
......
......@@ -7,7 +7,7 @@ Copyright © 2019 Alexandre Iooss
{% load i18n staticfiles %}
{% block title %}{{ title }} | {{ name_website }}{% endblock %}
{% block title %}{{ title }} | {{ request.site.name }}{% endblock %}
{% block branding %}
<h1 id="site-name">
......@@ -15,7 +15,7 @@ Copyright © 2019 Alexandre Iooss
<img class="banding-logo" src="{% static 'images/logo_navbar.svg' %}" alt=""/>
</a>
<a href="{% url 'index' %}">
{{ name_website }}
{{ request.site.name }}
</a>
</h1>
{% endblock %}
......@@ -62,7 +62,7 @@ Copyright © 2019 Alexandre Iooss
{% block footer %}
<div id="footer">
<p>
{{ name_website }} {% trans "powered by" %}
{{ request.site.name }} {% trans "powered by" %}
<a href="{% url 'about' %}">Aube 2016&ndash;2019</a>.
</p>
<p>
......
......@@ -8,7 +8,7 @@ Copyright © 2019 Alexandre Iooss
{% load i18n static %}
{% block content_title %}
<h1>{% blocktrans %}Welcome to {{ name_website }}{% endblocktrans %}</h1>
<h1>{% blocktrans %}Welcome to {{ request.site.name }}{% endblocktrans %}</h1>
{% endblock %}
{% block content %}
......
......@@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<html lang="fr">
<head prefix="og: http://ogp.me/ns#">
{# Open Graph for social media #}
<meta property="og:title" content="{{ name_website }}" />
<meta property="og:title" content="{{ request.site.name }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ request.scheme }}://{{ request.get_host }}/" />
<meta property="og:image" content="{% static 'images/logo.svg' %}"/>
......@@ -67,7 +67,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{# Do not allow zooming on devices #}
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ name_website }} : {% block title %}{% trans "Home" %}{% endblock %}</title>
<title>{{ request.site.name }} : {% block title %}{% trans "Home" %}{% endblock %}</title>
</head>
<body id="main">
......@@ -81,7 +81,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</button>
<a class="navbar-brand" href="/">
<img src="{% static 'images/logo_navbar.svg' %}" height="32">
{{ name_website }}
{{ request.site.name }}
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
......@@ -266,7 +266,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<footer id="footer" class="text-muted container">
<p>
{{ name_website }} {% trans "powered by" %}
{{ request.site.name }} {% trans "powered by" %}
<a href="{% url 'about' %}">Aube 2016&ndash;2019</a>.
</p>
<p>
......
......@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-24 09:44+0200\n"
"POT-Creation-Date: 2019-04-24 11:16+0200\n"
"PO-Revision-Date: 2018-03-31 16:09+0002\n"
"Last-Translator: Laouen Fernet <laouen.fernet@supelec.fr>\n"
"Language-Team: \n"
......@@ -57,11 +57,11 @@ msgid ""
"\">this form</a>."
msgstr ""
#: templates/admin/base_site.html:65 templates/base.html:269
#: templates/admin/base_site.html:65 templates/base.html:272
msgid "powered by"
msgstr "propulsé par"
#: templates/admin/base_site.html:69 templates/base.html:273
#: templates/admin/base_site.html:69 templates/base.html:276
msgid ""
"This software is under the terms of the <a href=\"http://www.gnu.org/"
"licenses/gpl-2.0.txt\" target=\"_blank\" rel=\"nofollow\">GPLv2</a> License."
......@@ -71,8 +71,8 @@ msgstr ""
#: templates/admin/custom_index.html:11
#, python-format
msgid "Welcome to %(name_website)s"
msgstr "Bienvenue sur %(name_website)s"
msgid "Welcome to %(request.site.name)s"
msgstr "Bienvenue sur %(request.site.name)s"
#: templates/admin/custom_index.html:17
msgid ""
......@@ -113,7 +113,7 @@ msgstr ""
msgid "Networking managing website endorsed by FedeRez."
msgstr "Site de gestion de réseau soutenu par FedeRez."
#: templates/base.html:70 templates/registration/logged_out.html:11
#: templates/base.html:73 templates/registration/logged_out.html:11
#: templates/registration/password_change_done.html:11
#: templates/registration/password_change_form.html:11
#: templates/registration/password_reset_complete.html:11
......@@ -123,129 +123,129 @@ msgstr "Site de gestion de réseau soutenu par FedeRez."
msgid "Home"
msgstr "Accueil"
#: templates/base.html:91
#: templates/base.html:94
msgid "Users"
msgstr "Utilisateurs"
#: templates/base.html:94
#: templates/base.html:97
msgid "Manage the users"
msgstr "Gérer les utilisateurs"
#: templates/base.html:95
#: templates/base.html:98
msgid "Manage the clubs"
msgstr "Gérer les clubs"
#: templates/base.html:98
#: templates/base.html:101
msgid "Manage the machines"
msgstr "Gérer les machines"
#: templates/base.html:101
#: templates/base.html:104
msgid "Manage the subscriptions"
msgstr "Gérer les cotisations"
#: templates/base.html:108
#: templates/base.html:111
msgid "Topology"
msgstr "Topologie"
#: templates/base.html:110
#: templates/base.html:113
msgid "Switches"
msgstr "Commutateurs réseau"
#: templates/base.html:115
#: templates/base.html:118
msgid "Statistics"
msgstr "Statistiques"
#: templates/base.html:120
#: templates/base.html:123
msgid "Administration"
msgstr "Administration"
#: templates/base.html:127
#: templates/base.html:130
msgid "Manage"
msgstr "Câblage"
#: templates/base.html:134
#: templates/base.html:137
msgid "More information"
msgstr "Plus d'informations"
#: templates/base.html:136
#: templates/base.html:139
msgid "About"
msgstr "À propos"
#: templates/base.html:137
#: templates/base.html:140
msgid "Contact"
msgstr "Contact"
#: templates/base.html:144
#: templates/base.html:147
msgid "Sign up"
msgstr "S'inscrire"
#: templates/base.html:150 templates/registration/login.html:11
#: templates/base.html:153 templates/registration/login.html:11
#: templates/registration/login.html:57
msgid "Log in"
msgstr "Se connecter"
#: templates/base.html:158
#: templates/base.html:161
msgid "Search"
msgstr "Rechercher"
#: templates/base.html:172
#: templates/base.html:175
msgid "My profile"
msgstr "Mon profil"
#: templates/base.html:173
#: templates/base.html:176
msgid "Log out"
msgstr "Se déconnecter"
#: templates/base.html:205
#: templates/base.html:208
msgid "Username"
msgstr "Pseudo"
#: templates/base.html:209
#: templates/base.html:212
msgid "Room"
msgstr "Chambre"
#: templates/base.html:213
#: templates/base.html:216
msgid "Internet access"
msgstr "Accès Internet"
#: templates/base.html:216
#: templates/base.html:219
#, python-format
msgid "Until %(end_access_date)s"
msgstr "Jusqu'au %(end_access_date)s"
#: templates/base.html:218
#: templates/base.html:221
msgid "Disabled"
msgstr "Désactivé"
#: templates/base.html:223
#: templates/base.html:226
msgid "Membership"
msgstr "Adhésion"
#: templates/base.html:226
#: templates/base.html:229
#, python-format
msgid "Until %(end_adhesion_date)s"
msgstr "Jusqu'au %(end_adhesion_date)s"
#: templates/base.html:228
#: templates/base.html:231
msgid "Non member"
msgstr "Non adhérent"
#: templates/base.html:236
#: templates/base.html:239
msgid "View my profile"
msgstr "Voir mon profil"
#: templates/base.html:241
#: templates/base.html:244
msgid "You are not logged in."
msgstr "Vous n'êtes pas connecté."
#: templates/base.html:248
#: templates/base.html:251
#, python-format
msgid "%(nb)s active machine"
msgid_plural "%(nb)s active machines"
msgstr[0] "%(nb)s machine active"
msgstr[1] "%(nb)s machines actives"
#: templates/base.html:257
#: templates/base.html:260
msgid "View my machines"
msgstr "Voir mes machines"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment