# Path: endorsements/models.py
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
#     description = models.TextField(blank=True)
#     is_personal = models.BooleanField(default=True)
#     category = models.ForeignKey(Category, null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ['name']
# 
#     def get_mode(self):
#         allow_personal = self.category.allow_personal
#         allow_org = self.category.allow_org
#         if allow_personal and allow_org:
#             return 'none'
#         elif allow_personal:
#             return 'personal'
#         else:
#             return 'organization'
# 
# class Endorser(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(null=True, blank=True)
#     url = models.URLField(null=True, blank=True)
#     is_personal = models.BooleanField(default=True)
#     max_followers = models.PositiveIntegerField(default=0)
#     tags = models.ManyToManyField(Tag, blank=True)
#     missing_image = models.BooleanField(default=True)
#     current_position = models.ForeignKey('Position', blank=True, null=True)
# 
#     class Meta:
#         ordering = ['-max_followers']
# 
#     def __unicode__(self):
#         return self.name
# 
#     def has_url(self):
#         return bool(self.url)
#     has_url.boolean = True
# 
#     def get_tags(self):
#         return ' / '.join(tag.name for tag in self.tags.all())
# 
#     def get_current_endorsement(self):
#         try:
#             return self.endorsement_set.latest('quote')
#         except Endorsement.DoesNotExist:
#             pass
# 
#     def get_image(self):
#         return '<img src="{url}" width="100" />'.format(
#             url=self.get_image_url()
#         )
#     get_image.allow_tags = True
# 
#     def get_image_url(self):
#         image_name = 'missing' if self.missing_image else self.pk
#         return 'https://s3.amazonaws.com/endorsementdb.com/images/endorsers/%s.png' % image_name
# 
#     def needs_quotes(self):
#         current_endorsement = self.get_current_endorsement()
#         return not current_endorsement.quote.text
#     needs_quotes.boolean = True
# 
#     def get_absolute_url(self):
#         return reverse('view-endorser', args=[self.pk])


from django.core.management.base import BaseCommand, CommandError
from endorsements.models import Tag, Endorser



class Command(BaseCommand):
    help = 'Bulk import all the newspaper endorsements'

    def add_arguments(self, parser):
        parser.add_argument('endorser_pk', type=int)
        parser.add_argument('tags', nargs='+')
        parser.add_argument(
            '--remove',
            action='store_true',
            dest='remove',
            default=False,
            help="Remove the specified tags",
        )

    def handle(self, *args, **options):

# Path: endorsements/models.py
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
#     description = models.TextField(blank=True)
#     is_personal = models.BooleanField(default=True)
#     category = models.ForeignKey(Category, null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.name
# 
#     class Meta:
#         ordering = ['name']
# 
#     def get_mode(self):
#         allow_personal = self.category.allow_personal
#         allow_org = self.category.allow_org
#         if allow_personal and allow_org:
#             return 'none'
#         elif allow_personal:
#             return 'personal'
#         else:
#             return 'organization'
# 
# class Endorser(models.Model):
#     name = models.CharField(max_length=100)
#     description = models.TextField(null=True, blank=True)
#     url = models.URLField(null=True, blank=True)
#     is_personal = models.BooleanField(default=True)
#     max_followers = models.PositiveIntegerField(default=0)
#     tags = models.ManyToManyField(Tag, blank=True)
#     missing_image = models.BooleanField(default=True)
#     current_position = models.ForeignKey('Position', blank=True, null=True)
# 
#     class Meta:
#         ordering = ['-max_followers']
# 
#     def __unicode__(self):
#         return self.name
# 
#     def has_url(self):
#         return bool(self.url)
#     has_url.boolean = True
# 
#     def get_tags(self):
#         return ' / '.join(tag.name for tag in self.tags.all())
# 
#     def get_current_endorsement(self):
#         try:
#             return self.endorsement_set.latest('quote')
#         except Endorsement.DoesNotExist:
#             pass
# 
#     def get_image(self):
#         return '<img src="{url}" width="100" />'.format(
#             url=self.get_image_url()
#         )
#     get_image.allow_tags = True
# 
#     def get_image_url(self):
#         image_name = 'missing' if self.missing_image else self.pk
#         return 'https://s3.amazonaws.com/endorsementdb.com/images/endorsers/%s.png' % image_name
# 
#     def needs_quotes(self):
#         current_endorsement = self.get_current_endorsement()
#         return not current_endorsement.quote.text
#     needs_quotes.boolean = True
# 
#     def get_absolute_url(self):
#         return reverse('view-endorser', args=[self.pk])


# Path: endorsements/management/commands/addtags.py
from django.core.management.base import BaseCommand, CommandError
from endorsements.models import Tag, Endorser




class Command(BaseCommand):
    help = 'Bulk import all the newspaper endorsements'

    def add_arguments(self, parser):
        parser.add_argument('endorser_pk', type=int)
        parser.add_argument('tags', nargs='+')
        parser.add_argument(
            '--remove',
            action='store_true',
            dest='remove',
            default=False,
            help="Remove the specified tags",
        )

    def handle(self, *args, **options):

        endorser = Endorser.objects.get(pk=options['endorser_pk'])