예제 #1
0
class Morning(handlers.EmailTemplate):
    recognized_versions = immutable.make_list('v1')

    data_sources = immutable.make_dict({
        'v1': {
            'top_stories': ds.TopStoriesDataSource(clientAUS),
            'world_news': dss.news.WorldNews(clientAUS),
            'australian_news': dss.au.News(clientAUS),
        }
    })

    priority_list = immutable.make_dict({
        'v1': [
            ('top_stories', 5),
            ('australian_news', 7),
            ('world_news', 5),
        ],
    })

    template_names = immutable.make_dict(v1='au/morning/v1')

    def additional_template_data(self):
        sydney_tz = pytz.timezone('Australia/Sydney')
        date_format = "%A %d %B %Y"
        return immutable.make_dict(
            sydney_date=datetime.datetime.now(sydney_tz).strftime(date_format))
예제 #2
0
class EditorsPicks(handlers.EmailTemplate):
    recognized_versions = ['v1']

    data_sources = {}
    data_sources['v1'] = {'editors_picks': ds.TopStoriesDataSource(client)}
    priority_list = {'v1': [('editors_picks', 3)]}
    template_names = {'v1': 'editors-picks'}
예제 #3
0
class DailyEmailAUS(handlers.EmailTemplate):
    recognized_versions = ['v1', 'v2', 'v3', 'v2015', 'v4']
    cache_bust = False

    ad_tag = 'email-guardian-today-aus'
    ad_config = {'leaderboard_v1': 'Top', 'leaderboard_v2': 'Bottom'}

    cultureDataSource = ds.ItemPlusBlogDataSource(
        ds.CultureDataSource(clientAUS),
        au.AusCultureBlogDataSource(clientAUS))

    base_data_sources = immutable.make_dict({
        'top_stories_code':
        ds.TopStoriesDataSource(clientAUS),
        'top_stories':
        ds.TopStoriesDataSource(clientAUS),
        'most_viewed':
        ds.MostViewedDataSource(clientAUS),
        'aus_sport':
        au.SportDataSource(client),
        'culture':
        cultureDataSource,
        'comment':
        au.AusCommentIsFreeDataSource(clientAUS),
        'lifeandstyle':
        ds.LifeAndStyleDataSource(clientAUS),
        'technology':
        tech_data.TechnologyDataSource(clientAUS),
        'environment':
        au.Environment(clientAUS),
        'science':
        ds.ScienceDataSource(clientAUS),
        'video':
        au.AusVideoDataSource(clientAUS),
    })

    data_sources = {
        'v1':
        base_data_sources,
        'v2':
        base_data_sources.using(
            eye_witness=ds.EyeWitnessDataSource(clientAUS)),
        'v3':
        base_data_sources.using(eye_witness=ds.EyeWitnessDataSource(clientAUS),
                                most_shared=dss.social.most_shared(
                                    clientAUS, ophan_client, 'au')),
        'v2015':
        base_data_sources,
        'v4':
        base_data_sources.using(
            breaking=container.for_front('au', 'breaking'),
            canonical=container.for_front('au', 'canonical'),
            special=container.for_front('au', 'special'),
        ),
    }

    base_priorities = immutable.make_list(
        ('top_stories', 6), ('most_viewed', 6), ('aus_sport', 5),
        ('culture', 3), ('comment', 3), ('lifeandstyle', 3), ('technology', 2),
        ('environment', 2), ('science', 2), ('video', 3))

    priority_list = immutable.make_dict({
        'v1':
        base_priorities,
        'v2':
        base_priorities.concat(immutable.make_list(('eye_witness', 1))),
        'v3':
        base_priorities.concat(immutable.make_list(('most_shared', 6))),
        'v2015':
        base_priorities,
        'v4':
        immutable.make_list(
            ('breaking', 5),
            ('canonical', 6),
            ('special', 1),
        ).concat(base_priorities.without(('top_stories', 6))),
    })

    template_names = immutable.make_dict({
        'v1': 'au/daily/v1',
        'v2': 'au/daily/v2',
        'v3': 'au/daily/v3',
        'v2015': 'au/daily/v2015',
        'v4': 'au/daily/v4',
    })
예제 #4
0
class DailyEmailUS(handlers.EmailTemplate):
    minify = True
    cache_bust = False

    recognized_versions = immutable.make_list('v1', 'v3', 'v6', 'v7', 'v2015',
                                              'v2015_v2', 'v2015_v3',
                                              'v2015_v4', 'categories_us')

    ad_tag = 'email-guardian-today-us'
    ad_config = {'leaderboard_v1': 'Top', 'leaderboard_v2': 'Bottom'}

    base_data_sources = immutable.make_dict({
        'business':
        ds.BusinessDataSource(clientUS),
        'technology':
        dss.technology.TechnologyDataSource(clientUS),
        'sport':
        dss.us.SportUSDataSource(clientUS),
        'comment':
        ds.CommentIsFreeDataSource(clientUS),
        'culture':
        ds.CultureDataSource(clientUS),
        'top_stories':
        ds.TopStoriesDataSource(clientUS),
        'video':
        ds.VideoDataSource(clientUS),
    })

    most_shared_us = ds.MostSharedDataSource(
        most_shared_fetcher=MostSharedFetcher(ophan_client, country='us'),
        multi_content_data_source=ds.MultiContentDataSource(
            client=clientUS, name='most_shared_us'),
        shared_count_interpolator=ds.MostSharedCountInterpolator())

    breaking = container.for_front('us',
                                   'breaking',
                                   additional_capi_params=immutable.make_dict(
                                       {"show-elements": "image"}))
    canonical = container.for_front('us',
                                    'canonical',
                                    additional_capi_params=immutable.make_dict(
                                        {"show-elements": "image"}))
    special = container.for_front('us',
                                  'special',
                                  additional_capi_params=immutable.make_dict(
                                      {"show-elements": "image"}))

    data_sources = immutable.make_dict({
        'v1':
        base_data_sources,
        'v3':
        base_data_sources,
        'v6':
        base_data_sources.using(most_shared_us=most_shared_us),
        'v7':
        base_data_sources.using(most_shared_us=most_shared_us),
        'v2015':
        base_data_sources.using(most_shared_us=most_shared_us),
        'v2015_v2':
        base_data_sources.using(most_shared_us=most_shared_us),
        'v2015_v3':
        base_data_sources.using(most_shared_us=most_shared_us),
        'v2015_v4':
        base_data_sources.using(most_shared_us=most_shared_us),
        'categories_us':
        base_data_sources.using(breaking=breaking,
                                canonical=canonical,
                                special=special,
                                most_shared_us=most_shared_us)
    })

    base_priorities = immutable.make_list(
        ('top_stories', 6),
        ('video', 3),
        ('sport', 3),
        ('comment', 3),
        ('culture', 3),
        ('business', 2),
        ('technology', 2),
    )

    priority_list = immutable.make_dict({
        'v1':
        base_priorities,
        'v3':
        base_priorities,
        'v6':
        base_priorities.cons(('most_shared_us', 6), ),
        'v7':
        base_priorities.without(('business', 2)).cons(
            ('most_shared_us', 6)).cons(('business', 3)),
        'v2015':
        base_priorities.cons(('most_shared_us', 6)),
        'v2015_v2':
        base_priorities.cons(('most_shared_us', 6)),
        'v2015_v3':
        base_priorities.cons(('most_shared_us', 6)),
        'v2015_v4':
        base_priorities.cons(('most_shared_us', 6)),
        'categories_us':
        immutable.make_list(('breaking', 5), ('canonical', 6), ('special', 1),
                            ('most_shared_us', 6)).concat(base_priorities)
    })

    template_names = immutable.make_dict({
        'v1':
        'us/daily/v1',
        'v3':
        'us/daily/v3',
        'v6':
        'us/daily/v6',
        'v7':
        'us/daily/v7',
        'v2015':
        'us/daily/v2015',
        'v2015_v2':
        'us/daily/v2015_v2',
        'v2015_v3':
        'us/daily/v2015_v3',
        'v2015_v4':
        'us/daily/v2015_v4',
        'categories_us':
        'us/daily/categories_us'
    })
예제 #5
0
class DailyEmail(handlers.EmailTemplate):
	recognized_versions = ['v1', 'v1-register', 'india', 'v2015', 'nhs', 'categories']

	ad_tag = 'email-guardian-today'
	ad_config = {
		'leaderboard_v1': 'Top',
		'leaderboard_v2': 'Bottom'
	}

	cache_bust=False

	base_data_sources = immutable.make_dict({
		'business': ds.BusinessDataSource(client),
		'technology': tech_data.TechnologyDataSource(client),
		'travel': ds.TravelDataSource(client),
		'lifeandstyle': ds.LifeAndStyleDataSource(client),
		'sport': ds.SportDataSource(client),
		'comment': ds.CommentIsFreeDataSource(client),
		'culture': ds.CultureDataSource(client),
		'top_stories': ds.TopStoriesDataSource(client),
		'eye_witness': ds.EyeWitnessDataSource(client),
		'most_viewed': ds.MostViewedDataSource(client),
		})

	data_sources = immutable.make_dict({
		'v1': base_data_sources,
		'v1-register': base_data_sources,
		'india': base_data_sources.using(
			india_recent = ds.IndiaDataSource(client),
			),
		'v2015': base_data_sources,
		'nhs': base_data_sources.using(
			nhs_special = container.for_id('346f91dc-60a5-41f1-a78e-513f6f379cec'),
			top_stories = container.for_id('uk-alpha/news/regular-stories')
			),
		'categories': base_data_sources.using(
			breaking = container.for_front('uk', 'breaking'),
			canonical = container.for_front('uk', 'canonical'),
			special = container.for_front('uk', 'special'),
		),
	})

	base_priorities = immutable.make_list(('top_stories', 6),
		('most_viewed', 6),
		('sport', 3), ('comment', 3), ('culture', 3),
		('business', 2), ('technology', 2), ('travel', 2),
		('lifeandstyle', 2), ('eye_witness', 1))

	priority_list = immutable.make_dict({
		'v1': base_priorities,
		'v1-register': base_priorities,
		'india': [('top_stories', 6), ('india_recent', 5), ('most_viewed', 6),
					('sport', 3), ('comment', 3), ('culture', 3),
					('business', 2), ('technology', 2), ('travel', 2),
					('lifeandstyle', 2), ('eye_witness', 1)],
		'v2015': base_priorities,
		'nhs': base_priorities.cons(('nhs_special', 2)),
		'categories': immutable.make_list(
			('breaking', 5),
			('canonical', 6),
			('special', 1),
			).concat(base_priorities.without(('top_stories', 6))),
		})

	template_names = immutable.make_dict({
		'v1': 'uk/daily/v1',
		'v1-register': 'uk/daily/v1-register',
		'india': 'uk/daily/india',
		'v2015': 'uk/daily/v2015',
		'nhs': 'uk/daily/nhs',
		'categories': 'uk/daily/categories',
	})

	def exclude_from_deduplication(self):
		return immutable.make_list('eye_witness')