# Path: comments/models.py
# class Comment(models.Model):
#     class Meta:
#         ordering = ["created"]
# 
#     user = models.ForeignKey(CustomUser, related_name='comments', null=True)
#     poster_name = models.CharField(max_length=100)
#     thread = models.ForeignKey(Thread, related_name='comments')
#     text = models.TextField()
#     created = models.DateTimeField(editable=False, default=timezone.now)
#     liked_by_count = models.IntegerField(default=0)
#     disliked_by_count = models.IntegerField(default=0)
#     liked_by = models.ManyToManyField(
#         CustomUser,
#         related_name='liked_comments',
#         blank=True
#     )
#     disliked_by = models.ManyToManyField(
#         CustomUser,
#         related_name='disliked_comments',
#         blank=True
#     )
# 
#     avatar_num = models.IntegerField(default=6)  # green diamond
#     hidden = models.BooleanField(default=False)
#     ip_address = models.GenericIPAddressField(null=True)
# 
#     objects = CommentManager()
# 
#     def get_avatar(self):
#         if self.user is not None:
#             return "%02d" % self.user.avatar_num
#         else:
#             return "%02d" % self.avatar_num
# 
#     def like(self, user):
#         if user.is_anonymous():
#             self.liked_by_count += 1
#         else:
#             self.liked_by.add(user)
# 
#         self.save()
# 
#     def undo_like(self, user):
#         if self.likes_count < 1:
#             return
# 
#         if user.is_anonymous():
#             self.liked_by_count -= 1
#         else:
#             self.liked_by.remove(user)
# 
#         self.save()
# 
#     def dislike(self, user):
#         if user.is_anonymous():
#             self.disliked_by_count += 1
#         else:
#             self.disliked_by.add(user)
# 
#         self.save()
# 
#     def undo_dislike(self, user):
#         if self.dislikes_count < 1:
#             return
# 
#         if user.is_anonymous():
#             self.disliked_by_count -= 1
#         else:
#             self.disliked_by.remove(user)
# 
#         self.save()
# 
#     @property
#     def likes_count(self):
#         count = self.liked_by_count
# 
#         if self.liked_by:
#             count += self.liked_by.count()
# 
#         return count
# 
#     @property
#     def dislikes_count(self):
#         count = self.disliked_by_count
# 
#         if self.disliked_by:
#             count += self.disliked_by.count()
# 
#         return count
# 
#     def hide(self):
#         self.hidden = True
#         self.save()
# 
#     def unhide(self):
#         self.hidden = False
#         self.save()
# 
#     def delete(self, user):
#         """
#         Deletes comment if user is staff/admin or admin for site.
#         """
#         if user.is_staff:
#             super(Comment, self).delete()


from django import forms
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext as _
from comments.models import Comment
from datetime import date, datetime, timedelta
        else:
            return datetime.utcfromtimestamp(0)


class BulkActionForm(forms.Form):
    BULK_ACTION_CHOICES = [
        ('delete', _('Delete')),
        ('hide', _('Unpublish'))
    ]
    site_id = forms.CharField(required=True, widget=forms.HiddenInput())
    action = forms.ChoiceField(choices=BULK_ACTION_CHOICES)


class UnpublishedBulkActionForm(BulkActionForm):
    BULK_ACTION_CHOICES = [
        ('delete', _('Delete')),
        ('unhide', _('Publish'))
    ]
    action = forms.ChoiceField(choices=BULK_ACTION_CHOICES)


class UserBulkActionForm(BulkActionForm):
    choices = forms.ModelMultipleChoiceField(
        queryset=UserModel.objects.all(),
        widget=forms.CheckboxSelectMultiple,
    )


class CommentBulkActionForm(BulkActionForm):
    choices = forms.ModelMultipleChoiceField(

# Path: comments/models.py
# class Comment(models.Model):
#     class Meta:
#         ordering = ["created"]
# 
#     user = models.ForeignKey(CustomUser, related_name='comments', null=True)
#     poster_name = models.CharField(max_length=100)
#     thread = models.ForeignKey(Thread, related_name='comments')
#     text = models.TextField()
#     created = models.DateTimeField(editable=False, default=timezone.now)
#     liked_by_count = models.IntegerField(default=0)
#     disliked_by_count = models.IntegerField(default=0)
#     liked_by = models.ManyToManyField(
#         CustomUser,
#         related_name='liked_comments',
#         blank=True
#     )
#     disliked_by = models.ManyToManyField(
#         CustomUser,
#         related_name='disliked_comments',
#         blank=True
#     )
# 
#     avatar_num = models.IntegerField(default=6)  # green diamond
#     hidden = models.BooleanField(default=False)
#     ip_address = models.GenericIPAddressField(null=True)
# 
#     objects = CommentManager()
# 
#     def get_avatar(self):
#         if self.user is not None:
#             return "%02d" % self.user.avatar_num
#         else:
#             return "%02d" % self.avatar_num
# 
#     def like(self, user):
#         if user.is_anonymous():
#             self.liked_by_count += 1
#         else:
#             self.liked_by.add(user)
# 
#         self.save()
# 
#     def undo_like(self, user):
#         if self.likes_count < 1:
#             return
# 
#         if user.is_anonymous():
#             self.liked_by_count -= 1
#         else:
#             self.liked_by.remove(user)
# 
#         self.save()
# 
#     def dislike(self, user):
#         if user.is_anonymous():
#             self.disliked_by_count += 1
#         else:
#             self.disliked_by.add(user)
# 
#         self.save()
# 
#     def undo_dislike(self, user):
#         if self.dislikes_count < 1:
#             return
# 
#         if user.is_anonymous():
#             self.disliked_by_count -= 1
#         else:
#             self.disliked_by.remove(user)
# 
#         self.save()
# 
#     @property
#     def likes_count(self):
#         count = self.liked_by_count
# 
#         if self.liked_by:
#             count += self.liked_by.count()
# 
#         return count
# 
#     @property
#     def dislikes_count(self):
#         count = self.disliked_by_count
# 
#         if self.disliked_by:
#             count += self.disliked_by.count()
# 
#         return count
# 
#     def hide(self):
#         self.hidden = True
#         self.save()
# 
#     def unhide(self):
#         self.hidden = False
#         self.save()
# 
#     def delete(self, user):
#         """
#         Deletes comment if user is staff/admin or admin for site.
#         """
#         if user.is_staff:
#             super(Comment, self).delete()


# Path: admin/forms.py
from django import forms
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext as _
from comments.models import Comment
from datetime import date, datetime, timedelta

        else:
            return datetime.utcfromtimestamp(0)


class BulkActionForm(forms.Form):
    BULK_ACTION_CHOICES = [
        ('delete', _('Delete')),
        ('hide', _('Unpublish'))
    ]
    site_id = forms.CharField(required=True, widget=forms.HiddenInput())
    action = forms.ChoiceField(choices=BULK_ACTION_CHOICES)


class UnpublishedBulkActionForm(BulkActionForm):
    BULK_ACTION_CHOICES = [
        ('delete', _('Delete')),
        ('unhide', _('Publish'))
    ]
    action = forms.ChoiceField(choices=BULK_ACTION_CHOICES)


class UserBulkActionForm(BulkActionForm):
    choices = forms.ModelMultipleChoiceField(
        queryset=UserModel.objects.all(),
        widget=forms.CheckboxSelectMultiple,
    )


class CommentBulkActionForm(BulkActionForm):
    choices = forms.ModelMultipleChoiceField(

        queryset=Comment.objects.all(),