示例#1
0
class ProjectSerializer(serializers.HyperlinkedModelSerializer):
    client_details = ProjectClientSerializer(source='client', read_only=True)
    total_entries = serializers.SerializerMethodField()
    total_duration = serializers.SerializerMethodField()
    percent_done = serializers.SerializerMethodField()
    estimate = DurationField(required=False)

    class Meta:
        model = Project
        fields = ('id', 'url', 'client', 'client_details', 'name',
                  'archive', 'estimate', 'total_entries', 'total_duration',
                  'percent_done',)

    def get_queryset(self):
        queryset = super(ProjectSerializer, self).get_queryset()
        return queryset.filter(archive=False)

    def get_total_entries(self, obj):
        return obj.get_total_entries()

    def get_total_duration(self, obj):
        return obj.get_total_duration()

    def get_percent_done(self, obj):
        return obj.get_percent_done()
示例#2
0
class EntrySerializer(serializers.HyperlinkedModelSerializer):
    duration = DurationField()
    project_details = ProjectSerializer(source='project', read_only=True)
    user_details = UserSerializer(source='user', read_only=True)
    task_details = TaskSerializer(source='task', read_only=True)

    class Meta:
        model = Entry
        fields = ('id', 'url', 'project', 'project_details', 'task',
                  'task_details', 'user', 'user_details', 'date', 'duration',
                  'note', 'invoiced',)
示例#3
0
class EntrySerializer(serializers.HyperlinkedModelSerializer):
    duration = DurationField()
    project_details = ProjectSerializer(source='project', read_only=True)
    user_details = EntryUserSerializer(source='user', read_only=True)
    task_details = TaskSerializer(source='task', read_only=True)
    is_invoiced = serializers.SerializerMethodField()

    class Meta:
        model = Entry
        fields = ('id', 'url', 'project', 'project_details', 'task',
                  'task_details', 'user', 'user_details', 'date', 'duration',
                  'note', 'is_invoiced',)

    def is_invoiced(self, obj):
        return obj.get_invoiced()
示例#4
0
class EntrySerializer(serializers.HyperlinkedModelSerializer):
    duration = DurationField()

    class Meta:
        model = Entry
        fields = (
            "id",
            "url",
            "project",
            "task",
            "user",
            "date",
            "duration",
            "datetime_start",
            "datetime_end",
            "note",
        )
示例#5
0
class EntrySerializer(serializers.HyperlinkedModelSerializer):
    duration = DurationField()

    class Meta:
        model = Entry
        fields = (
            'id',
            'url',
            'project',
            'task',
            'user',
            'date',
            'duration',
            'datetime_start',
            'datetime_end',
            'note',
        )
示例#6
0
class ClientProjectSerializer(serializers.HyperlinkedModelSerializer):
    total_entries = serializers.SerializerMethodField()
    total_duration = serializers.SerializerMethodField()
    percent_done = serializers.SerializerMethodField()
    estimate = DurationField(required=False)

    class Meta:
        model = Project
        fields = ('id', 'url', 'name', 'client', 'estimate', 'total_entries',
                  'total_duration', 'percent_done', 'archive',)

    def get_total_entries(self, obj):
        return obj.get_total_entries()

    def get_total_duration(self, obj):
        return obj.get_total_duration()

    def get_percent_done(self, obj):
        return obj.get_percent_done()