Commit d673e4d5 authored by Alexandre IOOSS's avatar Alexandre IOOSS Committed by klafyvel
Browse files

Clean up of API code

Automatic clean up that checks Python 2.7 compatibility, switch some
methods to static and rearrange code.
parent ee2ee0ad
Pipeline #1449 passed with stage
in 3 minutes and 30 seconds
......@@ -26,8 +26,8 @@ done.
"""
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
......
......@@ -26,12 +26,14 @@ import datetime
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from rest_framework.authentication import TokenAuthentication
from rest_framework import exceptions
from rest_framework.authentication import TokenAuthentication
class ExpiringTokenAuthentication(TokenAuthentication):
"""Authenticate a user if the provided token is valid and not expired.
"""
def authenticate_credentials(self, key):
"""See base class. Add the verification the token is not expired.
"""
......@@ -46,4 +48,4 @@ class ExpiringTokenAuthentication(TokenAuthentication):
if token.created < utc_now - token_duration:
raise exceptions.AuthenticationFailed(_('Token has expired'))
return (token.user, token)
return token.user, token
......@@ -24,8 +24,6 @@
from rest_framework import permissions, exceptions
from re2o.acl import can_create, can_edit, can_delete, can_view_all
from . import acl
......@@ -57,14 +55,14 @@ def _get_param_in_view(view, param_name):
AssertionError: None of the getter function or the attribute are
defined in the view.
"""
assert hasattr(view, 'get_'+param_name) \
or getattr(view, param_name, None) is not None, (
assert hasattr(view, 'get_' + param_name) \
or getattr(view, param_name, None) is not None, (
'cannot apply {} on a view that does not set '
'`.{}` or have a `.get_{}()` method.'
).format(self.__class__.__name__, param_name, param_name)
if hasattr(view, 'get_'+param_name):
param = getattr(view, 'get_'+param_name)()
if hasattr(view, 'get_' + param_name):
param = getattr(view, 'get_' + param_name)()
assert param is not None, (
'{}.get_{}() returned None'
).format(view.__class__.__name__, param_name)
......@@ -80,7 +78,8 @@ class ACLPermission(permissions.BasePermission):
See the wiki for the syntax of this attribute.
"""
def get_required_permissions(self, method, view):
@staticmethod
def get_required_permissions(method, view):
"""Build the list of permissions required for the request to be
accepted.
......@@ -153,15 +152,15 @@ class AutodetectACLPermission(permissions.BasePermission):
'OPTIONS': [can_see_api, lambda model: model.can_view_all],
'HEAD': [can_see_api, lambda model: model.can_view_all],
'POST': [can_see_api, lambda model: model.can_create],
'PUT': [], # No restrictions, apply to objects
'PATCH': [], # No restrictions, apply to objects
'PUT': [], # No restrictions, apply to objects
'PATCH': [], # No restrictions, apply to objects
'DELETE': [], # No restrictions, apply to objects
}
perms_obj_map = {
'GET': [can_see_api, lambda obj: obj.can_view],
'OPTIONS': [can_see_api, lambda obj: obj.can_view],
'HEAD': [can_see_api, lambda obj: obj.can_view],
'POST': [], # No restrictions, apply to models
'POST': [], # No restrictions, apply to models
'PUT': [can_see_api, lambda obj: obj.can_edit],
'PATCH': [can_see_api, lambda obj: obj.can_edit],
'DELETE': [can_see_api, lambda obj: obj.can_delete],
......@@ -209,7 +208,8 @@ class AutodetectACLPermission(permissions.BasePermission):
return [perm(obj) for perm in self.perms_obj_map[method]]
def _queryset(self, view):
@staticmethod
def _queryset(view):
return _get_param_in_view(view, 'queryset')
def has_permission(self, request, view):
......@@ -282,4 +282,3 @@ class AutodetectACLPermission(permissions.BasePermission):
return False
return True
......@@ -24,12 +24,12 @@
from collections import OrderedDict
from django.conf.urls import url, include
from django.conf.urls import url
from django.core.urlresolvers import NoReverseMatch
from rest_framework import views
from rest_framework.routers import DefaultRouter
from rest_framework.response import Response
from rest_framework.reverse import reverse
from rest_framework.routers import DefaultRouter
from rest_framework.schemas import SchemaGenerator
from rest_framework.settings import api_settings
......@@ -64,7 +64,8 @@ class AllViewsRouter(DefaultRouter):
name = self.get_default_name(pattern)
self.view_registry.append((pattern, view, name))
def get_default_name(self, pattern):
@staticmethod
def get_default_name(pattern):
"""Returns the name to use for the route if none was specified.
Args:
......@@ -113,7 +114,8 @@ class AllViewsRouter(DefaultRouter):
_ignore_model_permissions = True
renderer_classes = view_renderers
def get(self, request, *args, **kwargs):
@staticmethod
def get(request, *args, **kwargs):
if request.accepted_renderer.media_type in schema_media_types:
# Return a schema response.
schema = schema_generator.get_schema(request)
......
......@@ -30,7 +30,6 @@ import preferences.models as preferences
import topologie.models as topologie
import users.models as users
# The namespace used for the API. It must match the namespace used in the
# urlpatterns to include the API URLs.
API_NAMESPACE = 'api'
......@@ -40,6 +39,7 @@ class NamespacedHRField(serializers.HyperlinkedRelatedField):
"""A `rest_framework.serializers.HyperlinkedRelatedField` subclass to
automatically prefix view names with the API namespace.
"""
def __init__(self, view_name=None, **kwargs):
if view_name is not None:
view_name = '%s:%s' % (API_NAMESPACE, view_name)
......@@ -50,6 +50,7 @@ class NamespacedHIField(serializers.HyperlinkedIdentityField):
"""A `rest_framework.serializers.HyperlinkedIdentityField` subclass to
automatically prefix view names with teh API namespace.
"""
def __init__(self, view_name=None, **kwargs):
if view_name is not None:
view_name = '%s:%s' % (API_NAMESPACE, view_name)
......@@ -70,6 +71,7 @@ class NamespacedHMSerializer(serializers.HyperlinkedModelSerializer):
class FactureSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Facture` objects.
"""
class Meta:
model = cotisations.Facture
fields = ('user', 'paiement', 'banque', 'cheque', 'date', 'valid',
......@@ -79,6 +81,7 @@ class FactureSerializer(NamespacedHMSerializer):
class VenteSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Vente` objects.
"""
class Meta:
model = cotisations.Vente
fields = ('facture', 'number', 'name', 'prix', 'duration',
......@@ -88,6 +91,7 @@ class VenteSerializer(NamespacedHMSerializer):
class ArticleSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Article` objects.
"""
class Meta:
model = cotisations.Article
fields = ('name', 'prix', 'duration', 'type_user',
......@@ -97,6 +101,7 @@ class ArticleSerializer(NamespacedHMSerializer):
class BanqueSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Banque` objects.
"""
class Meta:
model = cotisations.Banque
fields = ('name', 'api_url')
......@@ -105,6 +110,7 @@ class BanqueSerializer(NamespacedHMSerializer):
class PaiementSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Paiement` objects.
"""
class Meta:
model = cotisations.Paiement
fields = ('moyen', 'type_paiement', 'api_url')
......@@ -113,6 +119,7 @@ class PaiementSerializer(NamespacedHMSerializer):
class CotisationSerializer(NamespacedHMSerializer):
"""Serialize `cotisations.models.Cotisation` objects.
"""
class Meta:
model = cotisations.Cotisation
fields = ('vente', 'type_cotisation', 'date_start', 'date_end',
......@@ -125,6 +132,7 @@ class CotisationSerializer(NamespacedHMSerializer):
class MachineSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Machine` objects.
"""
class Meta:
model = machines.Machine
fields = ('user', 'name', 'active', 'api_url')
......@@ -133,6 +141,7 @@ class MachineSerializer(NamespacedHMSerializer):
class MachineTypeSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.MachineType` objects.
"""
class Meta:
model = machines.MachineType
fields = ('type', 'ip_type', 'api_url')
......@@ -141,6 +150,7 @@ class MachineTypeSerializer(NamespacedHMSerializer):
class IpTypeSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.IpType` objects.
"""
class Meta:
model = machines.IpType
fields = ('type', 'extension', 'need_infra', 'domaine_ip_start',
......@@ -151,6 +161,7 @@ class IpTypeSerializer(NamespacedHMSerializer):
class VlanSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Vlan` objects.
"""
class Meta:
model = machines.Vlan
fields = ('vlan_id', 'name', 'comment', 'arp_protect', 'dhcp_snooping',
......@@ -160,6 +171,7 @@ class VlanSerializer(NamespacedHMSerializer):
class NasSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Nas` objects.
"""
class Meta:
model = machines.Nas
fields = ('name', 'nas_type', 'machine_type', 'port_access_mode',
......@@ -169,6 +181,7 @@ class NasSerializer(NamespacedHMSerializer):
class SOASerializer(NamespacedHMSerializer):
"""Serialize `machines.models.SOA` objects.
"""
class Meta:
model = machines.SOA
fields = ('name', 'mail', 'refresh', 'retry', 'expire', 'ttl',
......@@ -178,6 +191,7 @@ class SOASerializer(NamespacedHMSerializer):
class ExtensionSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Extension` objects.
"""
class Meta:
model = machines.Extension
fields = ('name', 'need_infra', 'origin', 'origin_v6', 'soa',
......@@ -187,6 +201,7 @@ class ExtensionSerializer(NamespacedHMSerializer):
class MxSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Mx` objects.
"""
class Meta:
model = machines.Mx
fields = ('zone', 'priority', 'name', 'api_url')
......@@ -195,13 +210,16 @@ class MxSerializer(NamespacedHMSerializer):
class DNameSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.DName` objects.
"""
class Meta:
model = machines.DName
fields = ('zone', 'alias', 'api_url')
class NsSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Ns` objects.
"""
class Meta:
model = machines.Ns
fields = ('zone', 'ns', 'api_url')
......@@ -210,6 +228,7 @@ class NsSerializer(NamespacedHMSerializer):
class TxtSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Txt` objects.
"""
class Meta:
model = machines.Txt
fields = ('zone', 'field1', 'field2', 'api_url')
......@@ -218,14 +237,17 @@ class TxtSerializer(NamespacedHMSerializer):
class SrvSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Srv` objects.
"""
class Meta:
model = machines.Srv
fields = ('service', 'protocole', 'extension', 'ttl', 'priority',
'weight', 'port', 'target', 'api_url')
class SshFpSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.SSHFP` objects.
"""
class Meta:
model = machines.SshFp
field = ('machine', 'pub_key_entry', 'algo', 'comment', 'api_url')
......@@ -246,6 +268,7 @@ class InterfaceSerializer(NamespacedHMSerializer):
class Ipv6ListSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Ipv6List` objects.
"""
class Meta:
model = machines.Ipv6List
fields = ('ipv6', 'interface', 'slaac_ip', 'api_url')
......@@ -254,6 +277,7 @@ class Ipv6ListSerializer(NamespacedHMSerializer):
class DomainSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Domain` objects.
"""
class Meta:
model = machines.Domain
fields = ('interface_parent', 'name', 'extension', 'cname',
......@@ -263,6 +287,7 @@ class DomainSerializer(NamespacedHMSerializer):
class IpListSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.IpList` objects.
"""
class Meta:
model = machines.IpList
fields = ('ipv4', 'ip_type', 'need_infra', 'api_url')
......@@ -271,6 +296,7 @@ class IpListSerializer(NamespacedHMSerializer):
class ServiceSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Service` objects.
"""
class Meta:
model = machines.Service
fields = ('service_type', 'min_time_regen', 'regular_time_regen',
......@@ -280,6 +306,7 @@ class ServiceSerializer(NamespacedHMSerializer):
class ServiceLinkSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.Service_link` objects.
"""
class Meta:
model = machines.Service_link
fields = ('service', 'server', 'last_regen', 'asked_regen',
......@@ -306,6 +333,7 @@ class OuverturePortListSerializer(NamespacedHMSerializer):
class OuverturePortSerializer(NamespacedHMSerializer):
"""Serialize `machines.models.OuverturePort` objects.
"""
class Meta:
model = machines.OuverturePort
fields = ('begin', 'end', 'port_list', 'protocole', 'io', 'api_url')
......@@ -339,6 +367,7 @@ class OptionalUserSerializer(NamespacedHMSerializer):
class OptionalMachineSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.OptionalMachine` objects.
"""
class Meta:
model = preferences.OptionalMachine
fields = ('password_machine', 'max_lambdauser_interfaces',
......@@ -363,6 +392,7 @@ class OptionalTopologieSerializer(NamespacedHMSerializer):
class GeneralOptionSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.GeneralOption` objects.
"""
class Meta:
model = preferences.GeneralOption
fields = ('general_message', 'search_display_page',
......@@ -374,6 +404,7 @@ class GeneralOptionSerializer(NamespacedHMSerializer):
class HomeServiceSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.Service` objects.
"""
class Meta:
model = preferences.Service
fields = ('name', 'url', 'description', 'image', 'api_url')
......@@ -385,6 +416,7 @@ class HomeServiceSerializer(NamespacedHMSerializer):
class AssoOptionSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.AssoOption` objects.
"""
class Meta:
model = preferences.AssoOption
fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
......@@ -395,6 +427,7 @@ class AssoOptionSerializer(NamespacedHMSerializer):
class HomeOptionSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.HomeOption` objects.
"""
class Meta:
model = preferences.HomeOption
fields = ('facebook_url', 'twitter_url', 'twitter_account_name')
......@@ -403,18 +436,19 @@ class HomeOptionSerializer(NamespacedHMSerializer):
class MailMessageOptionSerializer(NamespacedHMSerializer):
"""Serialize `preferences.models.MailMessageOption` objects.
"""
class Meta:
model = preferences.MailMessageOption
fields = ('welcome_mail_fr', 'welcome_mail_en')
# TOPOLOGIE
class StackSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.Stack` objects
"""
class Meta:
model = topologie.Stack
fields = ('name', 'stack_id', 'details', 'member_id_min',
......@@ -424,6 +458,7 @@ class StackSerializer(NamespacedHMSerializer):
class AccessPointSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.AccessPoint` objects
"""
class Meta:
model = topologie.AccessPoint
fields = ('user', 'name', 'active', 'location', 'api_url')
......@@ -433,6 +468,7 @@ class SwitchSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.Switch` objects
"""
port_amount = serializers.IntegerField(source='number')
class Meta:
model = topologie.Switch
fields = ('user', 'name', 'active', 'port_amount', 'stack',
......@@ -442,6 +478,7 @@ class SwitchSerializer(NamespacedHMSerializer):
class ServerSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.Server` objects
"""
class Meta:
model = topologie.Server
fields = ('user', 'name', 'active', 'api_url')
......@@ -450,6 +487,7 @@ class ServerSerializer(NamespacedHMSerializer):
class ModelSwitchSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.ModelSwitch` objects
"""
class Meta:
model = topologie.ModelSwitch
fields = ('reference', 'constructor', 'api_url')
......@@ -458,6 +496,7 @@ class ModelSwitchSerializer(NamespacedHMSerializer):
class ConstructorSwitchSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.ConstructorSwitch` objects
"""
class Meta:
model = topologie.ConstructorSwitch
fields = ('name', 'api_url')
......@@ -466,6 +505,7 @@ class ConstructorSwitchSerializer(NamespacedHMSerializer):
class SwitchBaySerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.SwitchBay` objects
"""
class Meta:
model = topologie.SwitchBay
fields = ('name', 'building', 'info', 'api_url')
......@@ -474,6 +514,7 @@ class SwitchBaySerializer(NamespacedHMSerializer):
class BuildingSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.Building` objects
"""
class Meta:
model = topologie.Building
fields = ('name', 'api_url')
......@@ -500,7 +541,7 @@ class PortProfileSerializer(NamespacedHMSerializer):
"""
class Meta:
model = topologie.PortProfile
fields = ('name', 'profil_default', 'vlan_untagged', 'vlan_tagged',
fields = ('name', 'profil_default', 'vlan_untagged', 'vlan_tagged',
'radius_type', 'radius_mode', 'speed', 'mac_limit', 'flow_control',
'dhcp_snooping', 'dhcpv6_snooping', 'dhcpv6_snooping', 'arp_protect',
'ra_guard', 'loop_protect', 'api_url')
......@@ -509,6 +550,7 @@ class PortProfileSerializer(NamespacedHMSerializer):
class RoomSerializer(NamespacedHMSerializer):
"""Serialize `topologie.models.Room` objects
"""
class Meta:
model = topologie.Room
fields = ('name', 'details', 'api_url')
......@@ -576,11 +618,12 @@ class AdherentSerializer(NamespacedHMSerializer):
fields = ('name', 'surname', 'pseudo', 'email', 'local_email_redirect',
'local_email_enabled', 'school', 'shell', 'comment',
'state', 'registered', 'telephone', 'room', 'solde',
'access', 'end_access', 'uid', 'api_url','gid')
'access', 'end_access', 'uid', 'api_url', 'gid')
extra_kwargs = {
'shell': {'view_name': 'shell-detail'}
}
class HomeCreationSerializer(NamespacedHMSerializer):
"""Serialize 'users.models.User' minimal infos to create home
"""
......@@ -591,9 +634,11 @@ class HomeCreationSerializer(NamespacedHMSerializer):
model = users.User
fields = ('pseudo', 'uid', 'gid')
class ServiceUserSerializer(NamespacedHMSerializer):
"""Serialize `users.models.ServiceUser` objects.
"""
class Meta:
model = users.ServiceUser
fields = ('pseudo', 'access_group', 'comment', 'api_url')
......@@ -602,6 +647,7 @@ class ServiceUserSerializer(NamespacedHMSerializer):
class SchoolSerializer(NamespacedHMSerializer):
"""Serialize `users.models.School` objects.
"""
class Meta:
model = users.School
fields = ('name', 'api_url')
......@@ -610,6 +656,7 @@ class SchoolSerializer(NamespacedHMSerializer):
class ListRightSerializer(NamespacedHMSerializer):
"""Serialize `users.models.ListRight` objects.
"""
class Meta:
model = users.ListRight
fields = ('unix_name', 'gid', 'critical', 'details', 'api_url')
......@@ -618,6 +665,7 @@ class ListRightSerializer(NamespacedHMSerializer):
class ShellSerializer(NamespacedHMSerializer):
"""Serialize `users.models.ListShell` objects.
"""
class Meta:
model = users.ListShell
fields = ('shell', 'api_url')
......@@ -651,6 +699,7 @@ class EMailAddressSerializer(NamespacedHMSerializer):
"""Serialize `users.models.EMailAddress` objects.
"""
user = serializers.CharField(source='user.pseudo', read_only=True)
class Meta:
model = users.EMailAddress
fields = ('user', 'local_part', 'complete_email_address', 'api_url')
......@@ -706,7 +755,7 @@ class RoleSerializer(NamespacedHMSerializer):
class VlanPortSerializer(NamespacedHMSerializer):
class Meta:
model = machines.Vlan
fields = ('vlan_id', 'name')
fields = ('vlan_id', 'name')
class ProfilSerializer(NamespacedHMSerializer):
......@@ -772,13 +821,14 @@ class LocalEmailUsersSerializer(NamespacedHMSerializer):
'email_address', 'email')
#Firewall
# Firewall
class FirewallPortListSerializer(serializers.ModelSerializer):
class Meta:
model = machines.OuverturePort
fields = ('begin', 'end', 'protocole', 'io', 'show_port')
class FirewallOuverturePortListSerializer(serializers.ModelSerializer):
tcp_ports_in = FirewallPortListSerializer(many=True, read_only=True)
udp_ports_in = FirewallPortListSerializer(many=True, read_only=True)
......@@ -789,6 +839,7 @@ class FirewallOuverturePortListSerializer(serializers.ModelSerializer):
model = machines.OuverturePortList
fields = ('tcp_ports_in', 'udp_ports_in', 'tcp_ports_out', 'udp_ports_out')
class SubnetPortsOpenSerializer(serializers.ModelSerializer):
ouverture_ports = FirewallOuverturePortListSerializer(read_only=True)
......@@ -796,6 +847,7 @@ class SubnetPortsOpenSerializer(serializers.ModelSerializer):
model = machines.IpType
fields = ('type', 'domaine_ip_start', 'domaine_ip_stop', 'complete_prefixv6', 'ouverture_ports')
class InterfacePortsOpenSerializer(serializers.ModelSerializer):
port_lists = FirewallOuverturePortListSerializer(read_only=True, many=True)
ipv4 = serializers.CharField(source='ipv4.ipv4', read_only=True)
......@@ -805,6 +857,7 @@ class InterfacePortsOpenSerializer(serializers.ModelSerializer):
model = machines.Interface
fields = ('port_lists', 'ipv4', 'ipv6')
# DHCP
......@@ -829,6 +882,7 @@ class SOARecordSerializer(SOASerializer):
"""Serialize `machines.models.SOA` objects with the data needed to
generate a SOA DNS record.
"""
class Meta:
model = machines.SOA
fields = ('name', 'mail', 'refresh', 'retry', 'expire', 'ttl')
......@@ -838,6 +892,7 @@ class OriginV4RecordSerializer(IpListSerializer):
"""Serialize `machines.models.IpList` objects with the data needed to
generate an IPv4 Origin DNS record.
"""
class Meta(IpListSerializer.Meta):
fields = ('ipv4',)
......@@ -866,6 +921,7 @@ class TXTRecordSerializer(TxtSerializer):
"""Serialize `machines.models.Txt` objects with the data needed to
generate a TXT DNS record.
"""
class Meta(TxtSerializer.Meta):
fields = ('field1', 'field2')
......@@ -884,6 +940,7 @@ class SSHFPRecordSerializer(SshFpSerializer):
"""Serialize `machines.models.SshFp` objects with the data needed to
generate a SSHFP DNS record.
"""
class Meta(SshFpSerializer.Meta):
fields = ('algo_id', 'hash')
......@@ -990,22 +1047,24 @@ class DNSReverseZonesSerializer(serializers.ModelSerializer):
ptr_records = ARecordSerializer(many=True, source='get_associated_ptr_records')
ptr_v6_records = AAAARecordSerializer(many=True, source='get_associated_ptr_v6_records')
class Meta:
model = machines.IpType
fields = ('type', 'extension', 'soa', 'ns_records', 'mx_records',
'txt_records', 'ptr_records', 'ptr_v6_records', 'cidrs',
'prefix_v6', 'prefix_v6_length')
# MAILING
class MailingMemberSerializer(UserSerializer):
"""Serialize the data about a mailing member.
"""
class Meta(UserSerializer.Meta):
fields = ('name', 'pseudo', 'get_mail')
class MailingSerializer(ClubSerializer):
"""Serialize the data about a mailing.
"""
......
......@@ -48,4 +48,4 @@ API_APPS = (
)
# The expiration time for an authentication token
API_TOKEN_DURATION = 86400 # 24 hours
API_TOKEN_DURATION = 86400 # 24 hours
......@@ -21,10 +21,11 @@
"""Defines the test suite for the API
"""
import json