Commit 41d8c70e authored by erdnaxe's avatar erdnaxe 🎇

Merge branch 'django_site' into 'dev'

Use Django sites framework

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