Commit 5c1d2a6b authored by grisel-davy's avatar grisel-davy Committed by Gabriel Detraz

Page de contact coté utilisateur

parent 38edf3b0
......@@ -282,6 +282,10 @@ class MailContact(AclMixin, models.Model):
max_length = 256
def get_name(self):
return self.address.split("@")[0]
class Meta:
permissions = (
("view_mailcontact", "Peut voir les mails de contact"),
{% extends "re2o/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
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.
{% endcomment %}
{% load bootstrap3 %}
{% load i18n %}
{% block title %}{% trans "Contact" %}{% endblock %}
{% block content %}
<h2>{% blocktrans %}Contacter l'association {{asso_name}}{% endblocktrans %}</h2>
{% for contact in contacts %}
<div class="panel panel-info">
<div class="panel-heading"><h4>{{ contact.get_name }}</h4></div>
<div class="panel-body">
<div class="row">
<div class="col-sm-9">{{ contact.commentary}}</div>
<div class="col-sm-3"><a href="mailto:{{ contact.address }}">{{ contact.address }}</a></div>
{% endfor %}
{% endblock %}
......@@ -36,6 +36,8 @@ from django.views.decorators.cache import cache_page
from preferences.models import (
......@@ -60,12 +62,125 @@ def index(request):
twitter_account_name = HomeOption.get_cached_value('twitter_account_name')
asso_name = AssoOption.get_cached_value('pseudo')
return form({
'services_urls': services,
'twitter_url': twitter_url,
'twitter_account_name': twitter_account_name,
'facebook_url': facebook_url,
'asso_name': asso_name
}, 're2o/index.html', request)
'services_urls': services,
'twitter_url': twitter_url,
'twitter_account_name' : twitter_account_name,
'facebook_url': facebook_url,
'asso_name': asso_name
}, 're2o/index.html', request)
#: Binding the corresponding char sequence of history url to re2o models.
'users': {
'user': users.models.User,
'ban': users.models.Ban,
'mailalias': users.models.MailAlias,
'whitelist': users.models.Whitelist,
'school': users.models.School,
'listright': users.models.ListRight,
'serviceuser': users.models.ServiceUser,
'listshell': users.models.ListShell,
'preferences': {
'service': preferences.models.Service,
'mailcontact': preferences.models.MailContact,
'cotisations': {
'facture': cotisations.models.Facture,
'article': cotisations.models.Article,
'paiement': cotisations.models.Paiement,
'banque': cotisations.models.Banque,
'topologie': {
'switch': topologie.models.Switch,
'port': topologie.models.Port,
'room': topologie.models.Room,
'stack': topologie.models.Stack,
'modelswitch': topologie.models.ModelSwitch,
'constructorswitch': topologie.models.ConstructorSwitch,
'accesspoint': topologie.models.AccessPoint,
'switchbay': topologie.models.SwitchBay,
'building': topologie.models.Building,
'machines': {
'machine': machines.models.Machine,
'interface': machines.models.Interface,
'domain': machines.models.Domain,
'machinetype': machines.models.MachineType,
'iptype': machines.models.IpType,
'extension': machines.models.Extension,
'soa': machines.models.SOA,
'mx': machines.models.Mx,
'txt': machines.models.Txt,
'dname': machines.models.DName,
'srv': machines.models.Srv,
'ns': machines.models.Ns,
'service': machines.models.Service,
'role': machines.models.Role,
'vlan': machines.models.Vlan,
'nas': machines.models.Nas,
'ipv6list': machines.models.Ipv6List,
'sshfingerprint': machines.models.SshFingerprint,
'sshfpralgo': machines.models.SshFprAlgo,
def history(request, application, object_name, object_id):
"""Render history for a model.
The model is determined using the `HISTORY_BIND` dictionnary if none is
found, raises a Http404. The view checks if the user is allowed to see the
history using the `can_view` method of the model.
request: The request sent by the user.
object_name: Name of the model.
object_id: Id of the object you want to acces history.
The rendered page of history if access is granted, else the user is
redirected to their profile page, with an error message.
Http404: This kind of models doesn't have history.
model = HISTORY_BIND[application][object_name]
except KeyError:
raise Http404(u"Il n'existe pas d'historique pour ce modèle.")
object_name_id = object_name + 'id'
kwargs = {object_name_id: object_id}
instance = model.get_instance(**kwargs)
except model.DoesNotExist:
messages.error(request, u"Entrée inexistante")
return redirect(reverse(
kwargs={'userid': str(}
can, msg = instance.can_view(request.user)
if not can:
messages.error(request, msg or "Vous ne pouvez pas accéder à ce menu")
return redirect(reverse(
kwargs={'userid': str(}
pagination_number = GeneralOption.get_cached_value('pagination_number')
reversions = Version.objects.get_for_object(instance)
if hasattr(instance, 'linked_objects'):
for related_object in chain(instance.linked_objects()):
reversions = (reversions |
reversions = re2o_paginator(request, reversions, pagination_number)
return render(
{'reversions': reversions, 'object': instance}
>>>>>>> e42b8f9... Page de contact coté utilisateur
@cache_page(7 * 24 * 60 * 60)
......@@ -106,6 +221,21 @@ def about_page(request):
def contact_page(request):
"""The view for the contact page
Send all the objects MailContact
address = MailContact.objects.all()
return render(
'contacts': address,
'asso_name': AssoOption.objects.first().name
def handler500(request):
"""The handler view for a 500 error"""
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