mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-28 09:53:47 +00:00
Fix #108
This commit is contained in:
parent
8e057db5ea
commit
b118e1199e
7 changed files with 152 additions and 6 deletions
|
@ -27,9 +27,16 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.forms import ModelForm, Form
|
||||
from django import forms
|
||||
from .models import OptionalUser, OptionalMachine, OptionalTopologie
|
||||
from .models import GeneralOption, AssoOption, MailMessageOption, Service
|
||||
|
||||
from .models import (
|
||||
OptionalUser,
|
||||
OptionalMachine,
|
||||
OptionalTopologie,
|
||||
GeneralOption,
|
||||
AssoOption,
|
||||
MailMessageOption,
|
||||
AccueilOption,
|
||||
Service
|
||||
)
|
||||
|
||||
class EditOptionalUserForm(ModelForm):
|
||||
"""Formulaire d'édition des options de l'user. (solde, telephone..)"""
|
||||
|
@ -185,6 +192,21 @@ class EditMailMessageOptionForm(ModelForm):
|
|||
mail de bienvenue en anglais'
|
||||
|
||||
|
||||
class EditAccueilOptionForm(ModelForm):
|
||||
"""Formulaire d'édition des options de la page d'accueil"""
|
||||
class Meta:
|
||||
model = AccueilOption
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditAccueilOptionForm, self).__init__(
|
||||
*args,
|
||||
prefix=prefix,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
||||
class ServiceForm(ModelForm):
|
||||
"""Edition, ajout de services sur la page d'accueil"""
|
||||
class Meta:
|
||||
|
|
29
preferences/migrations/0033_accueiloption.py
Normal file
29
preferences/migrations/0033_accueiloption.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-04-16 02:35
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import re2o.mixins
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0032_optionaluser_shell_default'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AccueilOption',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('facebook_url', models.URLField(blank=True, help_text='Url du compte facebook', null=True)),
|
||||
('twitter_url', models.URLField(blank=True, help_text='Url du compte twitter', null=True)),
|
||||
('twitter_account_name', models.CharField(blank=True, help_text='Nom du compte à afficher', max_length=32, null=True)),
|
||||
],
|
||||
options={
|
||||
'permissions': (('view_accueiloption', "Peut voir les options de l'accueil"),),
|
||||
},
|
||||
bases=(re2o.mixins.AclMixin, models.Model),
|
||||
),
|
||||
]
|
|
@ -331,6 +331,40 @@ def assooption_post_save(**kwargs):
|
|||
asso_pref.set_in_cache()
|
||||
|
||||
|
||||
class AccueilOption(AclMixin, PreferencesModel):
|
||||
"""Reglages de la page d'accueil"""
|
||||
PRETTY_NAME = "Options de la page d'accueil"
|
||||
|
||||
facebook_url = models.URLField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Url du compte facebook"
|
||||
)
|
||||
twitter_url = models.URLField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Url du compte twitter"
|
||||
)
|
||||
twitter_account_name = models.CharField(
|
||||
max_length=32,
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Nom du compte à afficher"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
permissions = (
|
||||
("view_accueiloption", "Peut voir les options de l'accueil"),
|
||||
)
|
||||
|
||||
|
||||
@receiver(post_save, sender=AccueilOption)
|
||||
def accueiloption_post_save(**kwargs):
|
||||
"""Ecriture dans le cache"""
|
||||
accueil_pref = kwargs['instance']
|
||||
accueil_pref.set_in_cache()
|
||||
|
||||
|
||||
class MailMessageOption(AclMixin, models.Model):
|
||||
"""Reglages, mail de bienvenue et autre"""
|
||||
PRETTY_NAME = "Options de corps de mail"
|
||||
|
|
|
@ -211,12 +211,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<td>{{ mailmessageoptions.welcome_mail_en | safe }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2>Liste des services page d'accueil</h2>
|
||||
<h2>Liste des services et préférences page d'accueil</h2>
|
||||
{% can_create preferences.Service%}
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-service' %}"><i class="fa fa-plus"></i> Ajouter un service</a>
|
||||
{% acl_end %}
|
||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'preferences:del-services' %}"><i class="fa fa-trash"></i> Supprimer un ou plusieurs service</a>
|
||||
{% include "preferences/aff_service.html" with service_list=service_list %}
|
||||
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'AccueilOption' %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
Editer
|
||||
</a>
|
||||
<p>
|
||||
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Url du compte twitter</th>
|
||||
<td>{{ accueiloptions.twitter_url }}</td>
|
||||
<th>Nom utilisé pour afficher le compte</th>
|
||||
<td>{{ accueiloptions.twitter_account_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Url du compte facebook</th>
|
||||
<td>{{ accueiloptions.facebook_url }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -57,6 +57,11 @@ urlpatterns = [
|
|||
views.edit_options,
|
||||
name='edit-options'
|
||||
),
|
||||
url(
|
||||
r'^edit_options/(?P<section>AccueilOption)$',
|
||||
views.edit_options,
|
||||
name='edit-options'
|
||||
),
|
||||
url(
|
||||
r'^edit_options/(?P<section>MailMessageOption)$',
|
||||
views.edit_options,
|
||||
|
|
|
@ -43,8 +43,16 @@ from re2o.views import form
|
|||
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all
|
||||
|
||||
from .forms import ServiceForm, DelServiceForm
|
||||
from .models import Service, OptionalUser, OptionalMachine, AssoOption
|
||||
from .models import MailMessageOption, GeneralOption, OptionalTopologie
|
||||
from .models import (
|
||||
Service,
|
||||
OptionalUser,
|
||||
OptionalMachine,
|
||||
AssoOption,
|
||||
MailMessageOption,
|
||||
GeneralOption,
|
||||
OptionalTopologie,
|
||||
AccueilOption
|
||||
)
|
||||
from . import models
|
||||
from . import forms
|
||||
|
||||
|
@ -56,6 +64,7 @@ from . import forms
|
|||
@can_view_all(GeneralOption)
|
||||
@can_view_all(AssoOption)
|
||||
@can_view_all(MailMessageOption)
|
||||
@can_view_all(AccueilOption)
|
||||
def display_options(request):
|
||||
"""Vue pour affichage des options (en vrac) classé selon les models
|
||||
correspondants dans un tableau"""
|
||||
|
@ -64,6 +73,7 @@ def display_options(request):
|
|||
topologieoptions, _created = OptionalTopologie.objects.get_or_create()
|
||||
generaloptions, _created = GeneralOption.objects.get_or_create()
|
||||
assooptions, _created = AssoOption.objects.get_or_create()
|
||||
accueiloptions, _created = AccueilOption.objects.get_or_create()
|
||||
mailmessageoptions, _created = MailMessageOption.objects.get_or_create()
|
||||
service_list = Service.objects.all()
|
||||
return form({
|
||||
|
@ -72,6 +82,7 @@ def display_options(request):
|
|||
'topologieoptions': topologieoptions,
|
||||
'generaloptions': generaloptions,
|
||||
'assooptions': assooptions,
|
||||
'accueiloptions': accueiloptions,
|
||||
'mailmessageoptions': mailmessageoptions,
|
||||
'service_list': service_list
|
||||
}, 'preferences/display_preferences.html', request)
|
||||
|
|
|
@ -25,4 +25,30 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
|
||||
{% block sidebar %}
|
||||
|
||||
{% if facebook_url %}
|
||||
<div class="fb-page" data-href="{{ facebook_url }}" data-tabs="timeline" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="false"><blockquote cite="{{ facebook_url }}" class="fb-xfbml-parse-ignore"><a href="{{ facebook_url }}">{{ asso_name }}</a></blockquote></div>
|
||||
|
||||
<div id="fb-root"></div>
|
||||
<script>(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = 'https://connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.12';
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));</script>
|
||||
|
||||
<hr>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if twitter_url %}
|
||||
<a class="twitter-timeline" data-lang="fr" data-height="500" href="{{ twitter_url }}?ref_src=twsrc%5Etfw">Tweets de @{{ twitter_account_name }}</a>
|
||||
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||
|
||||
<a href="{{ twitter_url }}?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-count="false"> Suivre @{{ twitter_account_name }}</a>
|
||||
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
Loading…
Reference in a new issue