# Path: forums/models.py
# class Post(models.Model):
#     author = models.ForeignKey('auth.User', related_name='posts', editable=False)
# 
#     contents = models.TextField()
# 
#     contents_marked_up = models.TextField(editable=False, null=True)
# 
#     post_date = models.DateTimeField(editable=False)
# 
#     last_edit_date = models.DateTimeField(blank=True)
#     
#     # These fields apply to topics only #
#     
#     is_topic = models.BooleanField(default=False)
#     
#     title = models.CharField(max_length=120, blank=True, null=True)
#     
#     # Tags are stored in their own table, the IDs of those are here.
#     tag_ids = models.ManyToManyField(Tag, related_name='posts', blank=True)
# 
#     is_locked = models.NullBooleanField(blank=True)
# 
#     # END Topics only fields #
#     # These fields apply to replies only #
# 
#     reply_to = models.ForeignKey('Post', related_name='replies', blank=True, null=True, editable=False)
# 
#     # END Replies only fields #
# 
#     def was_edited(self):
#         return True if self.last_edit_date != self.post_date else False
#     
#     def __str__(self):
#         return "Reply to Topic {} (ID {})".format(str(self.reply_to), str(self.id)) if (self.title is None) or (
#             self.title == "") else self.title
# 
#     def save(self, *args, **kwargs):
#         now = timezone.now()
#         if not self.id:
#             self.post_date = now
#         self.last_edit_date = now
#         self.contents_marked_up = bleach.clean(markdown(self.contents).replace('\n', ''), settings.ALLOWED_TAGS,
#                                                settings.ALLOWED_ATTRIBUTES)
#         return super(Post, self).save(*args, **kwargs)


from django.core import exceptions
from django.contrib.auth.models import Group, Permission
from django.db import migrations
from django.contrib.contenttypes.models import ContentType
from forums.models import Post
# -*- coding: utf-8 -*-
from __future__ import unicode_literals





def add_registered_group(apps, schema_editor):
    try:
        group, created = Group.objects.get_or_create(name='registered')
        if created:
            content_type = ContentType.objects.get_for_model(Post)
            p = Permission.objects.get(codename='add_post', content_type=content_type)
            group.permissions.add(p)
    except exceptions.ObjectDoesNotExist:
        # TODO: Unit tests can't create database because of this migration. Need to fix it.
        pass



class Migration(migrations.Migration):
    dependencies = [

# Path: forums/models.py
# class Post(models.Model):
#     author = models.ForeignKey('auth.User', related_name='posts', editable=False)
# 
#     contents = models.TextField()
# 
#     contents_marked_up = models.TextField(editable=False, null=True)
# 
#     post_date = models.DateTimeField(editable=False)
# 
#     last_edit_date = models.DateTimeField(blank=True)
#     
#     # These fields apply to topics only #
#     
#     is_topic = models.BooleanField(default=False)
#     
#     title = models.CharField(max_length=120, blank=True, null=True)
#     
#     # Tags are stored in their own table, the IDs of those are here.
#     tag_ids = models.ManyToManyField(Tag, related_name='posts', blank=True)
# 
#     is_locked = models.NullBooleanField(blank=True)
# 
#     # END Topics only fields #
#     # These fields apply to replies only #
# 
#     reply_to = models.ForeignKey('Post', related_name='replies', blank=True, null=True, editable=False)
# 
#     # END Replies only fields #
# 
#     def was_edited(self):
#         return True if self.last_edit_date != self.post_date else False
#     
#     def __str__(self):
#         return "Reply to Topic {} (ID {})".format(str(self.reply_to), str(self.id)) if (self.title is None) or (
#             self.title == "") else self.title
# 
#     def save(self, *args, **kwargs):
#         now = timezone.now()
#         if not self.id:
#             self.post_date = now
#         self.last_edit_date = now
#         self.contents_marked_up = bleach.clean(markdown(self.contents).replace('\n', ''), settings.ALLOWED_TAGS,
#                                                settings.ALLOWED_ATTRIBUTES)
#         return super(Post, self).save(*args, **kwargs)


# Path: forums/migrations/0019_auto_20150519_1726.py
from django.core import exceptions
from django.contrib.auth.models import Group, Permission
from django.db import migrations
from django.contrib.contenttypes.models import ContentType
from forums.models import Post

# -*- coding: utf-8 -*-
from __future__ import unicode_literals





def add_registered_group(apps, schema_editor):
    try:
        group, created = Group.objects.get_or_create(name='registered')
        if created:
            content_type = ContentType.objects.get_for_model(Post)
            p = Permission.objects.get(codename='add_post', content_type=content_type)
            group.permissions.add(p)
    except exceptions.ObjectDoesNotExist:
        # TODO: Unit tests can't create database because of this migration. Need to fix it.
        pass



class Migration(migrations.Migration):
    dependencies = [

        ('forums', '0018_auto_20150518_1634'),