# Path: profile/models.py
# class Notifications(models.Model):
#     update = models.BooleanField(default=True)
#     response = models.BooleanField(default=True)
#     reported = models.BooleanField(default=False)
#     threshold = models.BooleanField(default=False)
# 
# class Profile(models.Model):
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
#     full_name = models.TextField()
#     notifications = models.ForeignKey('profile.Notifications', on_delete=models.CASCADE)
#     subscriptions = models.ManyToManyField('petitions.Petition', related_name='profile_subscriptions', blank=True)
#     petitions_created = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_created', blank=True)
#     petitions_signed = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_signed', blank=True)
#     display_name = models.CharField(max_length=3, blank=True)
#     # 0 - Does not have access, 1 - Has Access
#     has_access = models.PositiveSmallIntegerField(default=1)
# 
#     def __unicode__(self):
#         return self.user.username
# 
# Path: petitions/models.py
# class Petition(models.Model):
#     title = models.CharField(max_length=80)
#     description = models.TextField()
#     tags = models.ManyToManyField('petitions.Tag')
#     author = models.ForeignKey(User, on_delete=models.PROTECT)
#     signatures = models.PositiveIntegerField(default=0)
#     created_at = models.DateTimeField()
#     # These states include: 0 - new (unpublished), 1 - published, 2 - removed (unpublished), 3 - Needs Review
#     status = models.PositiveSmallIntegerField(default=0)
#     expires = models.DateTimeField()
#     last_signed = models.DateTimeField(default=None, blank=True, null=True)
#     has_response = models.BooleanField(default=False)
#     response = models.ForeignKey('petitions.Response', default=None, blank=True, null=True, on_delete=models.SET_NULL)
#     in_progress = models.NullBooleanField()
#     updates = models.ManyToManyField('petitions.Update', default=None)
#     old_id = models.CharField(max_length=20, default=None, blank=True, null=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
# 
#     def __str__(self):
#         return self.name
# 
# class Response(models.Model):
#     description = models.TextField()
#     created_at = models.DateTimeField()
#     author = models.TextField()
# 
#     def __str__(self):
#         return self.author


import random
import traceback
from datetime import timedelta
from profile.models import Notifications, Profile
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
from mimesis import Person, Text
from mimesis.enums import Gender
from petitions.models import Petition, Tag, Response
                    petition.created_at = created_at
                    petition.status = status
                    petition.expires = expires
                    petition.last_signed = last_signed

                    petition.save()
                    if resp > 0:
                        petition.has_response = True
                        author = self.get_random_person_locale().full_name()
                        resp_obj = Response(description=text.text(random.randint(1,20))+"\n"+author, created_at=timezone.now(),author=author)
                        resp_obj.save()
                        petition.response = resp_obj
                        resp -= 1
                    petition.save()
                    petitionlst.append(petition)
            self.stdout.write(self.style.SUCCESS(
                'Successfully created %s Petition objects' % num_petitions))
            return petitionlst
        except Exception as e:
            self.stdout.write(self.style.ERROR(
                'Failed to generate %s Petition objects\n %s' % (len(users), e)))
            print(traceback.format_exc())
            return None

    def generate_tags(self):
        taglst = []
        self.stdout.write('Generating Tag objects')
        try:
            with transaction.atomic():
                for tag in self.tag_names:

# Path: profile/models.py
# class Notifications(models.Model):
#     update = models.BooleanField(default=True)
#     response = models.BooleanField(default=True)
#     reported = models.BooleanField(default=False)
#     threshold = models.BooleanField(default=False)
# 
# class Profile(models.Model):
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
#     full_name = models.TextField()
#     notifications = models.ForeignKey('profile.Notifications', on_delete=models.CASCADE)
#     subscriptions = models.ManyToManyField('petitions.Petition', related_name='profile_subscriptions', blank=True)
#     petitions_created = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_created', blank=True)
#     petitions_signed = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_signed', blank=True)
#     display_name = models.CharField(max_length=3, blank=True)
#     # 0 - Does not have access, 1 - Has Access
#     has_access = models.PositiveSmallIntegerField(default=1)
# 
#     def __unicode__(self):
#         return self.user.username
# 
# Path: petitions/models.py
# class Petition(models.Model):
#     title = models.CharField(max_length=80)
#     description = models.TextField()
#     tags = models.ManyToManyField('petitions.Tag')
#     author = models.ForeignKey(User, on_delete=models.PROTECT)
#     signatures = models.PositiveIntegerField(default=0)
#     created_at = models.DateTimeField()
#     # These states include: 0 - new (unpublished), 1 - published, 2 - removed (unpublished), 3 - Needs Review
#     status = models.PositiveSmallIntegerField(default=0)
#     expires = models.DateTimeField()
#     last_signed = models.DateTimeField(default=None, blank=True, null=True)
#     has_response = models.BooleanField(default=False)
#     response = models.ForeignKey('petitions.Response', default=None, blank=True, null=True, on_delete=models.SET_NULL)
#     in_progress = models.NullBooleanField()
#     updates = models.ManyToManyField('petitions.Update', default=None)
#     old_id = models.CharField(max_length=20, default=None, blank=True, null=True)
# 
#     def __str__(self):
#         return self.title
# 
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
# 
#     def __str__(self):
#         return self.name
# 
# class Response(models.Model):
#     description = models.TextField()
#     created_at = models.DateTimeField()
#     author = models.TextField()
# 
#     def __str__(self):
#         return self.author


# Path: petitions/management/commands/mockdata.py
import random
import traceback
from datetime import timedelta
from profile.models import Notifications, Profile
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
from mimesis import Person, Text
from mimesis.enums import Gender
from petitions.models import Petition, Tag, Response

                    petition.created_at = created_at
                    petition.status = status
                    petition.expires = expires
                    petition.last_signed = last_signed

                    petition.save()
                    if resp > 0:
                        petition.has_response = True
                        author = self.get_random_person_locale().full_name()
                        resp_obj = Response(description=text.text(random.randint(1,20))+"\n"+author, created_at=timezone.now(),author=author)
                        resp_obj.save()
                        petition.response = resp_obj
                        resp -= 1
                    petition.save()
                    petitionlst.append(petition)
            self.stdout.write(self.style.SUCCESS(
                'Successfully created %s Petition objects' % num_petitions))
            return petitionlst
        except Exception as e:
            self.stdout.write(self.style.ERROR(
                'Failed to generate %s Petition objects\n %s' % (len(users), e)))
            print(traceback.format_exc())
            return None

    def generate_tags(self):
        taglst = []
        self.stdout.write('Generating Tag objects')
        try:
            with transaction.atomic():
                for tag in self.tag_names:

                    tag_obj = Tag(name=tag)