Beispiel #1
0
    def to_representation(self, instance):

        # get serializers of foreignkey relationsships
        self.fields['artifact'] =  ArtifactFkSerializer(many=False, read_only=True)
        self.fields['case'] =  dfirtrack_main_fk.CaseFkSerializer(many=False, read_only=True)
        self.fields['parent_task'] =  dfirtrack_main_fk.ParentTaskFkSerializer(many=False, read_only=True)
        self.fields['system'] =  dfirtrack_main_fk.SystemFkSerializer(many=False, read_only=True)
        self.fields['tag'] =  dfirtrack_main_fk.TagFkSerializer(many=True, read_only=True)
        self.fields['taskname'] =  dfirtrack_main_fk.TasknameFkSerializer(many=False, read_only=True)
        self.fields['taskpriority'] =  dfirtrack_main_fk.TaskpriorityFkSerializer(many=False, read_only=True)
        self.fields['taskstatus'] =  dfirtrack_main_fk.TaskstatusFkSerializer(many=False, read_only=True)

        # get existing to_representation
        representation = super().to_representation(instance)

        # change mandatory time strings
        representation['task_create_time'] = instance.task_create_time.strftime('%Y-%m-%dT%H:%M')
        representation['task_modify_time'] = instance.task_modify_time.strftime('%Y-%m-%dT%H:%M')

        # change optional time strings
        if instance.task_scheduled_time:
            representation['task_scheduled_time'] = instance.task_scheduled_time.strftime('%Y-%m-%dT%H:%M')
        if instance.task_started_time:
            representation['task_started_time'] = instance.task_started_time.strftime('%Y-%m-%dT%H:%M')
        if instance.task_finished_time:
            representation['task_finished_time'] = instance.task_finished_time.strftime('%Y-%m-%dT%H:%M')
        if instance.task_due_time:
            representation['task_due_time'] = instance.task_due_time.strftime('%Y-%m-%dT%H:%M')

        return representation
Beispiel #2
0
    def to_representation(self, instance):

        # get serializers of foreignkey relationsships
        self.fields['case'] = dfirtrack_main_fk.CaseFkSerializer(
            many=False, read_only=True)
        self.fields['headline'] = dfirtrack_main_fk.HeadlineFkSerializer(
            many=False, read_only=True)
        self.fields['notestatus'] = dfirtrack_main_fk.NotestatusFkSerializer(
            many=False, read_only=True)
        self.fields['system'] = dfirtrack_main_fk.SystemFkSerializer(
            many=False, read_only=True)
        self.fields['tag'] = dfirtrack_main_fk.TagFkSerializer(many=True,
                                                               read_only=True)

        # get existing to_representation
        representation = super().to_representation(instance)

        # change mandatory time strings
        representation[
            'reportitem_create_time'] = instance.reportitem_create_time.strftime(
                '%Y-%m-%dT%H:%M')
        representation[
            'reportitem_modify_time'] = instance.reportitem_modify_time.strftime(
                '%Y-%m-%dT%H:%M')

        return representation
Beispiel #3
0
    def to_representation(self, instance):

        # get serializers of foreignkey relationsships
        self.fields['analysisstatus'] =  dfirtrack_main_fk.AnalysisstatusFkSerializer(many=False, read_only=True)
        self.fields['case'] =  dfirtrack_main_fk.CaseFkSerializer(many=True, read_only=True)
        self.fields['company'] =  dfirtrack_main_fk.CompanyFkSerializer(many=True, read_only=True)
        self.fields['contact'] =  dfirtrack_main_fk.ContactFkSerializer(many=False, read_only=True)
        self.fields['dnsname'] =  dfirtrack_main_fk.DnsnameFkSerializer(many=False, read_only=True)
        self.fields['domain'] =  dfirtrack_main_fk.DomainFkSerializer(many=False, read_only=True)
        self.fields['host_system'] =  dfirtrack_main_fk.HostSystemFkSerializer(many=False, read_only=True)
        self.fields['ip'] =  dfirtrack_main_fk.IpFkSerializer(many=True, read_only=True)
        self.fields['location'] =  dfirtrack_main_fk.LocationFkSerializer(many=False, read_only=True)
        self.fields['os'] =  dfirtrack_main_fk.OsFkSerializer(many=False, read_only=True)
        self.fields['osarch'] =  dfirtrack_main_fk.OsarchFkSerializer(many=False, read_only=True)
        self.fields['reason'] =  dfirtrack_main_fk.ReasonFkSerializer(many=False, read_only=True)
        self.fields['recommendation'] =  dfirtrack_main_fk.RecommendationFkSerializer(many=False, read_only=True)
        self.fields['serviceprovider'] =  dfirtrack_main_fk.ServiceproviderFkSerializer(many=False, read_only=True)
        self.fields['systemstatus'] =  dfirtrack_main_fk.SystemstatusFkSerializer(many=False, read_only=True)
        self.fields['systemtype'] =  dfirtrack_main_fk.SystemtypeFkSerializer(many=False, read_only=True)
        self.fields['tag'] =  dfirtrack_main_fk.TagFkSerializer(many=True, read_only=True)

        # get existing to_representation
        representation = super().to_representation(instance)

        # change mandatory time strings
        representation['system_create_time'] = instance.system_create_time.strftime('%Y-%m-%dT%H:%M')
        representation['system_modify_time'] = instance.system_modify_time.strftime('%Y-%m-%dT%H:%M')

        # change optional time strings
        # TODO: change after model rebuild
        #if instance.system_install_time:
        #    representation['system_install_time'] = instance.system_install_time.strftime('%Y-%m-%dT%H:%M')
        if instance.system_lastbooted_time:
            representation['system_lastbooted_time'] = instance.system_lastbooted_time.strftime('%Y-%m-%dT%H:%M')
        if instance.system_deprecated_time:
            representation['system_deprecated_time'] = instance.system_deprecated_time.strftime('%Y-%m-%dT%H:%M')

        return representation