示例#1
0
class ProjectRoleSerializer(serializers.ModelSerializer):
    exo_role = CategoryExORoleSerializer()
    project = serializers.HiddenField(default=CurrentProjectDefault())

    class Meta:
        model = ProjectRole
        fields = ['exo_role', 'project']
示例#2
0
class UserInTeamSerializer(serializers.ModelSerializer):
    name = serializers.CharField(source='team.name')
    exo_role = CategoryExORoleSerializer(source='team_role.exo_role')
    team_pk = serializers.IntegerField(source='team.pk')

    class Meta:
        model = UserTeamRole
        fields = ['name', 'exo_role', 'pk', 'team_pk']
示例#3
0
class TeamRoleSerializer(serializers.ModelSerializer):
    project = serializers.HiddenField(
        default=CurrentProjectDefault())
    exo_role = CategoryExORoleSerializer()

    class Meta:
        model = ProjectTeamRole
        fields = ['pk', 'project', 'exo_role']
 def get_project_roles(self, obj):
     COACH_OR_PARTICIPANT = [
         settings.EXO_ROLE_CODE_SPRINT_COACH,
         settings.EXO_ROLE_CODE_SPRINT_PARTICIPANT,
     ]
     queryset = obj.user_project_roles.filter(
         project_role__code__in=COACH_OR_PARTICIPANT).exo_roles()
     return CategoryExORoleSerializer(queryset, many=True).data
示例#5
0
class JobSerializer(serializers.ModelSerializer):
    category = ExORoleCategorySerializer()
    exo_role = CategoryExORoleSerializer()

    class Meta:
        model = Job
        fields = [
            'pk',
            'uuid',
            'category',
            'title',
            'start',
            'end',
            'status',
            'status_detail',
            'exo_role',
            'url',
            'extra_data',
        ]
示例#6
0
 def get_project_roles(self, obj):
     user = self.context.get('request').user
     exo_roles = user.user_project_roles.filter(
         project_role__project=obj).exo_roles()
     return CategoryExORoleSerializer(exo_roles, many=True).data
示例#7
0
class TeamRoleSimpleSerializer(serializers.ModelSerializer):
    exo_role = CategoryExORoleSerializer()

    class Meta:
        model = ProjectTeamRole
        fields = ['exo_role', 'pk']
示例#8
0
 def get_roles(self, obj):
     user = self.context.get('request').user
     queryset = obj.user_team_roles.filter(user=user).exo_roles()
     return CategoryExORoleSerializer(queryset, many=True).data
 def get_project_roles(self, obj):
     project = self.context.get('view').project
     queryset = obj.user_project_roles.filter(
         project_role__project=project).exo_roles()
     return CategoryExORoleSerializer(queryset, many=True).data