<s> from ralph . accounts . api_simple import SimpleRalphUserSerializer <EOL> from ralph . api import RalphAPISerializer , RalphAPIViewSet , router <EOL> from ralph . api . serializers import ReversionHistoryAPISerializerMixin <EOL> from ralph . assets . api . serializers import BaseObjectSerializer <EOL> from ralph . licences . models import ( <EOL> BaseObjectLicence , <EOL> Licence , <EOL> LicenceType , <EOL> LicenceUser , <EOL> Software <EOL> ) <EOL> class LicenceTypeSerializer ( RalphAPISerializer ) : <EOL> class Meta : <EOL> model = LicenceType <EOL> class LicenceUserSerializer ( RalphAPISerializer ) : <EOL> user = SimpleRalphUserSerializer ( ) <EOL> class Meta : <EOL> model = LicenceUser <EOL> class BaseObjectLicenceSerializer ( <EOL> ReversionHistoryAPISerializerMixin , <EOL> RalphAPISerializer <EOL> ) : <EOL> class Meta : <EOL> model = BaseObjectLicence <EOL> def validate ( self , data ) : <EOL> base_object_licence = BaseObjectLicence ( ** data ) <EOL> base_object_licence . clean ( ) <EOL> return data <EOL> class LicenceSerializer ( BaseObjectSerializer ) : <EOL> base_objects = BaseObjectLicenceSerializer ( <EOL> many = True , read_only = True , source = '<STR_LIT>' <EOL> ) <EOL> users = LicenceUserSerializer ( <EOL> many = True , read_only = True , source = '<STR_LIT>' <EOL> ) <EOL> class Meta : <EOL> model = Licence <EOL> depth = <NUM_LIT:1> <EOL> exclude = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class SoftwareSerializer ( RalphAPISerializer ) : <EOL> class Meta : <EOL> model = Software <EOL> class BaseObjectLicenceViewSet ( RalphAPIViewSet ) : <EOL> queryset = BaseObjectLicence . objects . all ( ) <EOL> serializer_class = BaseObjectLicenceSerializer <EOL> select_related = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> save_serializer_class = BaseObjectLicenceSerializer <EOL> class LicenceTypeViewSet ( RalphAPIViewSet ) : <EOL> queryset = LicenceType . objects . all ( ) <EOL> serializer_class = LicenceTypeSerializer <EOL> class LicenceViewSet ( RalphAPIViewSet ) : <EOL> queryset = Licence . objects . all ( ) <EOL> serializer_class = LicenceSerializer <EOL> select_related = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> prefetch_related = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> class LicenceUserViewSet ( RalphAPIViewSet ) : <EOL> queryset = LicenceUser . objects . all ( ) <EOL> serializer_class = LicenceUserSerializer <EOL> select_related = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:user>' <EOL> ] <EOL> class SoftwareViewSet ( RalphAPIViewSet ) : <EOL> queryset = Software . objects . all ( ) <EOL> serializer_class = SoftwareSerializer <EOL> router . register ( r'<STR_LIT>' , BaseObjectLicenceViewSet ) <EOL> router . register ( r'<STR_LIT>' , LicenceViewSet ) <EOL> router . register ( r'<STR_LIT>' , LicenceTypeViewSet ) <EOL> router . register ( r'<STR_LIT>' , LicenceUserViewSet ) <EOL> router . register ( r'<STR_LIT>' , SoftwareViewSet ) <EOL> urlpatterns = [ ] </s>
