Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
0356947e
Commit
0356947e
authored
Jun 10, 2018
by
Maël Kervella
Committed by
Maël Kervella
Jun 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoints for mailing
parent
761fad57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
api/serializers.py
api/serializers.py
+15
-0
api/urls.py
api/urls.py
+2
-0
api/views.py
api/views.py
+23
-2
No files found.
api/serializers.py
View file @
0356947e
...
...
@@ -577,3 +577,18 @@ class DNSZonesSerializer(serializers.ModelSerializer):
fields
=
(
'name'
,
'soa'
,
'ns_records'
,
'originv4'
,
'originv6'
,
'mx_records'
,
'txt_records'
,
'srv_records'
,
'a_records'
,
'aaaa_records'
,
'cname_records'
)
# Mailing
class
MailingMemberSerializer
(
UserSerializer
):
class
Meta
(
UserSerializer
.
Meta
):
fields
=
(
'name'
,
'pseudo'
,
'email'
)
class
MailingSerializer
(
ClubSerializer
):
members
=
MailingMemberSerializer
(
many
=
True
)
admins
=
MailingMemberSerializer
(
source
=
'administrators'
,
many
=
True
)
class
Meta
(
ClubSerializer
.
Meta
):
fields
=
(
'name'
,
'members'
,
'admins'
)
api/urls.py
View file @
0356947e
...
...
@@ -94,5 +94,7 @@ urlpatterns = [
url
(
r
'^'
,
include
(
router
.
urls
)),
url
(
r
'^dhcp/hostmacip'
,
views
.
HostMacIpView
.
as_view
()),
url
(
r
'^dns/zones'
,
views
.
DNSZonesView
.
as_view
()),
url
(
r
'^mailing/standard'
,
views
.
StandardMailingView
.
as_view
()),
url
(
r
'^mailing/club'
,
views
.
ClubMailingView
.
as_view
()),
url
(
r
'^token-auth'
,
views
.
ObtainExpiringAuthToken
.
as_view
())
]
api/views.py
View file @
0356947e
...
...
@@ -31,7 +31,7 @@ from django.conf import settings
from
rest_framework.authtoken.views
import
ObtainAuthToken
from
rest_framework.authtoken.models
import
Token
from
rest_framework.response
import
Response
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
viewsets
,
generics
,
views
import
cotisations.models
as
cotisations
import
machines.models
as
machines
...
...
@@ -39,9 +39,10 @@ import preferences.models as preferences
import
topologie.models
as
topologie
import
users.models
as
users
from
re2o.utils
import
all_active_interfaces
from
re2o.utils
import
all_active_interfaces
,
all_has_access
from
.
import
serializers
from
.pagination
import
PageSizedPagination
# COTISATIONS APP
...
...
@@ -345,6 +346,26 @@ class DNSZonesView(generics.ListAPIView):
serializer_class
=
serializers
.
DNSZonesSerializer
# Mailing views
class
StandardMailingView
(
views
.
APIView
):
pagination_class
=
PageSizedPagination
get_queryset
=
lambda
self
:
all_has_access
()
def
get
(
self
,
request
,
format
=
None
):
adherents_data
=
serializers
.
MailingMemberSerializer
(
self
.
get_queryset
(),
many
=
True
).
data
data
=
[{
'name'
:
'adherents'
,
'members'
:
adherents_data
}]
paginator
=
self
.
pagination_class
()
paginator
.
paginate_queryset
(
data
,
request
)
return
paginator
.
get_paginated_response
(
data
)
class
ClubMailingView
(
generics
.
ListAPIView
):
queryset
=
users
.
Club
.
objects
.
all
()
serializer_class
=
serializers
.
MailingSerializer
# Subclass the standard rest_framework.auth_token.views.ObtainAuthToken
# in order to renew the lease of the token and add expiration time
class
ObtainExpiringAuthToken
(
ObtainAuthToken
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment