From f38c12fcc359c9dcebdcf0efcc8914bd5ad4904e Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 16 Apr 2018 18:22:51 +0200 Subject: [PATCH] Accueil -> Home --- preferences/admin.py | 18 +++++++++++++-- preferences/forms.py | 10 ++++---- .../migrations/0034_auto_20180416_1120.py | 23 +++++++++++++++++++ preferences/models.py | 14 +++++------ .../preferences/display_preferences.html | 8 +++---- preferences/urls.py | 2 +- preferences/views.py | 8 +++---- re2o/views.py | 8 +++---- 8 files changed, 64 insertions(+), 27 deletions(-) create mode 100644 preferences/migrations/0034_auto_20180416_1120.py diff --git a/preferences/admin.py b/preferences/admin.py index 96b4d9e1..296dc57c 100644 --- a/preferences/admin.py +++ b/preferences/admin.py @@ -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) diff --git a/preferences/forms.py b/preferences/forms.py index b33e4704..afe111a2 100644 --- a/preferences/forms.py +++ b/preferences/forms.py @@ -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 diff --git a/preferences/migrations/0034_auto_20180416_1120.py b/preferences/migrations/0034_auto_20180416_1120.py new file mode 100644 index 00000000..5f27ffe5 --- /dev/null +++ b/preferences/migrations/0034_auto_20180416_1120.py @@ -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"),)}, + ), + ] diff --git a/preferences/models.py b/preferences/models.py index 85f51c52..560fa30f 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -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): diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index 575ddcac..f43e9696 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -218,7 +218,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Supprimer un ou plusieurs service {% include "preferences/aff_service.html" with service_list=service_list %} - + Editer @@ -227,13 +227,13 @@ with this program; if not, write to the Free Software Foundation, Inc., - + - + - +
Url du compte twitter{{ accueiloptions.twitter_url }}{{ homeoptions.twitter_url }} Nom utilisé pour afficher le compte{{ accueiloptions.twitter_account_name }}{{ homeoptions.twitter_account_name }}
Url du compte facebook{{ accueiloptions.facebook_url }}{{ homeoptions.facebook_url }}

diff --git a/preferences/urls.py b/preferences/urls.py index e0391789..bca7bb1e 100644 --- a/preferences/urls.py +++ b/preferences/urls.py @@ -58,7 +58,7 @@ urlpatterns = [ name='edit-options' ), url( - r'^edit_options/(?P
AccueilOption)$', + r'^edit_options/(?P
HomeOption)$', views.edit_options, name='edit-options' ), diff --git a/preferences/views.py b/preferences/views.py index 3f14191d..b2a6ba4c 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -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) diff --git a/re2o/views.py b/re2o/views.py index 6fd9ef4b..3c5cde09 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -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,