# Path: api_v3/models/comment.py
# class Comment(models.Model):
#     """Ticket comment model."""
# 
#     ticket = models.ForeignKey(
#         Ticket, blank=False, related_name='comments', db_index=True,
#         on_delete=models.DO_NOTHING)
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL, blank=False, db_index=True,
#         on_delete=models.DO_NOTHING)
# 
#     body = BleachField(blank=False)
#     created_at = models.DateTimeField(auto_now_add=True)
# 
#     @classmethod
#     def filter_by_user(cls, user, queryset=None):
#         """Returns any user accessible comments.
# 
#         Ones he has access to through the tickets.
#         """
#         if queryset is None:
#             queryset = cls.objects
# 
#         return queryset.filter(ticket__in=Ticket.filter_by_user(user))


from rest_framework_json_api import serializers
from api_v3.models import Comment



class CommentSerializer(serializers.ModelSerializer):

    included_serializers = {
        'user': 'api_v3.serializers.ProfileSerializer',
        'ticket': 'api_v3.serializers.TicketSerializer'
    }

    class Meta:
        model = Comment
        read_only_fields = ('user',)
        fields = (
            'id',
            'user',
            'ticket',

# Path: api_v3/models/comment.py
# class Comment(models.Model):
#     """Ticket comment model."""
# 
#     ticket = models.ForeignKey(
#         Ticket, blank=False, related_name='comments', db_index=True,
#         on_delete=models.DO_NOTHING)
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL, blank=False, db_index=True,
#         on_delete=models.DO_NOTHING)
# 
#     body = BleachField(blank=False)
#     created_at = models.DateTimeField(auto_now_add=True)
# 
#     @classmethod
#     def filter_by_user(cls, user, queryset=None):
#         """Returns any user accessible comments.
# 
#         Ones he has access to through the tickets.
#         """
#         if queryset is None:
#             queryset = cls.objects
# 
#         return queryset.filter(ticket__in=Ticket.filter_by_user(user))


# Path: api_v3/serializers/comment.py
from rest_framework_json_api import serializers
from api_v3.models import Comment




class CommentSerializer(serializers.ModelSerializer):

    included_serializers = {
        'user': 'api_v3.serializers.ProfileSerializer',
        'ticket': 'api_v3.serializers.TicketSerializer'
    }

    class Meta:
        model = Comment
        read_only_fields = ('user',)
        fields = (
            'id',
            'user',
            'ticket',

            'body',