mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Accueil -> Home
This commit is contained in:
parent
e515360936
commit
f38c12fcc3
8 changed files with 64 additions and 27 deletions
|
@ -28,8 +28,16 @@ from __future__ import unicode_literals
|
|||
from django.contrib import admin
|
||||
from reversion.admin import VersionAdmin
|
||||
|
||||
from .models import OptionalUser, OptionalMachine, OptionalTopologie
|
||||
from .models import GeneralOption, Service, AssoOption, MailMessageOption
|
||||
from .models import (
|
||||
OptionalUser,
|
||||
OptionalMachine,
|
||||
OptionalTopologie,
|
||||
GeneralOption,
|
||||
Service,
|
||||
AssoOption,
|
||||
MailMessageOption,
|
||||
HomeOption
|
||||
)
|
||||
|
||||
|
||||
class OptionalUserAdmin(VersionAdmin):
|
||||
|
@ -67,10 +75,16 @@ class MailMessageOptionAdmin(VersionAdmin):
|
|||
pass
|
||||
|
||||
|
||||
class HomeOptionAdmin(VersionAdmin):
|
||||
"""Class admin options home"""
|
||||
pass
|
||||
|
||||
|
||||
admin.site.register(OptionalUser, OptionalUserAdmin)
|
||||
admin.site.register(OptionalMachine, OptionalMachineAdmin)
|
||||
admin.site.register(OptionalTopologie, OptionalTopologieAdmin)
|
||||
admin.site.register(GeneralOption, GeneralOptionAdmin)
|
||||
admin.site.register(HomeOption, HomeOptionAdmin)
|
||||
admin.site.register(Service, ServiceAdmin)
|
||||
admin.site.register(AssoOption, AssoOptionAdmin)
|
||||
admin.site.register(MailMessageOption, MailMessageOptionAdmin)
|
||||
|
|
|
@ -34,7 +34,7 @@ from .models import (
|
|||
GeneralOption,
|
||||
AssoOption,
|
||||
MailMessageOption,
|
||||
AccueilOption,
|
||||
HomeOption,
|
||||
Service
|
||||
)
|
||||
|
||||
|
@ -192,15 +192,15 @@ class EditMailMessageOptionForm(ModelForm):
|
|||
mail de bienvenue en anglais'
|
||||
|
||||
|
||||
class EditAccueilOptionForm(ModelForm):
|
||||
"""Formulaire d'édition des options de la page d'accueil"""
|
||||
class EditHomeOptionForm(ModelForm):
|
||||
"""Edition forms of Home options"""
|
||||
class Meta:
|
||||
model = AccueilOption
|
||||
model = HomeOption
|
||||
fields = '__all__'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(EditAccueilOptionForm, self).__init__(
|
||||
super(EditHomeOptionForm, self).__init__(
|
||||
*args,
|
||||
prefix=prefix,
|
||||
**kwargs
|
||||
|
|
23
preferences/migrations/0034_auto_20180416_1120.py
Normal file
23
preferences/migrations/0034_auto_20180416_1120.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.7 on 2018-04-16 16:20
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('preferences', '0033_accueiloption'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='AccueilOption',
|
||||
new_name='HomeOption',
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='homeoption',
|
||||
options={'permissions': (('view_homeoption', "Peut voir les options de l'accueil"),)},
|
||||
),
|
||||
]
|
|
@ -331,8 +331,8 @@ def assooption_post_save(**kwargs):
|
|||
asso_pref.set_in_cache()
|
||||
|
||||
|
||||
class AccueilOption(AclMixin, PreferencesModel):
|
||||
"""Reglages de la page d'accueil"""
|
||||
class HomeOption(AclMixin, PreferencesModel):
|
||||
"""Settings of the home page (facebook/twitter etc)"""
|
||||
PRETTY_NAME = "Options de la page d'accueil"
|
||||
|
||||
facebook_url = models.URLField(
|
||||
|
@ -354,15 +354,15 @@ class AccueilOption(AclMixin, PreferencesModel):
|
|||
|
||||
class Meta:
|
||||
permissions = (
|
||||
("view_accueiloption", "Peut voir les options de l'accueil"),
|
||||
("view_homeoption", "Peut voir les options de l'accueil"),
|
||||
)
|
||||
|
||||
|
||||
@receiver(post_save, sender=AccueilOption)
|
||||
def accueiloption_post_save(**kwargs):
|
||||
@receiver(post_save, sender=HomeOption)
|
||||
def homeoption_post_save(**kwargs):
|
||||
"""Ecriture dans le cache"""
|
||||
accueil_pref = kwargs['instance']
|
||||
accueil_pref.set_in_cache()
|
||||
home_pref = kwargs['instance']
|
||||
home_pref.set_in_cache()
|
||||
|
||||
|
||||
class MailMessageOption(AclMixin, models.Model):
|
||||
|
|
|
@ -218,7 +218,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<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' %}">
|
||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'HomeOption' %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
Editer
|
||||
</a>
|
||||
|
@ -227,13 +227,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Url du compte twitter</th>
|
||||
<td>{{ accueiloptions.twitter_url }}</td>
|
||||
<td>{{ homeoptions.twitter_url }}</td>
|
||||
<th>Nom utilisé pour afficher le compte</th>
|
||||
<td>{{ accueiloptions.twitter_account_name }}</td>
|
||||
<td>{{ homeoptions.twitter_account_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Url du compte facebook</th>
|
||||
<td>{{ accueiloptions.facebook_url }}</td>
|
||||
<td>{{ homeoptions.facebook_url }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
|
|
|
@ -58,7 +58,7 @@ urlpatterns = [
|
|||
name='edit-options'
|
||||
),
|
||||
url(
|
||||
r'^edit_options/(?P<section>AccueilOption)$',
|
||||
r'^edit_options/(?P<section>HomeOption)$',
|
||||
views.edit_options,
|
||||
name='edit-options'
|
||||
),
|
||||
|
|
|
@ -51,7 +51,7 @@ from .models import (
|
|||
MailMessageOption,
|
||||
GeneralOption,
|
||||
OptionalTopologie,
|
||||
AccueilOption
|
||||
HomeOption
|
||||
)
|
||||
from . import models
|
||||
from . import forms
|
||||
|
@ -64,7 +64,7 @@ from . import forms
|
|||
@can_view_all(GeneralOption)
|
||||
@can_view_all(AssoOption)
|
||||
@can_view_all(MailMessageOption)
|
||||
@can_view_all(AccueilOption)
|
||||
@can_view_all(HomeOption)
|
||||
def display_options(request):
|
||||
"""Vue pour affichage des options (en vrac) classé selon les models
|
||||
correspondants dans un tableau"""
|
||||
|
@ -73,7 +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()
|
||||
homeoptions, _created = HomeOption.objects.get_or_create()
|
||||
mailmessageoptions, _created = MailMessageOption.objects.get_or_create()
|
||||
service_list = Service.objects.all()
|
||||
return form({
|
||||
|
@ -82,7 +82,7 @@ def display_options(request):
|
|||
'topologieoptions': topologieoptions,
|
||||
'generaloptions': generaloptions,
|
||||
'assooptions': assooptions,
|
||||
'accueiloptions': accueiloptions,
|
||||
'homeoptions': homeoptions,
|
||||
'mailmessageoptions': mailmessageoptions,
|
||||
'service_list': service_list
|
||||
}, 'preferences/display_preferences.html', request)
|
||||
|
|
|
@ -45,7 +45,7 @@ from preferences.models import (
|
|||
Service,
|
||||
GeneralOption,
|
||||
AssoOption,
|
||||
AccueilOption
|
||||
HomeOption
|
||||
)
|
||||
import users
|
||||
import cotisations
|
||||
|
@ -68,9 +68,9 @@ def index(request):
|
|||
services = [[], [], []]
|
||||
for indice, serv in enumerate(Service.objects.all()):
|
||||
services[indice % 3].append(serv)
|
||||
twitter_url = AccueilOption.get_cached_value('twitter_url')
|
||||
facebook_url = AccueilOption.get_cached_value('facebook_url')
|
||||
twitter_account_name = AccueilOption.get_cached_value('twitter_account_name')
|
||||
twitter_url = HomeOption.get_cached_value('twitter_url')
|
||||
facebook_url = HomeOption.get_cached_value('facebook_url')
|
||||
twitter_account_name = HomeOption.get_cached_value('twitter_account_name')
|
||||
asso_name = AssoOption.get_cached_value('pseudo')
|
||||
return form({
|
||||
'services_urls': services,
|
||||
|
|
Loading…
Reference in a new issue