8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 00:22:25 +00:00

Merge branch 'mailing' into 'master'

Mailing

See merge request !6
This commit is contained in:
Gabriel Detraz 2017-09-15 01:25:56 +02:00
commit 82ce3f4f83
4 changed files with 33 additions and 0 deletions

View file

@ -195,8 +195,10 @@ def cotisation_post_save(sender, **kwargs):
regen('dns')
regen('dhcp')
regen('mac_ip_list')
regen('mailing')
@receiver(post_delete, sender=Cotisation)
def vente_post_delete(sender, **kwargs):
cotisation = kwargs['instance']
regen('mac_ip_list')
regen('mailing')

View file

@ -496,11 +496,13 @@ def user_post_save(sender, **kwargs):
if is_created:
user.notif_inscription()
user.ldap_sync(base=True, access_refresh=True, mac_refresh=False)
regen('mailing')
@receiver(post_delete, sender=User)
def user_post_delete(sender, **kwargs):
user = kwargs['instance']
user.ldap_del()
regen('mailing')
class ServiceUser(AbstractBaseUser):
readonly = 'readonly'
@ -675,6 +677,7 @@ def ban_post_save(sender, **kwargs):
is_created = kwargs['created']
user = ban.user
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
regen('mailing')
if is_created:
ban.notif_ban()
regen('dhcp')
@ -687,6 +690,7 @@ def ban_post_save(sender, **kwargs):
def ban_post_delete(sender, **kwargs):
user = kwargs['instance'].user
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
regen('mailing')
regen('dhcp')
regen('mac_ip_list')
@ -707,6 +711,7 @@ def whitelist_post_save(sender, **kwargs):
user = whitelist.user
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
is_created = kwargs['created']
regen('mailing')
if is_created:
regen('dhcp')
regen('mac_ip_list')
@ -718,6 +723,7 @@ def whitelist_post_save(sender, **kwargs):
def whitelist_post_delete(sender, **kwargs):
user = kwargs['instance'].user
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
regen('mailing')
regen('dhcp')
regen('mac_ip_list')

View file

@ -63,6 +63,8 @@ urlpatterns = [
url(r'^history/(?P<object>listright)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^history/(?P<object>serviceuser)/(?P<id>[0-9]+)$', views.history, name='history'),
url(r'^$', views.index, name='index'),
url(r'^rest/mailing/$', views.mailing, name='mailing'),
]

View file

@ -38,6 +38,11 @@ from django.core.mail import send_mail
from django.utils import timezone
from django.core.urlresolvers import reverse
from django.db import transaction
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.renderers import JSONRenderer
from reversion.models import Version
from reversion import revisions as reversion
@ -690,3 +695,21 @@ def process_passwd(request, req):
if u_form.is_valid():
return password_change_action(u_form, user, request, req=req)
return form({'userform': u_form}, 'users/user.html', request)
""" Framework Rest """
class JSONResponse(HttpResponse):
def __init__(self, data, **kwargs):
content = JSONRenderer().render(data)
kwargs['content_type'] = 'application/json'
super(JSONResponse, self).__init__(content, **kwargs)
@csrf_exempt
@login_required
@permission_required('serveur')
def mailing(request):
mails = set()
for u in User.objects.all() :
if u.has_access():
mails.add( u.email )
return JSONResponse(mails)