From 7d54c10c29c6e2126a4b5aaab6f184ce5b6bc526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Tue, 10 Apr 2018 22:07:26 +0000 Subject: [PATCH 1/4] Add many information on about page --- contributors.py | 3 - re2o/contributors.py | 3 + re2o/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 3605 bytes re2o/locale/fr/LC_MESSAGES/django.po | 156 ++++++++++++++++++++++ re2o/management/commands/gen_contrib.py | 8 +- re2o/settings.py | 6 + re2o/templates/re2o/about.html | 88 ++++++++---- re2o/views.py | 62 ++++++++- templates/base.html | 93 +++++++++---- templates/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 401 bytes templates/locale/fr/LC_MESSAGES/django.po | 35 +++++ 11 files changed, 384 insertions(+), 70 deletions(-) delete mode 100644 contributors.py create mode 100644 re2o/contributors.py create mode 100644 re2o/locale/fr/LC_MESSAGES/django.mo create mode 100644 re2o/locale/fr/LC_MESSAGES/django.po create mode 100644 templates/locale/fr/LC_MESSAGES/django.mo create mode 100644 templates/locale/fr/LC_MESSAGES/django.po diff --git a/contributors.py b/contributors.py deleted file mode 100644 index 02a2015c..00000000 --- a/contributors.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python3 - -contributeurs = ['Gabriel Detraz', 'chirac', 'Maël Kervella', 'LEVY-FALK Hugo', 'Dalahro', 'lhark', 'root', 'Hugo LEVY-FALK', 'Chirac', 'guimoz', 'Mael Kervella', 'klafyvel', 'matthieu', 'Yoann Pietri', 'Simon Brélivet', 'chibrac', 'David Sinquin', 'Pierre Cadart', 'moamoak', 'Éloi Alain', 'FERNET Laouen', 'Hugo Levy-Falk', 'Joanne Steiner', 'Matthieu Michelet', 'Yoann PIETRI', 'B', 'Daniel STAN', 'Eloi Alain', 'Guimoz', 'Hugo Hervieux', 'Laouen Fernet', 'Lemesle', 'MICHELET matthieu', 'Nymous', 'Thibault de BOUTRAY', 'Tipunchetrhum', 'Éloi ALAIN'] \ No newline at end of file diff --git a/re2o/contributors.py b/re2o/contributors.py new file mode 100644 index 00000000..00e97e41 --- /dev/null +++ b/re2o/contributors.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +CONTRIBUTORS = ['Gabriel "Chirac" Détraz', 'Maël "MoaMoaK" Kervella', 'Hugo "Klafyvel" Levy--Falk', 'Augustin "Dahlaro" Lemesle', 'Goulven "Lhark" Kermarec', 'Guillaume "Guimoz" Goessel', 'Yoann "Nanoy" Pietri', 'Matthieu "Lebanni" Michelet', 'Arthur "Grizzly" Grisel-Davy', 'Simon "Rezatoune" Brélivet', 'Sellem Lev-Arcady', 'David "5-1" Sinquin', 'Pierre "Redstorm" Cadart', 'Éloi "Goslig" Alain', 'Laouen "Volgarr" Fernet', 'Joanne Steiner', '"Krokmou"', 'Thibault "Tipunchetrhum" de Boutray', 'Baptiste "B" Fournier', 'Daniel "Dstan" Stan', 'Hugo "Shaka" Hervieux', '"Mikachu"', 'Thomas "Nymous" Gaudin', '"Esum"'] diff --git a/re2o/locale/fr/LC_MESSAGES/django.mo b/re2o/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..eb533f3e22010443cc48455dd1c5342fd6f88cd5 GIT binary patch literal 3605 zcmbtWOK%)S5N;s63`h_m-~ggzDY7lH>qkfki(}!~aWL44<=8o5_0H7pcHA>PO!ur~ zU*W)s6Wlog2L1rzxHly3aN!r^Cvf1a+4bzkc0!_zG+R48HD5iuzW(RzneP;?S8%_L z`zze9;l77ku9>Hl`UG+oauf1k@cbv_8lK;HTB$#tQ7VEwi|6`tN{vA-LJH0ron@jPd67DbZ)Y3!j4H>Zl_r;Px%v{JrHQgC5Z_X>%b?_qVnC2 zynB4e2cSI;&?YA?Fl}$HodCf(LE<%O;50^D!BLap*dW}PGpy@0P%C!{oZcrG-*fpcK569|=_#U6dw*R^^LXe+!SHCTykjzaUzFkdqCDlQaL^NkGjn{)N7Df>T61VkLOIf zWWrOT%d|<&bk39^-!XNaEs#uEl=o#=$lOZK*n5bzZBo26X}faKM;-K*r^#j!D0Km0 zV0V?Zn4-OoqmJ$}yy-HUk}MR^A*ia!DVT(%WQpD#Rv<`n;mjS50%gv7gACT`mZQwF zM#fN>U4zcpGod3u$?^DBTeR;A+LO8iz0K&66oGZ&6pASw6?2!Z%Muh%Y(?z-dD>%O zS}O+HR!cKgLGH1|WZ)7PEfTvj(hhqQu%EG z@D#mEjhPQcZ*FW28??5C`R=VoI1O6Yy(_?y%+_bdB(3O#+SYysp99|w)0sv0e?(D7=a>RlwzpPl zmxp@dQj7E2wKQ@uHba9hH%%COAmj9@t7IE`Lh_QlQd~%bVVem_+>iLg1a=zSLrG_p ztwGbEE{f5b*nOu2{HP?x9$P6TYzAW~o;b#4C6Vj}Oxix4Nl_MSVIH%1{3vdMM>=C6wk4#apK{5+Fk9~@ zR7|F18wZI3!-Yd-L3B{*%%w7-$vcd?BMy5w(|NdNha>+)>HeSP`Wlkak%Po>B3MK1 zj##e1#DuntQFw}g@X#{CbIsmi+B*b4KpP|_tdW7?B9m#`k3B}wqVjz_f!z*$!-9ts zMB4jN8$Z%KlQ0PW(jK)e`rl8X#SE1;T?$hm7+pjTM+^91frOEhWcWxb*3vjlNPRp; zEK74%`Ho7GzJnThhe`~&aoMF2`3dZluGBzgm+0*C0mu(U1UrL+4~UDq$5V96^uNJ} z78)6NK9<9P&I9R!(03(KW@RGIgY|&#ImbZ_>;_&b?jnfF!_vHtqJqJrXuDV(OD8&L zO&kdTkF@l@@1qO|6XzlXghiwtUz7&4k>e89pd&{#$;e2%l;n9-%u((XDo0l2)%^@Q z@}lI?HOwbD1bDH~XH+SuT0YulI1s4CBEke3Ayf2RMX0?)wVE7N0F%Ns!65M8qCtkN Px;p${de!Z-tXKa5zlSHu literal 0 HcmV?d00001 diff --git a/re2o/locale/fr/LC_MESSAGES/django.po b/re2o/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 00000000..2cabc6ec --- /dev/null +++ b/re2o/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,156 @@ +# 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 © 2018 Maël Kervella +# +# 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. +msgid "" +msgstr "" +"Project-Id-Version: 2.5\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-31 14:05+0000\n" +"PO-Revision-Date: 2018-03-31 16:09+0002\n" +"Last-Translator: Maël Kervella \n" +"Language-Team: \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: templates/re2o/about.html:29 templates/re2o/about.html:35 +msgid "About Re2o" +msgstr "A propos de Re2o" + +#: templates/re2o/about.html:32 +#, python-format +msgid "About %(AssoName)s" +msgstr "A propos de %(AssoName)s" + +#: templates/re2o/about.html:36 +msgid "" +"\n" +" Re2o is an administration tool initiated by\n" +" Rezo Supelec Metz and a few\n" +" members of other FedeRez " +"associations\n" +" around the summer 2016.
\n" +" It is intended to be a tool independant from any network " +"infrastructure\n" +" so it can be setup in \"a few steps\". This tool is entirely free " +"and\n" +" available under a GNU Public License v2 (GPLv2) license on\n" +" FedeRez gitlab.
\n" +" Re2o's mainteners are proud volunteers mainly from French " +"engineering\n" +" schools (but not limited to) who have given a lot of their time to " +"make\n" +" this project possible. So please be kind with them.
\n" +" If you want to get involved in the development process, we will be " +"glad to\n" +" welcome you so do not hesitate to contact us and come help us build " +"the\n" +" future of Re2o.\n" +" " +msgstr "" +"\n" +" Re2o est un outil d'administration initié par\n" +"
Rezo Supelec Metz et quelques\n" +" membres d'autres assocations de " +"FedeRez\n" +" autour de l'été 2016.
\n" +" Il se veut être un outil idépendant de toute infrastructure réseau\n" +" pour pouvoir être installé en \"quelques étapes\". Cet outil est " +"entièrement gratuit et\n" +" est disponible sous license GNU Public License v2 (GPLv2) sur le\n" +" gitlab de FedeRez" +".
\n" +" Les mainteneurs de Re2o sont de fiers bénévoles venant principalement " +"d'écoles d'ingénieurs françaises\n" +" (mais pas seulement) qui ont donné beaucoup de leur temps pour faire " +"en sorte que\n" +" ce projet soit possible. Donc s'il vous plait soyez gentils avez eux." +"
\n" +" Si vous voulez prendre part au développement, nous serons heureux " +"de\n" +" vous accueillir donc n'hésitez pas à nous contacter et à venir nous " +"aider à construire le\n" +" futur de Re2o.\n" +" " + +#: templates/re2o/about.html:57 +msgid "Contributors list" +msgstr "Liste des contributeurs" + +#: templates/re2o/about.html:66 +msgid "Version informations" +msgstr "Informations de versions" + +#: templates/re2o/about.html:68 +#, python-format +msgid "" +"\n" +" Remote URL: %(git_info_remote)s\n" +" " +msgstr "" +"\n" +" URL distante : %(git_info_remote)s\n" +" " + +#: templates/re2o/about.html:71 +#, python-format +msgid "" +"\n" +" Branch: %(git_info_branch)s\n" +" " +msgstr "" +"\n" +" Branche : %(git_info_branch)s\n" +" " + +#: templates/re2o/about.html:74 +#, python-format +msgid "" +"\n" +" Commit: %(git_info_commit)s\n" +" " +msgstr "" +"\n" +" Commit : %(git_info_commit)s\n" +" " + +#: templates/re2o/about.html:77 +#, python-format +msgid "" +"\n" +" Commit date: %(git_info_commit_date)s\n" +" " +msgstr "" +"\n" +" Date du commit : %(git_info_commit_date)s\n" +" " + +#: templates/re2o/about.html:82 +msgid "Dependencies" +msgstr "Dépendances" + +#: views.py:172 +msgid "No Git repository configured" +msgstr "Aucun repository git configuré" + +#: views.py:178 +msgid "Unable to get the information" +msgstr "Impossible d'obtenir l'information" diff --git a/re2o/management/commands/gen_contrib.py b/re2o/management/commands/gen_contrib.py index d33b560d..08e57304 100644 --- a/re2o/management/commands/gen_contrib.py +++ b/re2o/management/commands/gen_contrib.py @@ -33,7 +33,7 @@ class Command(BaseCommand): def handle(self, *args, **options): contributeurs = [item.split('\t')[1] for item in os.popen("git shortlog -s -n").read().split("\n") if '\t' in item] self.stdout.write(self.style.SUCCESS("Exportation Sucessfull")) - contrib_file = open("contributors.py", "w") - contrib_file.write("#!/usr/bin/env python3\n") - contrib_file.write("\n") - contrib_file.write("contributeurs = " + str(contributeurs)) + with open("re2o/contributors.py", "w") as contrib_file: + contrib_file.write("#!/usr/bin/env python3\n") + contrib_file.write("\n") + contrib_file.write("CONTRIBUTORS = " + str(contributeurs)) diff --git a/re2o/settings.py b/re2o/settings.py index e7853141..dce3ef8f 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -123,6 +123,12 @@ WSGI_APPLICATION = 're2o.wsgi.application' LANGUAGE_CODE = 'en' +# Proritary location search for translations +# then searches in {app}/locale/ for app in INSTALLED_APPS +LOCALE_PATHS = [ + BASE_DIR + '/templates/locale/' # to define translations outside of apps +] + TIME_ZONE = 'Europe/Paris' USE_I18N = True diff --git a/re2o/templates/re2o/about.html b/re2o/templates/re2o/about.html index daec6d91..ac101031 100644 --- a/re2o/templates/re2o/about.html +++ b/re2o/templates/re2o/about.html @@ -24,39 +24,69 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load bootstrap3 %} +{% load i18n %} -{% block title %}Historique{% endblock %} +{% block title %}{% trans "About Re2o" %}{% endblock %} {% block content %} -

À propos de {{AssoName}}

+

{% blocktrans %}About {{AssoName}}{% endblocktrans %}

{{ description }} -

À propos de Re2o

-

Re2o est un logiciel d'administration développé initialement au RézoMetz. Il -se veut indépendant de l'architecture du réseau considéré, de manière à être installable en -quelques clics. -C'est un logiciel totallement libre disponible sur le gitlab de FedeRez. -

-

Liste des contributeurs

-
-
- -
    - {% for i in contrib_1 %} -
  • {{i}}
  • - {% endfor %} -
-
-
-
    - {% for i in contrib_2 %} -
  • {{i}}
  • - {%endfor%} -
-
-
-
-
-
+

{% trans "About Re2o" %}

+

{% blocktrans %} + Re2o is an administration tool initiated by + Rezo Supelec Metz and a few + members of other FedeRez associations + around the summer 2016.
+ It is intended to be a tool independant from any network infrastructure + so it can be setup in "a few steps". This tool is entirely free and + available under a GNU Public License v2 (GPLv2) license on + FedeRez gitlab.
+ Re2o's mainteners are proud volunteers mainly from French engineering + schools (but not limited to) who have given a lot of their time to make + this project possible. So please be kind with them.
+ If you want to get involved in the development process, we will be glad to + welcome you so do not hesitate to contact us and come help us build the + future of Re2o. + {% endblocktrans %} +

+ +
+ +
+

{% trans "Contributors list" %}

+
    + {% for contributor in git_info_contributors %} +
  • {{ contributor }}
  • + {% endfor %} +
+
+ +
+

{% trans "Version informations" %}

+
    +
  • {% blocktrans %} + Remote URL: {{ git_info_remote }} + {% endblocktrans %}
  • +
  • {% blocktrans %} + Branch: {{ git_info_branch }} + {% endblocktrans %}
  • +
  • {% blocktrans %} + Commit: {{ git_info_commit }} + {% endblocktrans %}
  • +
  • {% blocktrans %} + Commit date: {{ git_info_commit_date }} + {% endblocktrans %}
  • +
+ +

{% trans "Dependencies" %}

+
    + {% for dependency in dependencies %} +
  • {{ dependency }}
  • + {% endfor %} +
+
+ +
{% endblock %} diff --git a/re2o/views.py b/re2o/views.py index bd9b18cb..cc0fb04e 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -33,15 +33,18 @@ from django.template.context_processors import csrf from django.contrib.auth.decorators import login_required, permission_required from reversion.models import Version from django.contrib import messages -from preferences.models import Service -from preferences.models import OptionalUser, GeneralOption, AssoOption from django.conf import settings -from contributors import contributeurs +from django.utils.translation import ugettext as _ +import git import os import time from itertools import chain +from preferences.models import Service +from preferences.models import OptionalUser, GeneralOption, AssoOption import users, preferences, cotisations, topologie, machines from .utils import re2o_paginator +from .settings import BASE_DIR, INSTALLED_APPS, MIDDLEWARE_CLASSES +from .contributors import CONTRIBUTORS def form(ctx, template, request): """Form générique, raccourci importé par les fonctions views du site""" @@ -162,12 +165,57 @@ def history(request, application, object_name, object_id): def about_page(request): option = AssoOption.objects.get() - n = len(contributeurs) - contrib_1 = contributeurs[:n//2] - contrib_2 = contributeurs[n//2:] + git_info_contributors = CONTRIBUTORS + try: + git_repo = git.Repo(BASE_DIR) + except git.InvalidGitRepositoryError: + NO_GIT_MSG = _("No Git repository configured") + git_info_remote = NO_GIT_MSG + git_info_branch = NO_GIT_MSG + git_info_commit = NO_GIT_MSG + git_info_commit_date = NO_GIT_MSG + else: + UNABLE_GIT_MSG = _("Unable to get the information") + + try: + git_info_remote = ", ".join(git_repo.remote().urls) + except: + git_info_remote = UNABLE_GIT_MSG + + try: + git_info_branch = git_repo.active_branch.name + except: + git_info_branch = UNABLE_GIT_MSG + + try: + last_commit = git_repo.commit() + except: + git_info_commit = UNABLE_GIT_MSG + else: + try: + git_info_commit = last_commit.hexsha + except: + git_info_commit = UNABLE_GIT_MSG + + try: + git_info_commit_date = last_commit.committed_datetime + except: + git_info_commit_date = UNABLE_GIT_MSG + + dependencies = INSTALLED_APPS + MIDDLEWARE_CLASSES + return render( request, "re2o/about.html", - {'description': option.description , 'AssoName' : option.name , 'contrib_1' : contrib_1 , 'contrib_2' : contrib_2} + { + 'description': option.description , + 'AssoName' : option.name , + 'git_info_contributors': git_info_contributors, + 'git_info_remote': git_info_remote, + 'git_info_branch': git_info_branch, + 'git_info_commit': git_info_commit, + 'git_info_commit_date': git_info_commit_date, + 'dependencies': dependencies + } ) diff --git a/templates/base.html b/templates/base.html index 6961e583..297cac89 100644 --- a/templates/base.html +++ b/templates/base.html @@ -27,6 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load bootstrap3 %} {% load acl %} {% load self_adhesion %} +{% load i18n %} + {% self_adhesion as var_sa %} @@ -39,17 +41,15 @@ with this program; if not, write to the Free Software Foundation, Inc., {# Load CSS and JavaScript #} {% bootstrap_css %} - - - {% comment %}{% endcomment %} + + {% bootstrap_javascript %} - - - - - - {% comment %}{% endcomment %} + + + + + {{ site_name }} : {% block title %}Accueil{% endblock %} @@ -86,7 +86,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
  • Gérer les adhérents
  • Gérer les clubs
  • {% acl_end %} - {% can_view_app machines %} + {% can_view_app machines %}
  • Gérer les machines
  • {% acl_end %} {% can_view_app cotisations %} @@ -99,17 +99,57 @@ with this program; if not, write to the Free Software Foundation, Inc., +
  • Switchs
  • +
  • Bornes WiFi
  • +
  • Chambres et locaux
  • + + {% acl_end %} {% can_view_app logs %}
  • Statistiques
  • {% acl_end %} - @@ -239,7 +278,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {# Read the documentation for more information #} diff --git a/templates/locale/fr/LC_MESSAGES/django.mo b/templates/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..7a3646b875fa230358920fc0c20c37884a36100f GIT binary patch literal 401 zcmZvXK~BRk5Jdw531!Keh4(PUX(=kEAllMO6-0z8z!JI1Gz3yRvYiNSzy&x3$KW2E zg$V+>;mc3svHsZKpW7R69%-G}A@+z(qE9r6h^D_L_?qY4QQab5X;150&Fr5Bb6q(v zGWrn{2h$X8(b!xo!P>2^Kf_WR2cgaK6oyr1A=ZNV(Nzp1gVK=^&ZR?g^PmU31D${c z2ZDEZIf;xg!#Zy+{Kt1F_)+6)`h>cXXkWL%HLizDtunROb7KLQ}6zj94#Nz4a zq=nTfO{uJs8A6P5NwI!=!4~FzGV{Y}I9~lHXmNj}l|w~Oy_A&M;j`N>3z@59mOMyf j(Vg7H6X>mcO{4`H7^_65xyl6V&2#5_16CScYU_OgRh()% literal 0 HcmV?d00001 diff --git a/templates/locale/fr/LC_MESSAGES/django.po b/templates/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 00000000..9de43dbb --- /dev/null +++ b/templates/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,35 @@ +# 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 © 2018 Maël Kervella +# +# 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. +msgid "" +msgstr "" +"Project-Id-Version: 2.5\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-31 14:05+0000\n" +"PO-Revision-Date: 2018-03-31 16:09+0002\n" +"Last-Translator: Maël Kervella \n" +"Language-Team: \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: base.html:121 +msgid "About" +msgstr "A propos" From 001728ca701d95df12ca6ce6b21ab5e88a08066e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 11 Apr 2018 11:31:20 +0000 Subject: [PATCH 2/4] Add python3-git as dependency in isntall script --- install_re2o.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_re2o.sh b/install_re2o.sh index 80379bdb..3f627717 100755 --- a/install_re2o.sh +++ b/install_re2o.sh @@ -238,7 +238,7 @@ install_base=$(dialog --clear \ 2>&1 >/dev/tty) echo "Installation des paquets de base" -apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev python3-crypto +apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev python3-crypto python3-git pip3 install django-bootstrap3 pip3 install django-ldapdb pip3 install django-macaddress From ce8fa57747ca6d7e1e145dda6521c213583b214a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 11 Apr 2018 11:40:55 +0000 Subject: [PATCH 3/4] Add cache for about view --- re2o/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/re2o/views.py b/re2o/views.py index cc0fb04e..d7e7fe12 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -35,13 +35,17 @@ from reversion.models import Version from django.contrib import messages from django.conf import settings from django.utils.translation import ugettext as _ +from django.views.decorators.cache import cache_page + import git import os import time from itertools import chain + from preferences.models import Service from preferences.models import OptionalUser, GeneralOption, AssoOption import users, preferences, cotisations, topologie, machines + from .utils import re2o_paginator from .settings import BASE_DIR, INSTALLED_APPS, MIDDLEWARE_CLASSES from .contributors import CONTRIBUTORS @@ -163,6 +167,7 @@ def history(request, application, object_name, object_id): ) +@cache_page(7 * 24 * 60 * 60) def about_page(request): option = AssoOption.objects.get() git_info_contributors = CONTRIBUTORS From 906758211809494375da619edda910afc9104803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Wed, 11 Apr 2018 13:29:14 +0000 Subject: [PATCH 4/4] Remove multiple try/except for getting git info --- re2o/views.py | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/re2o/views.py b/re2o/views.py index d7e7fe12..4d7e47d0 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -173,39 +173,17 @@ def about_page(request): git_info_contributors = CONTRIBUTORS try: git_repo = git.Repo(BASE_DIR) - except git.InvalidGitRepositoryError: - NO_GIT_MSG = _("No Git repository configured") + git_info_remote = ", ".join(git_repo.remote().urls) + git_info_branch = git_repo.active_branch.name + last_commit = git_repo.commit() + git_info_commit = last_commit.hexsha + git_info_commit_date = last_commit.committed_datetime + except: + NO_GIT_MSG = _("Unable to get the information") git_info_remote = NO_GIT_MSG git_info_branch = NO_GIT_MSG git_info_commit = NO_GIT_MSG git_info_commit_date = NO_GIT_MSG - else: - UNABLE_GIT_MSG = _("Unable to get the information") - - try: - git_info_remote = ", ".join(git_repo.remote().urls) - except: - git_info_remote = UNABLE_GIT_MSG - - try: - git_info_branch = git_repo.active_branch.name - except: - git_info_branch = UNABLE_GIT_MSG - - try: - last_commit = git_repo.commit() - except: - git_info_commit = UNABLE_GIT_MSG - else: - try: - git_info_commit = last_commit.hexsha - except: - git_info_commit = UNABLE_GIT_MSG - - try: - git_info_commit_date = last_commit.committed_datetime - except: - git_info_commit_date = UNABLE_GIT_MSG dependencies = INSTALLED_APPS + MIDDLEWARE_CLASSES