mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
API cleanup code
This commit is contained in:
parent
95acdb2ecd
commit
187138f6e3
2 changed files with 244 additions and 606 deletions
|
@ -24,666 +24,419 @@ Serializers for the API app
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from cotisations.models import (
|
import cotisations.models as cotisations
|
||||||
Facture,
|
import machines.models as machines
|
||||||
Vente,
|
import preferences.models as preferences
|
||||||
Article,
|
import topologie.models as topologie
|
||||||
Banque,
|
import users.models as users
|
||||||
Paiement,
|
|
||||||
Cotisation
|
|
||||||
)
|
API_NAMESPACE = 'api'
|
||||||
from machines.models import (
|
|
||||||
Machine,
|
|
||||||
MachineType,
|
class NamespacedHRField(serializers.HyperlinkedRelatedField):
|
||||||
IpType,
|
""" A HyperlinkedRelatedField subclass to automatically prefix
|
||||||
Vlan,
|
view names with a namespace """
|
||||||
Nas,
|
def __init__(self, view_name=None, **kwargs):
|
||||||
SOA,
|
if view_name is not None:
|
||||||
Extension,
|
view_name = '%s:%s' % (API_NAMESPACE, view_name)
|
||||||
Mx,
|
super(NamespacedHRField, self).__init__(view_name=view_name, **kwargs)
|
||||||
Ns,
|
|
||||||
Txt,
|
|
||||||
Srv,
|
class NamespacedHIField(serializers.HyperlinkedIdentityField):
|
||||||
Interface,
|
""" A HyperlinkedIdentityField subclass to automatically prefix
|
||||||
Ipv6List,
|
view names with a namespace """
|
||||||
Domain,
|
def __init__(self, view_name=None, **kwargs):
|
||||||
IpList,
|
if view_name is not None:
|
||||||
Service,
|
view_name = '%s:%s' % (API_NAMESPACE, view_name)
|
||||||
Service_link,
|
super(NamespacedHIField, self).__init__(view_name=view_name, **kwargs)
|
||||||
OuverturePortList,
|
|
||||||
OuverturePort
|
|
||||||
)
|
class NamespacedHMSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
from preferences.models import (
|
""" A HyperlinkedModelSerializer subclass to use `NamespacedHRField` as
|
||||||
OptionalUser,
|
field and automatically prefix view names with a namespace """
|
||||||
OptionalMachine,
|
serializer_related_field = NamespacedHRField
|
||||||
OptionalTopologie,
|
serializer_url_field = NamespacedHIField
|
||||||
GeneralOption,
|
|
||||||
AssoOption,
|
|
||||||
HomeOption,
|
|
||||||
MailMessageOption
|
|
||||||
)
|
|
||||||
# Avoid duplicate names
|
|
||||||
from preferences.models import Service as ServiceOption
|
|
||||||
from topologie.models import (
|
|
||||||
Stack,
|
|
||||||
AccessPoint,
|
|
||||||
Switch,
|
|
||||||
ModelSwitch,
|
|
||||||
ConstructorSwitch,
|
|
||||||
SwitchBay,
|
|
||||||
Building,
|
|
||||||
Room
|
|
||||||
)
|
|
||||||
from topologie.models import Port as SwitchPort
|
|
||||||
from users.models import (
|
|
||||||
User,
|
|
||||||
Club,
|
|
||||||
Adherent,
|
|
||||||
ServiceUser,
|
|
||||||
School,
|
|
||||||
ListRight,
|
|
||||||
ListShell,
|
|
||||||
Ban,
|
|
||||||
Whitelist
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# COTISATIONS APP
|
# COTISATIONS APP
|
||||||
|
|
||||||
class FactureSerializer(serializers.HyperlinkedModelSerializer):
|
|
||||||
|
class FactureSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Facture
|
model = cotisations.Facture
|
||||||
fields = ('user', 'paiement', 'banque', 'cheque', 'date', 'valid',
|
fields = ('user', 'paiement', 'banque', 'cheque', 'date', 'valid',
|
||||||
'control', 'prix_total', 'name', 'api_url')
|
'control', 'prix_total', 'name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'user': {'view_name': 'api:user-detail'},
|
|
||||||
'paiement': {'view_name': 'api:paiement-detail'},
|
|
||||||
'banque': {'view_name': 'api:banque-detail'},
|
|
||||||
'api_url': {'view_name': 'api:facture-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class VenteSerializer(serializers.HyperlinkedModelSerializer):
|
class VenteSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Vente
|
model = cotisations.Vente
|
||||||
fields = ('facture', 'number', 'name', 'prix', 'duration',
|
fields = ('facture', 'number', 'name', 'prix', 'duration',
|
||||||
'type_cotisation', 'prix_total', 'api_url')
|
'type_cotisation', 'prix_total', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'facture': {'view_name': 'api:facture-detail'},
|
|
||||||
'api_url': {'view_name': 'api:vente-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ArticleSerializer(serializers.HyperlinkedModelSerializer):
|
class ArticleSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Article
|
model = cotisations.Article
|
||||||
fields = ('name', 'prix', 'duration', 'type_user',
|
fields = ('name', 'prix', 'duration', 'type_user',
|
||||||
'type_cotisation', 'api_url')
|
'type_cotisation', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:article-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class BanqueSerializer(serializers.HyperlinkedModelSerializer):
|
class BanqueSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Banque
|
model = cotisations.Banque
|
||||||
fields = ('name', 'api_url')
|
fields = ('name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:banque-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class PaiementSerializer(serializers.HyperlinkedModelSerializer):
|
class PaiementSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Paiement
|
model = cotisations.Paiement
|
||||||
fields = ('moyen', 'type_paiement', 'api_url')
|
fields = ('moyen', 'type_paiement', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:paiement-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class CotisationSerializer(serializers.HyperlinkedModelSerializer):
|
class CotisationSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Cotisation
|
model = cotisations.Cotisation
|
||||||
fields = ('vente', 'type_cotisation', 'date_start', 'date_end',
|
fields = ('vente', 'type_cotisation', 'date_start', 'date_end',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'vente': {'view_name': 'api:vente-detail'},
|
|
||||||
'api_url': {'view_name': 'api:cotisation-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# MACHINES APP
|
# MACHINES APP
|
||||||
|
|
||||||
|
|
||||||
class MachineSerializer(serializers.HyperlinkedModelSerializer):
|
class MachineSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Machine
|
model = machines.Machine
|
||||||
fields = ('user', 'name', 'active', 'api_url')
|
fields = ('user', 'name', 'active', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'user': {'view_name': 'api:user-detail'},
|
|
||||||
'api_url': {'view_name': 'api:machine-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MachineTypeSerializer(serializers.HyperlinkedModelSerializer):
|
class MachineTypeSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MachineType
|
model = machines.MachineType
|
||||||
fields = ('type', 'ip_type', 'api_url')
|
fields = ('type', 'ip_type', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'ip_type': {'view_name': 'api:iptype-detail'},
|
|
||||||
'api_url': {'view_name': 'api:machinetype-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class IpTypeSerializer(serializers.HyperlinkedModelSerializer):
|
class IpTypeSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IpType
|
model = machines.IpType
|
||||||
fields = ('type', 'extension', 'need_infra', 'domaine_ip_start',
|
fields = ('type', 'extension', 'need_infra', 'domaine_ip_start',
|
||||||
'domaine_ip_stop', 'prefix_v6', 'vlan', 'ouverture_ports',
|
'domaine_ip_stop', 'prefix_v6', 'vlan', 'ouverture_ports',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'extension': {'view_name': 'api:extension-detail'},
|
|
||||||
'vlan': {'view_name': 'api:vlan-detail'},
|
|
||||||
'ouverture_ports': {'view_name': 'api:ouvertureportlist-detail'},
|
|
||||||
'api_url': {'view_name': 'api:iptype-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class VlanSerializer(serializers.HyperlinkedModelSerializer):
|
class VlanSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Vlan
|
model = machines.Vlan
|
||||||
fields = ('vlan_id', 'name', 'comment', 'api_url')
|
fields = ('vlan_id', 'name', 'comment', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:vlan-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NasSerializer(serializers.HyperlinkedModelSerializer):
|
class NasSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Nas
|
model = machines.Nas
|
||||||
fields = ('name', 'nas_type', 'machine_type', 'port_access_mode',
|
fields = ('name', 'nas_type', 'machine_type', 'port_access_mode',
|
||||||
'autocapture_mac', 'api_url')
|
'autocapture_mac', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'nas_type': {'view_name': 'api:machinetype-detail'},
|
|
||||||
'machine_type': {'view_name': 'api:machinetype-detail'},
|
|
||||||
'api_url': {'view_name': 'api:nas-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SOASerializer(serializers.HyperlinkedModelSerializer):
|
class SOASerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SOA
|
model = machines.SOA
|
||||||
fields = ('name', 'mail', 'refresh', 'retry', 'expire', 'ttl',
|
fields = ('name', 'mail', 'refresh', 'retry', 'expire', 'ttl',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:soa-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ExtensionSerializer(serializers.HyperlinkedModelSerializer):
|
class ExtensionSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Extension
|
model = machines.Extension
|
||||||
fields = ('name', 'need_infra', 'origin', 'origin_v6', 'soa',
|
fields = ('name', 'need_infra', 'origin', 'origin_v6', 'soa',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'origin': {'view_name': 'api:iplist-detail'},
|
|
||||||
'soa': {'view_name': 'api:soa-detail'},
|
|
||||||
'api_url': {'view_name': 'api:extension-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MxSerializer(serializers.HyperlinkedModelSerializer):
|
class MxSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Mx
|
model = machines.Mx
|
||||||
fields = ('zone', 'priority', 'name', 'api_url')
|
fields = ('zone', 'priority', 'name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'zone': {'view_name': 'api:extension-detail'},
|
|
||||||
'name': {'view_name': 'api:domain-detail'},
|
|
||||||
'api_url': {'view_name': 'api:mx-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class NsSerializer(serializers.HyperlinkedModelSerializer):
|
class NsSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ns
|
model = machines.Ns
|
||||||
fields = ('zone', 'ns', 'api_url')
|
fields = ('zone', 'ns', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'zone': {'view_name': 'api:extension-detail'},
|
|
||||||
'ns': {'view_name': 'api:domain-detail'},
|
|
||||||
'api_url': {'view_name': 'api:ns-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TxtSerializer(serializers.HyperlinkedModelSerializer):
|
class TxtSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Txt
|
model = machines.Txt
|
||||||
fields = ('zone', 'field1', 'field2', 'api_url')
|
fields = ('zone', 'field1', 'field2', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'zone': {'view_name': 'api:extension-detail'},
|
|
||||||
'api_url': {'view_name': 'api:txt-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SrvSerializer(serializers.HyperlinkedModelSerializer):
|
class SrvSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Srv
|
model = machines.Srv
|
||||||
fields = ('service', 'protocole', 'extension', 'ttl', 'priority',
|
fields = ('service', 'protocole', 'extension', 'ttl', 'priority',
|
||||||
'weight', 'port', 'target', 'api_url')
|
'weight', 'port', 'target', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'extension': {'view_name': 'api:extension-detail'},
|
|
||||||
'target': {'view_name': 'api:domain-detail'},
|
|
||||||
'api_url': {'view_name': 'api:mx-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class InterfaceSerializer(serializers.HyperlinkedModelSerializer):
|
class InterfaceSerializer(NamespacedHMSerializer):
|
||||||
active = serializers.BooleanField(source='is_active')
|
active = serializers.BooleanField(source='is_active')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = machines.Interface
|
||||||
fields = ('ipv4', 'mac_address', 'machine', 'type', 'details',
|
fields = ('ipv4', 'mac_address', 'machine', 'type', 'details',
|
||||||
'port_lists', 'active', 'api_url')
|
'port_lists', 'active', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'ipv4': {'view_name': 'api:iplist-detail'},
|
|
||||||
'machine': {'view_name': 'api:machine-detail'},
|
|
||||||
'type': {'view_name': 'api:machinetype-detail'},
|
|
||||||
'port_lists': {'view_name': 'api:ouvertureportlist-detail'},
|
|
||||||
'api_url': {'view_name': 'api:interface-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Ipv6ListSerializer(serializers.HyperlinkedModelSerializer):
|
class Ipv6ListSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ipv6List
|
model = machines.Ipv6List
|
||||||
fields = ('ipv6', 'interface', 'slaac_ip', 'date_end',
|
fields = ('ipv6', 'interface', 'slaac_ip', 'date_end',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'interface': {'view_name': 'api:interface-detail'},
|
|
||||||
'api_url': {'view_name': 'api:ipv6list-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class DomainSerializer(serializers.HyperlinkedModelSerializer):
|
class DomainSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Domain
|
model = machines.Domain
|
||||||
fields = ('interface_parent', 'name', 'extension', 'cname',
|
fields = ('interface_parent', 'name', 'extension', 'cname',
|
||||||
'api_url')
|
'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'interface_parent': {'view_name': 'api:interface-detail'},
|
|
||||||
'extension': {'view_name': 'api:extension-detail'},
|
|
||||||
'cname': {'view_name': 'api:domain-detail'},
|
|
||||||
'api_url': {'view_name': 'api:domain-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class IpListSerializer(serializers.HyperlinkedModelSerializer):
|
class IpListSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IpList
|
model = machines.IpList
|
||||||
fields = ('ipv4', 'ip_type', 'need_infra', 'api_url')
|
fields = ('ipv4', 'ip_type', 'need_infra', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'ip_type': {'view_name': 'api:iptype-detail'},
|
|
||||||
'api_url': {'view_name': 'api:iplist-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceSerializer(serializers.HyperlinkedModelSerializer):
|
class ServiceSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Service
|
model = machines.Service
|
||||||
fields = ('service_type', 'min_time_regen', 'regular_time_regen',
|
fields = ('service_type', 'min_time_regen', 'regular_time_regen',
|
||||||
'servers', 'api_url')
|
'servers', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'servers': {'view_name': 'api:interface-detail'},
|
|
||||||
'api_url': {'view_name': 'api:service-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceLinkSerializer(serializers.HyperlinkedModelSerializer):
|
class ServiceLinkSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Service_link
|
model = machines.Service_link
|
||||||
fields = ('service', 'server', 'last_regen', 'asked_regen',
|
fields = ('service', 'server', 'last_regen', 'asked_regen',
|
||||||
'need_regen', 'api_url')
|
'need_regen', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'service': {'view_name': 'api:service-detail'},
|
|
||||||
'server': {'view_name': 'api:interface-detail'},
|
|
||||||
'api_url': {'view_name': 'api:servicelink-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortListSerializer(serializers.HyperlinkedModelSerializer):
|
class OuverturePortListSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OuverturePortList
|
model = machines.OuverturePortList
|
||||||
fields = ('name', 'tcp_ports_in', 'udp_ports_in', 'tcp_ports_out',
|
fields = ('name', 'tcp_ports_in', 'udp_ports_in', 'tcp_ports_out',
|
||||||
'udp_ports_out', 'api_url')
|
'udp_ports_out', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'tcp_ports_in': {'view_name': 'api:ouvertureport-detail'},
|
|
||||||
'udp_ports_in': {'view_name': 'api:ouvertureport-detail'},
|
|
||||||
'tcp_ports_out': {'view_name': 'api:ouvertureport-detail'},
|
|
||||||
'udp_ports_out': {'view_name': 'api:ouvertureport-detail'},
|
|
||||||
'api_url': {'view_name': 'api:ouvertureportlist-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortSerializer(serializers.HyperlinkedModelSerializer):
|
class OuverturePortSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OuverturePort
|
model = machines.OuverturePort
|
||||||
fields = ('begin', 'end', 'port_list', 'protocole', 'io', 'api_url')
|
fields = ('begin', 'end', 'port_list', 'protocole', 'io', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'port_list': {'view_name': 'api:ouvertureportlist-detail'},
|
|
||||||
'api_url': {'view_name': 'api:ouvertureport-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# PREFERENCES APP
|
# PREFERENCES APP
|
||||||
|
|
||||||
|
|
||||||
# class OptionalUserSerializer(serializers.HyperlinkedModelSerializer):
|
# class OptionalUserSerializer(NamespacedHMSerializer):
|
||||||
# tel_mandatory = serializers.BooleanField(source='is_tel_mandatory')
|
# tel_mandatory = serializers.BooleanField(source='is_tel_mandatory')
|
||||||
#
|
#
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = OptionalUser
|
# model = preferences.OptionalUser
|
||||||
# fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde',
|
# fields = ('tel_mandatory', 'user_solde', 'solde_negatif', 'max_solde',
|
||||||
# 'min_online_payement', 'gpg_fingerprint',
|
# 'min_online_payement', 'gpg_fingerprint',
|
||||||
# 'all_can_create_club', 'self_adhesion', 'shell_default',
|
# 'all_can_create_club', 'self_adhesion', 'shell_default',
|
||||||
# 'api_url')
|
# 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'shell_default': {'view_name': 'api:shell-detail'},
|
|
||||||
# 'api_url': {'view_name': 'api:optionaluser-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class OptionalMachineSerializer(serializers.HyperlinkedModelSerializer):
|
# class OptionalMachineSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = OptionalMachine
|
# model = preferences.OptionalMachine
|
||||||
# fields = ('password_machine', 'max_lambdauser_interfaces',
|
# fields = ('password_machine', 'max_lambdauser_interfaces',
|
||||||
# 'max_lambdauser_aliases', 'ipv6_mode', 'create_machine',
|
# 'max_lambdauser_aliases', 'ipv6_mode', 'create_machine',
|
||||||
# 'ipv6', 'api_url')
|
# 'ipv6', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'api_url': {'view_name': 'api:optionalmachine-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class OptionalTopologieSerializer(serializers.HyperlinkedModelSerializer):
|
# class OptionalTopologieSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = OptionalTopologie
|
# model = preferences.OptionalTopologie
|
||||||
# fields = ('radius_general_policy', 'vlan_decision_ok',
|
# fields = ('radius_general_policy', 'vlan_decision_ok',
|
||||||
# 'vlan_decision_no', 'api_url')
|
# 'vlan_decision_no', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'vlan_decision_ok': {'view_name': 'api:vlan-detail'},
|
|
||||||
# 'vlan_decision_nok': {'view_name': 'api:vlan-detail'},
|
|
||||||
# 'api_url': {'view_name': 'api:optionaltopologie-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class GeneralOptionSerializer(serializers.HyperlinkedModelSerializer):
|
# class GeneralOptionSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = GeneralOption
|
# model = preferences.GeneralOption
|
||||||
# fields = ('general_message', 'search_display_page',
|
# fields = ('general_message', 'search_display_page',
|
||||||
# 'pagination_number', 'pagination_large_number',
|
# 'pagination_number', 'pagination_large_number',
|
||||||
# 'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up',
|
# 'req_expire_hrs', 'site_name', 'email_from', 'GTU_sum_up',
|
||||||
# 'GTU', 'api_url')
|
# 'GTU', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'api_url': {'view_name': 'api:generaloption-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class ServiceOptionSerializer(serializers.HyperlinkedModelSerializer):
|
# class ServiceOptionSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = ServiceOption
|
# model = preferences.ServiceOption
|
||||||
# fields = ('name', 'url', 'description', 'image', 'api_url')
|
# fields = ('name', 'url', 'description', 'image', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'api_url': {'view_name': 'api:serviceoption-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class AssoOptionSerializer(serializers.HyperlinkedModelSerializer):
|
# class AssoOptionSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = AssoOption
|
# model = preferences.AssoOption
|
||||||
# fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
|
# fields = ('name', 'siret', 'adresse1', 'adresse2', 'contact',
|
||||||
# 'telephone', 'pseudo', 'utilisateur_asso', 'payement',
|
# 'telephone', 'pseudo', 'utilisateur_asso', 'payement',
|
||||||
# 'payement_id', 'payement_pass', 'description', 'api_url')
|
# 'payement_id', 'payement_pass', 'description', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'utilisateur_asso': {'view_name': 'api:user-detail'},
|
|
||||||
# 'api_url': {'view_name': 'api:assooption-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class HomeOptionSerializer(serializers.HyperlinkedModelSerializer):
|
# class HomeOptionSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = HomeOption
|
# model = preferences.HomeOption
|
||||||
# fields = ('facebook_url', 'twitter_url', 'twitter_account_name',
|
# fields = ('facebook_url', 'twitter_url', 'twitter_account_name',
|
||||||
# 'api_url')
|
# 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'api_url': {'view_name': 'api:homeoption-detail'}
|
|
||||||
# }
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class MailMessageOptionSerializer(serializers.HyperlinkedModelSerializer):
|
# class MailMessageOptionSerializer(NamespacedHMSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = MailMessageOption
|
# model = preferences.MailMessageOption
|
||||||
# fields = ('welcome_mail_fr', 'welcome_mail_en', 'api_url')
|
# fields = ('welcome_mail_fr', 'welcome_mail_en', 'api_url')
|
||||||
# extra_kwargs = {
|
|
||||||
# 'api_url': {'view_name': 'api:mailmessageoption-detail'}
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TOPOLOGIE APP
|
# TOPOLOGIE APP
|
||||||
|
|
||||||
|
|
||||||
class StackSerializer(serializers.HyperlinkedModelSerializer):
|
class StackSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Stack
|
model = topologie.Stack
|
||||||
fields = ('name', 'stack_id', 'details', 'member_id_min',
|
fields = ('name', 'stack_id', 'details', 'member_id_min',
|
||||||
'member_id_max', 'api_url')
|
'member_id_max', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:stack-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AccessPointSerializer(serializers.HyperlinkedModelSerializer):
|
class AccessPointSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AccessPoint
|
model = topologie.AccessPoint
|
||||||
fields = ('user', 'name', 'active', 'location', 'api_url')
|
fields = ('user', 'name', 'active', 'location', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'user': {'view_name': 'api:user-detail'},
|
|
||||||
'api_url': {'view_name': 'api:accesspoint-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SwitchSerializer(serializers.HyperlinkedModelSerializer):
|
class SwitchSerializer(NamespacedHMSerializer):
|
||||||
port_amount = serializers.IntegerField(source='number')
|
port_amount = serializers.IntegerField(source='number')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Switch
|
model = topologie.Switch
|
||||||
fields = ('port_amount', 'stack', 'stack_member_id', 'model',
|
fields = ('port_amount', 'stack', 'stack_member_id', 'model',
|
||||||
'switchbay', 'api_url')
|
'switchbay', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'stack': {'view_name': 'api:stack-detail'},
|
|
||||||
'model': {'view_name': 'api:modelswitch-detail'},
|
|
||||||
'switchbay': {'view_name': 'api:switchbay-detail'},
|
|
||||||
'api_url': {'view_name': 'api:switch-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ModelSwitchSerializer(serializers.HyperlinkedModelSerializer):
|
class ModelSwitchSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ModelSwitch
|
model = topologie.ModelSwitch
|
||||||
fields = ('reference', 'constructor', 'api_url')
|
fields = ('reference', 'constructor', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'constructor': {'view_name': 'api:constructorswitch-detail'},
|
|
||||||
'api_url': {'view_name': 'api:modelswitch-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ConstructorSwitchSerializer(serializers.HyperlinkedModelSerializer):
|
class ConstructorSwitchSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ConstructorSwitch
|
model = topologie.ConstructorSwitch
|
||||||
fields = ('name', 'api_url')
|
fields = ('name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:constructorswitch-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SwitchBaySerializer(serializers.HyperlinkedModelSerializer):
|
class SwitchBaySerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SwitchBay
|
model = topologie.SwitchBay
|
||||||
fields = ('name', 'building', 'info', 'api_url')
|
fields = ('name', 'building', 'info', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'building': {'view_name': 'api:building-detail'},
|
|
||||||
'api_url': {'view_name': 'api:switchbay-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class BuildingSerializer(serializers.HyperlinkedModelSerializer):
|
class BuildingSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Building
|
model = topologie.Building
|
||||||
fields = ('name', 'api_url')
|
fields = ('name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:building-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
|
class SwitchPortSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SwitchPort
|
model = topologie.Port
|
||||||
fields = ('switch', 'port', 'room', 'machine_interface', 'related',
|
fields = ('switch', 'port', 'room', 'machine_interface', 'related',
|
||||||
'radius', 'vlan_force', 'details', 'api_url')
|
'radius', 'vlan_force', 'details', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'switch': {'view_name': 'api:switch-detail'},
|
|
||||||
'room': {'view_name': 'api:room-detail'},
|
|
||||||
'machine_interface': {'view_name': 'api:interface-detail'},
|
|
||||||
'related': {'view_name': 'api:switchport-detail'},
|
|
||||||
'vlan_force': {'view_name': 'api:vlan-detail'},
|
|
||||||
'api_url': {'view_name': 'api:switchport-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class RoomSerializer(serializers.HyperlinkedModelSerializer):
|
class RoomSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Room
|
model = topologie.Room
|
||||||
fields = ('name', 'details', 'api_url')
|
fields = ('name', 'details', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:room-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# USERS APP
|
# USERS APP
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
class UserSerializer(NamespacedHMSerializer):
|
||||||
access = serializers.BooleanField(source='has_access')
|
access = serializers.BooleanField(source='has_access')
|
||||||
uid = serializers.IntegerField(source='uid_number')
|
uid = serializers.IntegerField(source='uid_number')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = users.User
|
||||||
fields = ('name', 'pseudo', 'email', 'school', 'shell', 'comment',
|
fields = ('name', 'pseudo', 'email', 'school', 'shell', 'comment',
|
||||||
'state', 'registered', 'telephone', 'solde', #'room',
|
'state', 'registered', 'telephone', 'solde', #'room',
|
||||||
'access', 'end_access', 'uid', 'class_name', 'api_url')
|
'access', 'end_access', 'uid', 'class_name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'school': {'view_name': 'api:school-detail'},
|
|
||||||
'shell': {'view_name': 'api:shell-detail'},
|
|
||||||
#'room': {'view_name': 'api:room-detail'},
|
|
||||||
'api_url': {'view_name': 'api:user-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ClubSerializer(serializers.HyperlinkedModelSerializer):
|
class ClubSerializer(NamespacedHMSerializer):
|
||||||
name = serializers.CharField(source='surname')
|
name = serializers.CharField(source='surname')
|
||||||
access = serializers.BooleanField(source='has_access')
|
access = serializers.BooleanField(source='has_access')
|
||||||
uid = serializers.IntegerField(source='uid_number')
|
uid = serializers.IntegerField(source='uid_number')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Club
|
model = users.Club
|
||||||
fields = ('name', 'pseudo', 'email', 'school', 'shell', 'comment',
|
fields = ('name', 'pseudo', 'email', 'school', 'shell', 'comment',
|
||||||
'state', 'registered', 'telephone', 'solde', #'room',
|
'state', 'registered', 'telephone', 'solde', #'room',
|
||||||
'access', 'end_access', 'administrators', 'members',
|
'access', 'end_access', 'administrators', 'members',
|
||||||
'mailing', 'uid', 'api_url')
|
'mailing', 'uid', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'school': {'view_name': 'api:school-detail'},
|
|
||||||
'shell': {'view_name': 'api:shell-detail'},
|
|
||||||
#'room': {'view_name': 'api:room-detail'},
|
|
||||||
'administrators': {'view_name': 'api:adherent-detail'},
|
|
||||||
'members': {'view_name': 'api:adherent-detail'},
|
|
||||||
'api_url': {'view_name': 'api:club-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AdherentSerializer(serializers.HyperlinkedModelSerializer):
|
class AdherentSerializer(NamespacedHMSerializer):
|
||||||
access = serializers.BooleanField(source='has_access')
|
access = serializers.BooleanField(source='has_access')
|
||||||
uid = serializers.IntegerField(source='uid_number')
|
uid = serializers.IntegerField(source='uid_number')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Adherent
|
model = users.Adherent
|
||||||
fields = ('name', 'surname', 'pseudo', 'email', 'school', 'shell',
|
fields = ('name', 'surname', 'pseudo', 'email', 'school', 'shell',
|
||||||
'comment', 'state', 'registered', 'telephone', #'room',
|
'comment', 'state', 'registered', 'telephone', #'room',
|
||||||
'solde', 'access', 'end_access', 'uid', 'api_url')
|
'solde', 'access', 'end_access', 'uid', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'school': {'view_name': 'api:school-detail'},
|
|
||||||
'shell': {'view_name': 'api:shell-detail'},
|
|
||||||
#'room': {'view_name': 'api:room-detail'},
|
|
||||||
'api_url': {'view_name': 'api:adherent-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceUserSerializer(serializers.HyperlinkedModelSerializer):
|
class ServiceUserSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ServiceUser
|
model = users.ServiceUser
|
||||||
fields = ('pseudo', 'access_group', 'comment', 'api_url')
|
fields = ('pseudo', 'access_group', 'comment', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:serviceuser-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SchoolSerializer(serializers.HyperlinkedModelSerializer):
|
class SchoolSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = School
|
model = users.School
|
||||||
fields = ('name', 'api_url')
|
fields = ('name', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:school-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ListRightSerializer(serializers.HyperlinkedModelSerializer):
|
class ListRightSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ListRight
|
model = users.ListRight
|
||||||
fields = ('unix_name', 'gid', 'critical', 'details', 'api_url')
|
fields = ('unix_name', 'gid', 'critical', 'details', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:listright-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ShellSerializer(serializers.HyperlinkedModelSerializer):
|
class ShellSerializer(NamespacedHMSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ListShell
|
model = users.ListShell
|
||||||
fields = ('shell', 'api_url')
|
fields = ('shell', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'api_url': {'view_name': 'api:shell-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class BanSerializer(serializers.HyperlinkedModelSerializer):
|
class BanSerializer(NamespacedHMSerializer):
|
||||||
active = serializers.BooleanField(source='is_active')
|
active = serializers.BooleanField(source='is_active')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ban
|
model = users.Ban
|
||||||
fields = ('user', 'raison', 'date_start', 'date_end', 'state',
|
fields = ('user', 'raison', 'date_start', 'date_end', 'state',
|
||||||
'active', 'api_url')
|
'active', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'user': {'view_name': 'api:user-detail'},
|
|
||||||
'api_url': {'view_name': 'api:ban-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class WhitelistSerializer(serializers.HyperlinkedModelSerializer):
|
class WhitelistSerializer(NamespacedHMSerializer):
|
||||||
active = serializers.BooleanField(source='is_active')
|
active = serializers.BooleanField(source='is_active')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Whitelist
|
model = users.Whitelist
|
||||||
fields = ('user', 'raison', 'date_start', 'date_end', 'active', 'api_url')
|
fields = ('user', 'raison', 'date_start', 'date_end', 'active', 'api_url')
|
||||||
extra_kwargs = {
|
|
||||||
'user': {'view_name': 'api:user-detail'},
|
|
||||||
'api_url': {'view_name': 'api:whitelist-detail'}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
331
api/views.py
331
api/views.py
|
@ -33,397 +33,282 @@ from rest_framework.authtoken.models import Token
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework import viewsets, status
|
from rest_framework import viewsets, status
|
||||||
|
|
||||||
|
import cotisations.models as cotisations
|
||||||
|
import machines.models as machines
|
||||||
|
import preferences.models as preferences
|
||||||
|
import topologie.models as topologie
|
||||||
|
import users.models as users
|
||||||
|
|
||||||
from cotisations.models import (
|
from . import serializers
|
||||||
Facture,
|
|
||||||
Vente,
|
|
||||||
Article,
|
|
||||||
Banque,
|
|
||||||
Paiement,
|
|
||||||
Cotisation
|
|
||||||
)
|
|
||||||
from machines.models import (
|
|
||||||
Machine,
|
|
||||||
MachineType,
|
|
||||||
IpType,
|
|
||||||
Vlan,
|
|
||||||
Nas,
|
|
||||||
SOA,
|
|
||||||
Extension,
|
|
||||||
Mx,
|
|
||||||
Ns,
|
|
||||||
Txt,
|
|
||||||
Srv,
|
|
||||||
Interface,
|
|
||||||
Ipv6List,
|
|
||||||
Domain,
|
|
||||||
IpList,
|
|
||||||
Service,
|
|
||||||
Service_link,
|
|
||||||
OuverturePortList,
|
|
||||||
OuverturePort
|
|
||||||
)
|
|
||||||
# from preferences.models import (
|
|
||||||
# OptionalUser,
|
|
||||||
# OptionalMachine,
|
|
||||||
# OptionalTopologie,
|
|
||||||
# GeneralOption,
|
|
||||||
# AssoOption,
|
|
||||||
# HomeOption,
|
|
||||||
# MailMessageOption
|
|
||||||
# )
|
|
||||||
# # Avoid duplicate names
|
|
||||||
# from preferences.models import Service as ServiceOption
|
|
||||||
from topologie.models import (
|
|
||||||
Stack,
|
|
||||||
AccessPoint,
|
|
||||||
Switch,
|
|
||||||
ModelSwitch,
|
|
||||||
ConstructorSwitch,
|
|
||||||
SwitchBay,
|
|
||||||
Building,
|
|
||||||
Room
|
|
||||||
)
|
|
||||||
from topologie.models import Port as SwitchPort
|
|
||||||
from users.models import (
|
|
||||||
User,
|
|
||||||
Club,
|
|
||||||
Adherent,
|
|
||||||
ServiceUser,
|
|
||||||
School,
|
|
||||||
ListRight,
|
|
||||||
ListShell,
|
|
||||||
Ban,
|
|
||||||
Whitelist
|
|
||||||
)
|
|
||||||
|
|
||||||
from .serializers import (
|
|
||||||
# COTISATIONS APP
|
|
||||||
FactureSerializer,
|
|
||||||
VenteSerializer,
|
|
||||||
ArticleSerializer,
|
|
||||||
BanqueSerializer,
|
|
||||||
PaiementSerializer,
|
|
||||||
CotisationSerializer,
|
|
||||||
# MACHINES APP
|
|
||||||
MachineSerializer,
|
|
||||||
MachineTypeSerializer,
|
|
||||||
IpTypeSerializer,
|
|
||||||
VlanSerializer,
|
|
||||||
NasSerializer,
|
|
||||||
SOASerializer,
|
|
||||||
ExtensionSerializer,
|
|
||||||
MxSerializer,
|
|
||||||
NsSerializer,
|
|
||||||
TxtSerializer,
|
|
||||||
SrvSerializer,
|
|
||||||
InterfaceSerializer,
|
|
||||||
Ipv6ListSerializer,
|
|
||||||
DomainSerializer,
|
|
||||||
IpListSerializer,
|
|
||||||
ServiceSerializer,
|
|
||||||
ServiceLinkSerializer,
|
|
||||||
OuverturePortListSerializer,
|
|
||||||
OuverturePortSerializer,
|
|
||||||
# PREFERENCES APP
|
|
||||||
# OptionalUserSerializer,
|
|
||||||
# OptionalMachineSerializer,
|
|
||||||
# OptionalTopologieSerializer,
|
|
||||||
# GeneralOptionSerializer,
|
|
||||||
# ServiceOptionSerializer,
|
|
||||||
# AssoOptionSerializer,
|
|
||||||
# HomeOptionSerializer,
|
|
||||||
# MailMessageOptionSerializer,
|
|
||||||
# TOPOLOGIE APP
|
|
||||||
StackSerializer,
|
|
||||||
AccessPointSerializer,
|
|
||||||
SwitchSerializer,
|
|
||||||
ModelSwitchSerializer,
|
|
||||||
ConstructorSwitchSerializer,
|
|
||||||
SwitchBaySerializer,
|
|
||||||
BuildingSerializer,
|
|
||||||
SwitchPortSerializer,
|
|
||||||
RoomSerializer,
|
|
||||||
# USERS APP
|
|
||||||
UserSerializer,
|
|
||||||
ClubSerializer,
|
|
||||||
AdherentSerializer,
|
|
||||||
ServiceUserSerializer,
|
|
||||||
SchoolSerializer,
|
|
||||||
ListRightSerializer,
|
|
||||||
ShellSerializer,
|
|
||||||
BanSerializer,
|
|
||||||
WhitelistSerializer
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# COTISATIONS APP
|
# COTISATIONS APP
|
||||||
|
|
||||||
|
|
||||||
class FactureViewSet(viewsets.ReadOnlyModelViewSet):
|
class FactureViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Facture.objects.all()
|
queryset = cotisations.Facture.objects.all()
|
||||||
serializer_class = FactureSerializer
|
serializer_class = serializers.FactureSerializer
|
||||||
|
|
||||||
|
|
||||||
class VenteViewSet(viewsets.ReadOnlyModelViewSet):
|
class VenteViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Vente.objects.all()
|
queryset = cotisations.Vente.objects.all()
|
||||||
serializer_class = VenteSerializer
|
serializer_class = serializers.VenteSerializer
|
||||||
|
|
||||||
|
|
||||||
class ArticleViewSet(viewsets.ReadOnlyModelViewSet):
|
class ArticleViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Article.objects.all()
|
queryset = cotisations.Article.objects.all()
|
||||||
serializer_class = ArticleSerializer
|
serializer_class = serializers.ArticleSerializer
|
||||||
|
|
||||||
|
|
||||||
class BanqueViewSet(viewsets.ReadOnlyModelViewSet):
|
class BanqueViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Banque.objects.all()
|
queryset = cotisations.Banque.objects.all()
|
||||||
serializer_class = BanqueSerializer
|
serializer_class = serializers.BanqueSerializer
|
||||||
|
|
||||||
|
|
||||||
class PaiementViewSet(viewsets.ReadOnlyModelViewSet):
|
class PaiementViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Paiement.objects.all()
|
queryset = cotisations.Paiement.objects.all()
|
||||||
serializer_class = PaiementSerializer
|
serializer_class = serializers.PaiementSerializer
|
||||||
|
|
||||||
|
|
||||||
class CotisationViewSet(viewsets.ReadOnlyModelViewSet):
|
class CotisationViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Cotisation.objects.all()
|
queryset = cotisations.Cotisation.objects.all()
|
||||||
serializer_class = CotisationSerializer
|
serializer_class = serializers.CotisationSerializer
|
||||||
|
|
||||||
|
|
||||||
# MACHINES APP
|
# MACHINES APP
|
||||||
|
|
||||||
|
|
||||||
class MachineViewSet(viewsets.ReadOnlyModelViewSet):
|
class MachineViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Machine.objects.all()
|
queryset = machines.Machine.objects.all()
|
||||||
serializer_class = MachineSerializer
|
serializer_class = serializers.MachineSerializer
|
||||||
|
|
||||||
|
|
||||||
class MachineTypeViewSet(viewsets.ReadOnlyModelViewSet):
|
class MachineTypeViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = MachineType.objects.all()
|
queryset = machines.MachineType.objects.all()
|
||||||
serializer_class = MachineTypeSerializer
|
serializer_class = serializers.MachineTypeSerializer
|
||||||
|
|
||||||
|
|
||||||
class IpTypeViewSet(viewsets.ReadOnlyModelViewSet):
|
class IpTypeViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = IpType.objects.all()
|
queryset = machines.IpType.objects.all()
|
||||||
serializer_class = IpTypeSerializer
|
serializer_class = serializers.IpTypeSerializer
|
||||||
|
|
||||||
|
|
||||||
class VlanViewSet(viewsets.ReadOnlyModelViewSet):
|
class VlanViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Vlan.objects.all()
|
queryset = machines.Vlan.objects.all()
|
||||||
serializer_class = VlanSerializer
|
serializer_class = serializers.VlanSerializer
|
||||||
|
|
||||||
|
|
||||||
class NasViewSet(viewsets.ReadOnlyModelViewSet):
|
class NasViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Nas.objects.all()
|
queryset = machines.Nas.objects.all()
|
||||||
serializer_class = NasSerializer
|
serializer_class = serializers.NasSerializer
|
||||||
|
|
||||||
|
|
||||||
class SOAViewSet(viewsets.ReadOnlyModelViewSet):
|
class SOAViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = SOA.objects.all()
|
queryset = machines.SOA.objects.all()
|
||||||
serializer_class = SOASerializer
|
serializer_class = serializers.SOASerializer
|
||||||
|
|
||||||
|
|
||||||
class ExtensionViewSet(viewsets.ReadOnlyModelViewSet):
|
class ExtensionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Extension.objects.all()
|
queryset = machines.Extension.objects.all()
|
||||||
serializer_class = ExtensionSerializer
|
serializer_class = serializers.ExtensionSerializer
|
||||||
|
|
||||||
|
|
||||||
class MxViewSet(viewsets.ReadOnlyModelViewSet):
|
class MxViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Mx.objects.all()
|
queryset = machines.Mx.objects.all()
|
||||||
serializer_class = MxSerializer
|
serializer_class = serializers.MxSerializer
|
||||||
|
|
||||||
|
|
||||||
class NsViewSet(viewsets.ReadOnlyModelViewSet):
|
class NsViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Ns.objects.all()
|
queryset = machines.Ns.objects.all()
|
||||||
serializer_class = NsSerializer
|
serializer_class = serializers.NsSerializer
|
||||||
|
|
||||||
|
|
||||||
class TxtViewSet(viewsets.ReadOnlyModelViewSet):
|
class TxtViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Txt.objects.all()
|
queryset = machines.Txt.objects.all()
|
||||||
serializer_class = TxtSerializer
|
serializer_class = serializers.TxtSerializer
|
||||||
|
|
||||||
|
|
||||||
class SrvViewSet(viewsets.ReadOnlyModelViewSet):
|
class SrvViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Srv.objects.all()
|
queryset = machines.Srv.objects.all()
|
||||||
serializer_class = SrvSerializer
|
serializer_class = serializers.SrvSerializer
|
||||||
|
|
||||||
|
|
||||||
class InterfaceViewSet(viewsets.ReadOnlyModelViewSet):
|
class InterfaceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Interface.objects.all()
|
queryset = machines.Interface.objects.all()
|
||||||
serializer_class = InterfaceSerializer
|
serializer_class = serializers.InterfaceSerializer
|
||||||
|
|
||||||
|
|
||||||
class Ipv6ListViewSet(viewsets.ReadOnlyModelViewSet):
|
class Ipv6ListViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Ipv6List.objects.all()
|
queryset = machines.Ipv6List.objects.all()
|
||||||
serializer_class = Ipv6ListSerializer
|
serializer_class = serializers.Ipv6ListSerializer
|
||||||
|
|
||||||
|
|
||||||
class DomainViewSet(viewsets.ReadOnlyModelViewSet):
|
class DomainViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Domain.objects.all()
|
queryset = machines.Domain.objects.all()
|
||||||
serializer_class = DomainSerializer
|
serializer_class = serializers.DomainSerializer
|
||||||
|
|
||||||
|
|
||||||
class IpListViewSet(viewsets.ReadOnlyModelViewSet):
|
class IpListViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = IpList.objects.all()
|
queryset = machines.IpList.objects.all()
|
||||||
serializer_class = IpListSerializer
|
serializer_class = serializers.IpListSerializer
|
||||||
|
|
||||||
|
|
||||||
class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Service.objects.all()
|
queryset = machines.Service.objects.all()
|
||||||
serializer_class = ServiceSerializer
|
serializer_class = serializers.ServiceSerializer
|
||||||
|
|
||||||
|
|
||||||
class ServiceLinkViewSet(viewsets.ReadOnlyModelViewSet):
|
class ServiceLinkViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Service_link.objects.all()
|
queryset = machines.Service_link.objects.all()
|
||||||
serializer_class = ServiceLinkSerializer
|
serializer_class = serializers.ServiceLinkSerializer
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortListViewSet(viewsets.ReadOnlyModelViewSet):
|
class OuverturePortListViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = OuverturePortList.objects.all()
|
queryset = machines.OuverturePortList.objects.all()
|
||||||
serializer_class = OuverturePortListSerializer
|
serializer_class = serializers.OuverturePortListSerializer
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortViewSet(viewsets.ReadOnlyModelViewSet):
|
class OuverturePortViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = OuverturePort.objects.all()
|
queryset = machines.OuverturePort.objects.all()
|
||||||
serializer_class = OuverturePortSerializer
|
serializer_class = serializers.OuverturePortSerializer
|
||||||
|
|
||||||
|
|
||||||
# PREFERENCES APP
|
# PREFERENCES APP
|
||||||
|
|
||||||
# class OptionalUserViewSet(viewsets.ReadOnlyModelViewSet):
|
# class OptionalUserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = OptionalUser.objects.all()
|
# queryset = preferences.OptionalUser.objects.all()
|
||||||
# serializer_class = OptionalUserSerializer
|
# serializer_class = serializers.OptionalUserSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class OptionalMachineViewSet(viewsets.ReadOnlyModelViewSet):
|
# class OptionalMachineViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = OptionalMachine.objects.all()
|
# queryset = preferences.OptionalMachine.objects.all()
|
||||||
# serializer_class = OptionalMachineSerializer
|
# serializer_class = serializers.OptionalMachineSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class OptionalTopologieViewSet(viewsets.ReadOnlyModelViewSet):
|
# class OptionalTopologieViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = OptionalTopologie.objects.all()
|
# queryset = preferences.OptionalTopologie.objects.all()
|
||||||
# serializer_class = OptionalTopologieSerializer
|
# serializer_class = serializers.OptionalTopologieSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class GeneralOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
# class GeneralOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = GeneralOption.objects.all()
|
# queryset = preferences.GeneralOption.objects.all()
|
||||||
# serializer_class = GeneralOptionSerializer
|
# serializer_class = serializers.GeneralOptionSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class ServiceOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
# class ServiceOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = ServiceOption.objects.all()
|
# queryset = preferences.ServiceOption.objects.all()
|
||||||
# serializer_class = ServiceOptionSerializer
|
# serializer_class = serializers.ServiceOptionSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
# class AssoOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = AssoOption.objects.all()
|
# queryset = preferences.AssoOption.objects.all()
|
||||||
# serializer_class = AssoOptionSerializer
|
# serializer_class = serializers.AssoOptionSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
# class HomeOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = HomeOption.objects.all()
|
# queryset = preferences.HomeOption.objects.all()
|
||||||
# serializer_class = HomeOptionSerializer
|
# serializer_class = serializers.HomeOptionSerializer
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# class MailMessageOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
# class MailMessageOptionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
# queryset = MailMessageOption.objects.all()
|
# queryset = preferences.MailMessageOption.objects.all()
|
||||||
# serializer_class = MailMessageOptionSerializer
|
# serializer_class = serializers.MailMessageOptionSerializer
|
||||||
|
|
||||||
|
|
||||||
# TOPOLOGIE APP
|
# TOPOLOGIE APP
|
||||||
|
|
||||||
|
|
||||||
class StackViewSet(viewsets.ReadOnlyModelViewSet):
|
class StackViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Stack.objects.all()
|
queryset = topologie.Stack.objects.all()
|
||||||
serializer_class = StackSerializer
|
serializer_class = serializers.StackSerializer
|
||||||
|
|
||||||
|
|
||||||
class AccessPointViewSet(viewsets.ReadOnlyModelViewSet):
|
class AccessPointViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = AccessPoint.objects.all()
|
queryset = topologie.AccessPoint.objects.all()
|
||||||
serializer_class = AccessPointSerializer
|
serializer_class = serializers.AccessPointSerializer
|
||||||
|
|
||||||
|
|
||||||
class SwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
class SwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Switch.objects.all()
|
queryset = topologie.Switch.objects.all()
|
||||||
serializer_class = SwitchSerializer
|
serializer_class = serializers.SwitchSerializer
|
||||||
|
|
||||||
|
|
||||||
class ModelSwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
class ModelSwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = ModelSwitch.objects.all()
|
queryset = topologie.ModelSwitch.objects.all()
|
||||||
serializer_class = ModelSwitchSerializer
|
serializer_class = serializers.ModelSwitchSerializer
|
||||||
|
|
||||||
|
|
||||||
class ConstructorSwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
class ConstructorSwitchViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = ConstructorSwitch.objects.all()
|
queryset = topologie.ConstructorSwitch.objects.all()
|
||||||
serializer_class = ConstructorSwitchSerializer
|
serializer_class = serializers.ConstructorSwitchSerializer
|
||||||
|
|
||||||
|
|
||||||
class SwitchBayViewSet(viewsets.ReadOnlyModelViewSet):
|
class SwitchBayViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = SwitchBay.objects.all()
|
queryset = topologie.SwitchBay.objects.all()
|
||||||
serializer_class = SwitchBaySerializer
|
serializer_class = serializers.SwitchBaySerializer
|
||||||
|
|
||||||
|
|
||||||
class BuildingViewSet(viewsets.ReadOnlyModelViewSet):
|
class BuildingViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Building.objects.all()
|
queryset = topologie.Building.objects.all()
|
||||||
serializer_class = BuildingSerializer
|
serializer_class = serializers.BuildingSerializer
|
||||||
|
|
||||||
|
|
||||||
class SwitchPortViewSet(viewsets.ReadOnlyModelViewSet):
|
class SwitchPortViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = SwitchPort.objects.all()
|
queryset = topologie.Port.objects.all()
|
||||||
serializer_class = SwitchPortSerializer
|
serializer_class = serializers.SwitchPortSerializer
|
||||||
|
|
||||||
|
|
||||||
class RoomViewSet(viewsets.ReadOnlyModelViewSet):
|
class RoomViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Room.objects.all()
|
queryset = topologie.Room.objects.all()
|
||||||
serializer_class = RoomSerializer
|
serializer_class = serializers.RoomSerializer
|
||||||
|
|
||||||
|
|
||||||
# USER APP
|
# USER APP
|
||||||
|
|
||||||
|
|
||||||
class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
class UserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = User.objects.all()
|
queryset = users.User.objects.all()
|
||||||
serializer_class = UserSerializer
|
serializer_class = serializers.UserSerializer
|
||||||
|
|
||||||
|
|
||||||
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
class ClubViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Club.objects.all()
|
queryset = users.Club.objects.all()
|
||||||
serializer_class = ClubSerializer
|
serializer_class = serializers.ClubSerializer
|
||||||
|
|
||||||
|
|
||||||
class AdherentViewSet(viewsets.ReadOnlyModelViewSet):
|
class AdherentViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Adherent.objects.all()
|
queryset = users.Adherent.objects.all()
|
||||||
serializer_class = AdherentSerializer
|
serializer_class = serializers.AdherentSerializer
|
||||||
|
|
||||||
|
|
||||||
class ServiceUserViewSet(viewsets.ReadOnlyModelViewSet):
|
class ServiceUserViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = ServiceUser.objects.all()
|
queryset = users.ServiceUser.objects.all()
|
||||||
serializer_class = ServiceUserSerializer
|
serializer_class = serializers.ServiceUserSerializer
|
||||||
|
|
||||||
|
|
||||||
class SchoolViewSet(viewsets.ReadOnlyModelViewSet):
|
class SchoolViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = School.objects.all()
|
queryset = users.School.objects.all()
|
||||||
serializer_class = SchoolSerializer
|
serializer_class = serializers.SchoolSerializer
|
||||||
|
|
||||||
|
|
||||||
class ListRightViewSet(viewsets.ReadOnlyModelViewSet):
|
class ListRightViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = ListRight.objects.all()
|
queryset = users.ListRight.objects.all()
|
||||||
serializer_class = ListRightSerializer
|
serializer_class = serializers.ListRightSerializer
|
||||||
|
|
||||||
|
|
||||||
class ShellViewSet(viewsets.ReadOnlyModelViewSet):
|
class ShellViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = ListShell.objects.all()
|
queryset = users.ListShell.objects.all()
|
||||||
serializer_class = ShellSerializer
|
serializer_class = serializers.ShellSerializer
|
||||||
|
|
||||||
|
|
||||||
class BanViewSet(viewsets.ReadOnlyModelViewSet):
|
class BanViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Ban.objects.all()
|
queryset = users.Ban.objects.all()
|
||||||
serializer_class = BanSerializer
|
serializer_class = serializers.BanSerializer
|
||||||
|
|
||||||
|
|
||||||
class WhitelistViewSet(viewsets.ReadOnlyModelViewSet):
|
class WhitelistViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
queryset = Whitelist.objects.all()
|
queryset = users.Whitelist.objects.all()
|
||||||
serializer_class = WhitelistSerializer
|
serializer_class = serializers.WhitelistSerializer
|
||||||
|
|
||||||
# Subclass the standard rest_framework.auth_token.views.ObtainAuthToken
|
# Subclass the standard rest_framework.auth_token.views.ObtainAuthToken
|
||||||
# in order to renew the lease of the token and add expiration time
|
# in order to renew the lease of the token and add expiration time
|
||||||
|
|
Loading…
Reference in a new issue