# Path: wagtailsocialfeed/models.py
# class SocialFeedConfiguration(models.Model):
#     FEED_CHOICES = (
#         ('twitter', _('Twitter')),
#         ('instagram', _('Instagram')),
#         ('facebook', _('Facebook'))
#     )
# 
#     source = models.CharField(_('Feed source'),
#                               max_length=100,
#                               choices=FEED_CHOICES,
#                               blank=False)
#     username = models.CharField(_('User to track'),
#                                 max_length=255,
#                                 blank=False)
#     moderated = models.BooleanField(default=False)
# 
#     def __str__(self):
#         name = self.username
#         if self.source == 'twitter':
#             name = "@{}".format(self.username)
#         return "{} ({})".format(self.source, name)
# 
# class SocialFeedPage(Page):
#     feedconfig = models.ForeignKey(SocialFeedConfiguration,
#                                    blank=True,
#                                    null=True,
#                                    on_delete=models.PROTECT,
#                                    help_text=_("Leave blank to show all the feeds."))
# 
#     content_panels = Page.content_panels + [
#         FieldPanel('feedconfig'),
#     ]
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(SocialFeedPage,
#                         self).get_context(request, *args, **kwargs)
#         feed = None
#         if self.feedconfig:
#             feed = get_feed_items(self.feedconfig)
#         else:
#             feed = get_feed_items_mix(SocialFeedConfiguration.objects.all())
# 
#         context['feed'] = feed
#         return context


import factory
from wagtailsocialfeed.models import SocialFeedConfiguration, SocialFeedPage
from __future__ import unicode_literals




class SocialFeedConfigurationFactory(factory.DjangoModelFactory):
    username = factory.Faker('user_name')

    class Meta:
        model = SocialFeedConfiguration


class SocialFeedPageFactory(factory.DjangoModelFactory):
    title = factory.Faker('word')
    path = '0000'
    depth = 0

    feedconfig = factory.SubFactory(SocialFeedConfigurationFactory)


# Path: wagtailsocialfeed/models.py
# class SocialFeedConfiguration(models.Model):
#     FEED_CHOICES = (
#         ('twitter', _('Twitter')),
#         ('instagram', _('Instagram')),
#         ('facebook', _('Facebook'))
#     )
# 
#     source = models.CharField(_('Feed source'),
#                               max_length=100,
#                               choices=FEED_CHOICES,
#                               blank=False)
#     username = models.CharField(_('User to track'),
#                                 max_length=255,
#                                 blank=False)
#     moderated = models.BooleanField(default=False)
# 
#     def __str__(self):
#         name = self.username
#         if self.source == 'twitter':
#             name = "@{}".format(self.username)
#         return "{} ({})".format(self.source, name)
# 
# class SocialFeedPage(Page):
#     feedconfig = models.ForeignKey(SocialFeedConfiguration,
#                                    blank=True,
#                                    null=True,
#                                    on_delete=models.PROTECT,
#                                    help_text=_("Leave blank to show all the feeds."))
# 
#     content_panels = Page.content_panels + [
#         FieldPanel('feedconfig'),
#     ]
# 
#     def get_context(self, request, *args, **kwargs):
#         context = super(SocialFeedPage,
#                         self).get_context(request, *args, **kwargs)
#         feed = None
#         if self.feedconfig:
#             feed = get_feed_items(self.feedconfig)
#         else:
#             feed = get_feed_items_mix(SocialFeedConfiguration.objects.all())
# 
#         context['feed'] = feed
#         return context


# Path: tests/factories.py
import factory
from wagtailsocialfeed.models import SocialFeedConfiguration, SocialFeedPage

from __future__ import unicode_literals




class SocialFeedConfigurationFactory(factory.DjangoModelFactory):
    username = factory.Faker('user_name')

    class Meta:
        model = SocialFeedConfiguration


class SocialFeedPageFactory(factory.DjangoModelFactory):
    title = factory.Faker('word')
    path = '0000'
    depth = 0

    feedconfig = factory.SubFactory(SocialFeedConfigurationFactory)


    class Meta: