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