mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
REST view pour obtenir les mails des adhérents ayant une connexion
This commit is contained in:
parent
b0ead0ccd6
commit
69a32753d0
2 changed files with 25 additions and 0 deletions
|
@ -61,6 +61,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'),
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,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
|
||||
|
@ -687,3 +692,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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue