Beispiel #1
0
 def tasks(self, request, pk=None):
     if request.method == 'POST' or request.method == 'PUT':
         items = get_task_items(self.get_object())
         for i in items:
             if i['item'] == request.data['type']:
                 item = apps.get_model(app_label=i['app'],
                                       model_name=i['model']).objects.get(
                                           id=request.data['item']['id'])
                 i['s_model'].add(item) if request.method == 'POST' else i[
                     's_model'].remove(item)
                 break
         return Response(request.data['item'],
                         status=status.HTTP_201_CREATED)
     return Response({
         'preboarding':
         PreboardingUserSerializer(
             PreboardingUser.objects.filter(user=self.get_object()),
             many=True).data,
         'to_do':
         ToDoUserSerializer(ToDoUser.objects.filter(user=self.get_object()),
                            many=True).data,
         'resources':
         NewHireResourceItemSerializer(
             ResourceUser.objects.filter(user=self.get_object()),
             many=True).data,
         'introductions':
         IntroductionSerializer(self.get_object().introductions,
                                many=True).data,
         'appointments':
         AppointmentSerializer(self.get_object().appointments,
                               many=True).data,
         'conditions':
         ConditionSerializer(self.get_object().conditions, many=True).data
     })
class TaskSerializer(serializers.ModelSerializer):
    resources = ResourceSerializer(many=True, read_only=True)
    to_do = ToDoSerializer(many=True, read_only=True)
    introductions = IntroductionSerializer(many=True, read_only=True)
    appointments = AppointmentSerializer(many=True, read_only=True)
    preboarding = PreboardingSerializer(many=True, read_only=True)

    class Meta:
        model = get_user_model()
        fields = ('preboarding', 'to_do', 'resources', 'introductions',
                  'appointments')
Beispiel #3
0
class ConditionSerializer(serializers.ModelSerializer):
    condition_to_do = ToDoSerializer(many=True, read_only=True)
    to_do = ToDoSerializer(many=True)
    badges = BadgeSerializer(many=True)
    resources = ResourceSerializer(many=True)
    admin_tasks = PendingAdminTaskSerializer(many=True)
    external_messages = ExternalMessageSerializer(many=True)
    introductions = IntroductionSerializer(many=True)

    class Meta:
        model = Condition
        fields = '__all__'
Beispiel #4
0
class SequenceSerializer(serializers.ModelSerializer):
    search_type = serializers.CharField(default='sequence', read_only=True)
    preboarding = PreboardingSerializer(many=True)
    to_do = ToDoSerializer(many=True)
    resources = ResourceSerializer(many=True)
    introductions = IntroductionSerializer(many=True)
    appointments = AppointmentSerializer(many=True)

    conditions = ConditionSerializer(many=True)

    class Meta:
        model = Sequence
        fields = '__all__'
 def tasks(self, request, pk=None):
     if request.method == 'POST' or request.method == 'PUT':
         items = get_task_items(self.get_object())
         for i in items:
             if i['item'] == request.data['type']:
                 item = apps.get_model(app_label=i['app'],
                                       model_name=i['model']).objects.get(
                                           id=request.data['item']['id'])
                 i['s_model'].add(item) if request.method == 'POST' else i[
                     's_model'].remove(item)
                 break
         return Response(request.data['item'],
                         status=status.HTTP_201_CREATED)
     user = self.get_object()
     return Response({
         'preboarding':
         PreboardingUserSerializer(PreboardingUser.objects.filter(
             user=user).select_related('preboarding').prefetch_related(
                 'preboarding__content__files'),
                                   many=True).data,
         'to_do':
         ToDoUserSerializer(
             ToDoUser.objects.filter(user=user).select_related(
                 'to_do').prefetch_related('to_do__content__files'),
             many=True).data,
         'resources':
         NewHireResourceItemSerializer(ResourceUser.objects.filter(
             user=user).select_related('resource').prefetch_related(
                 'resource__chapters__content__files'),
                                       many=True).data,
         'introductions':
         IntroductionSerializer(
             user.introductions.select_related('intro_person'),
             many=True).data,
         'appointments':
         AppointmentSerializer(user.appointments, many=True).data,
         'conditions':
         ConditionSerializer(user.conditions.prefetch_related(
             'to_do', 'resources', 'badges', 'admin_tasks',
             'external_messages', 'introductions', 'condition_to_do'),
                             many=True).data
     })
Beispiel #6
0
 def get(self, request):
     colleagues = IntroductionSerializer(request.user.introductions,
                                         many=True)
     return Response(colleagues.data)