1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- from .models import KeywordMission, DateMission, TimeMission, PageMission
- from rest_framework import serializers
- from django.contrib.auth.models import User
- class KeywordMissionSerializer(serializers.HyperlinkedModelSerializer):
- url = serializers.HyperlinkedIdentityField(view_name="CrawKeywords:keywordmission-detail")
- publisher = serializers.HyperlinkedRelatedField(view_name='CrawKeywords:user-detail', queryset=User.objects.all())
- class Meta:
- model = KeywordMission
- fields = ('url', 'keyword_mission_id', 'keyword', 'publisher')
- class UserSerializer(serializers.HyperlinkedModelSerializer):
- url = serializers.HyperlinkedIdentityField(view_name="CrawKeywords:user-detail")
- class Meta:
- model = User
- fields = ('url', 'username', 'email')
- class DateMissionSerializer(serializers.HyperlinkedModelSerializer):
- url = serializers.HyperlinkedIdentityField(view_name="CrawKeywords:datemission-detail")
- keyword_mission = serializers.HyperlinkedRelatedField(view_name='CrawKeywords:keywordmission-detail',
- queryset=KeywordMission.objects.all())
- class Meta:
- model = DateMission
- fields = ('url', 'date', 'is_date_finished', 'keyword_mission')
- class TimeMissionSerializer(serializers.HyperlinkedModelSerializer):
- url = serializers.HyperlinkedIdentityField(view_name="CrawKeywords:timemission-detail")
- date_mission = serializers.HyperlinkedRelatedField(view_name='CrawKeywords:datemission-detail',
- queryset=DateMission.objects.all())
- class Meta:
- model = TimeMission
- fields = ('url', 'time', 'is_time_finished', 'date_mission')
- class PageMissionSerializer(serializers.HyperlinkedModelSerializer):
- url = serializers.HyperlinkedIdentityField(view_name="CrawKeywords:pagemission-detail")
- time_mission = serializers.HyperlinkedRelatedField(view_name='CrawKeywords:timemission-detail',
- queryset=TimeMission.objects.all())
- class Meta:
- model = TimeMission
- fields = ('url', 'page', 'time_mission', 'finisher')
|