2024-01-07 20:27:22 +00:00
|
|
|
from rest_framework import routers, viewsets, serializers
|
|
|
|
|
2024-01-14 15:01:32 +00:00
|
|
|
from mail.models import Email, EmailAttachment
|
|
|
|
|
|
|
|
|
|
|
|
class AttachmentSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = EmailAttachment
|
|
|
|
fields = ['hash', 'mime_type', 'name']
|
2024-01-07 20:27:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EmailSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Email
|
|
|
|
fields = '__all__'
|
|
|
|
|
|
|
|
|
|
|
|
class EmailViewSet(viewsets.ModelViewSet):
|
|
|
|
serializer_class = EmailSerializer
|
|
|
|
queryset = Email.objects.all()
|
|
|
|
|
|
|
|
|
|
|
|
router = routers.SimpleRouter()
|
|
|
|
router.register(r'mails', EmailViewSet, basename='mails')
|
|
|
|
|
|
|
|
urlpatterns = router.urls
|