Esempio n. 1
0
def inform_account_about_events_with_tags(account):
    events = InTheLoopSchedule.unprocessed_for_account(account)

    if events.count():
        account_tags = account.in_the_loop_tags.values_list('name', flat=True)
        tags_in_venues = {}
        for event in events:
            event_tags = event.tags.values_list('name', flat=True)

            tags_intersection = list(set(account_tags) & set(event_tags))

            for tag in tags_intersection:
                if tag in tags_in_venues and not event.venue.city.name_std in tags_in_venues[
                        tag]:
                    tags_in_venues[tag].append(event.venue.city.name_std)
                else:
                    tags_in_venues[tag] = [event.venue.city.name_std]

        if account.reminder_with_email:
            inform_account_about_events_with_tag_with_email(
                account, events, tags_in_venues)

        if account.reminder_with_sms:
            inform_account_about_events_with_tag_with_sms(
                account, events, tags_in_venues)
Esempio n. 2
0
    def test_account_should_be_informed_about_tag_in_region_he_interested_in(self):
        """
        User should be informed about event that appeared in region that he is interested in
        """

        user = User.objects.create_user(username='******', email="*****@*****.**",  password="******")
        account = Account(
            user=user,
            all_of_canada=False,
            regions=[Region.objects.filter(name="Alberta"), Region.objects.filter(name="Saskatchewan")]
            tags=["boo"]
        )

        venue = Venue(
            name="Test venue",
            city=City.objects.filter(name="Saskatoon"),
            country=Country.objects.filter(name="Canada")
        )

        event = Event(
            name="Test event",
            venue=venue,
            tags=["boo"]
        )

        self.assertIn(
            event,
            InTheLoopSchedule.unprocessed_for_account(account)
        )        
Esempio n. 3
0
    def test_account_should_be_informed_about_tag_in_region_he_interested_in(self):
        """
        User should be informed about event that appeared in region that he is interested in
        """

        user = User.objects.create_user(username='******', email="*****@*****.**",  password="******")
        account = Account(
            user=user,
            all_of_canada=False,
            regions=[Region.objects.filter(name="Alberta"), Region.objects.filter(name="Saskatchewan")],
            tags=["boo"]
        )

        venue = Venue(
            name="Test venue",
            city=City.objects.filter(name="Saskatoon"),
            country=Country.objects.filter(name="Canada")
        )

        event = Event(
            name="Test event",
            venue=venue,
            tags=["boo"]
        )

        self.assertIn(
            event,
            InTheLoopSchedule.unprocessed_for_account(account)
        )        
Esempio n. 4
0
def inform_account_about_events_with_tags(account):
    events = InTheLoopSchedule.unprocessed_for_account(account)

    if events.count():
        account_tags = account.in_the_loop_tags.values_list("name", flat=True)
        tags_in_venues = {}
        for event in events:
            event_tags = event.tags.values_list("name", flat=True)

            tags_intersection = list(set(account_tags) & set(event_tags))

            for tag in tags_intersection:
                if tag in tags_in_venues and not event.venue.city.name_std in tags_in_venues[tag]:
                    tags_in_venues[tag].append(event.venue.city.name_std)
                else:
                    tags_in_venues[tag] = [event.venue.city.name_std]

        if account.reminder_with_email:
            inform_account_about_events_with_tag_with_email(account, events, tags_in_venues)

        if account.reminder_with_sms:
            inform_account_about_events_with_tag_with_sms(account, events, tags_in_venues)