예제 #1
0
    def get_field_names(self, declared_fields, info):
        """
        Filter out the 'members' field when the user is a employee.

        :param declared_fields: A mapping of the declared fields in order
        :type declared_fields: collections.OrderedDict

        :param info: Additional information about the current models fields
        :type info: rest_framework.utils.model_meta.FieldInfo

        :return: A sequence with the fields to serialize
        :rtype: tuple
        """
        fields = ModelSerializer.get_field_names(self, declared_fields, info)
        if not is_employee(self.context["request"].user, False):
            return fields

        return tuple(field for field in fields if field != "members")
예제 #2
0
 def get_field_names(self, declared_fields, info):
     fields = ModelSerializer.get_field_names(self, declared_fields, info)
     if 'application' in fields:
         fields.remove('application')
     return fields
예제 #3
0
 def get_field_names(self, declared_fields, info):
     fields = ModelSerializer.get_field_names(self, declared_fields, info)
     if 'application' in fields:
         fields.remove('application')
     return fields