Commit a6e978f2 authored by Hamza Dely's avatar Hamza Dely
Browse files

[note_kfet/mixins] Déplace le DynamicFieldsMixin dans note_kfet/serializers

parent 0740ad1e
......@@ -6,7 +6,7 @@ from django.contrib.auth.password_validation import validate_password as django_
from rest_framework import serializers
from note_kfet import mixins
from note_kfet.serializers import mixins
from note_kfet.serializers import Base64ImageField
from comptes.models import Section, Alias, Historique, Droit, Accreditation, Adhesion, Adherent
......
......@@ -84,14 +84,3 @@ class NoteMixin(object):
})
return context
class DynamicFieldsMixin(object):
"""
Un mixin permettant de modifier de manière dynamique les champs
utilisés dans un sérialiseur.
"""
def __init__(self, *args, **kwargs):
fields = set(kwargs.pop('fields', []))
super().__init__(*args, **kwargs)
for field in set(self.fields) - fields:
self.fields.pop(field)
......@@ -7,8 +7,18 @@ import binascii
from django.core.files.base import ContentFile
from django.core.validators import EMPTY_VALUES
__all__ = ['Base64FieldMixin']
__all__ = ['Base64FieldMixin', 'DynamicFieldsMixin']
class DynamicFieldsMixin(object):
"""
Un mixin permettant de modifier de manière dynamique les champs
utilisés dans un sérialiseur.
"""
def __init__(self, *args, **kwargs):
fields = set(kwargs.pop('fields', []))
super().__init__(*args, **kwargs)
for field in set(self.fields) - fields:
self.fields.pop(field)
class Base64FieldMixin(object):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment