def test_addentry(self):
     date = datetime.datetime.now()
     title = "test title"
     link = "blog.iktel.nl"
     entry = RSSBlog(date=date, title=title, link=link)
     entry.put()
     self.assertEqual(1, len(RSSBlog.all()[:1]))
Example #2
0
    def get(self):
        version_number = None

        if (user_models.UserData.current() and
            user_models.UserData.current().developer):
            version_number = self.request_string('version', default=None)

        thumbnail_link_sets = new_and_noteworthy_link_sets()

        # If all else fails, just show the TED talk on the homepage
        marquee_video = {
            "youtube_id": "gM95HHI4gLk",
            "href": "/video?v=%s" % "gM95HHI4gLk",
            "thumb_urls": (
                video_models.Video.youtube_thumbnail_urls("gM95HHI4gLk")),
            "title": "Salman Khan talk at TED 2011",
            "key": "",
        }
        if len(thumbnail_link_sets) > 1:

            day = datetime.datetime.now().day

            # Switch up the first 4 New & Noteworthy videos on a daily basis
            current_link_set_offset = day % len(thumbnail_link_sets)

            # Switch up the marquee video on a daily basis
            marquee_videos = []
            for thumbnail_link_set in thumbnail_link_sets:
                marquee_videos += filter(lambda item: item["marquee"],
                                         thumbnail_link_set)

            if marquee_videos:
                marquee_video = marquee_videos[day % len(marquee_videos)]
                marquee_video["selected"] = True

            thumbnail_link_sets = (
                thumbnail_link_sets[current_link_set_offset:]
                + thumbnail_link_sets[:current_link_set_offset])

            # If there is a set of videos that isn't full,
            # move it to the last position in the carousel.
            for i, link_set in enumerate(thumbnail_link_sets):
                if len(link_set) < ITEMS_PER_SET:
                    thumbnail_link_sets[i], thumbnail_link_sets[-1] = (
                            thumbnail_link_sets[-1], thumbnail_link_sets[i])

        content_uninitialized = (
            topic_models.TopicVersion.get_default_version() is None)

        if content_uninitialized:
            library_content = ('<h1>Content not initialized. '
                               '<a href="/devadmin/content?autoupdate=1">'
                               'Click here</a> '
                               'to autoupdate from iktel.nl.')
        elif version_number:
            layer_cache.disable()
            library_content = library.library_content_html(
                version_number=int(version_number))
        elif self.is_mobile_capable():
            # Only running ajax version of homepage for non-mobile clients
            library_content = library.library_content_html(ajax=False)
        else:
            library_content = library.library_content_html(ajax=True)

        from gae_bingo.gae_bingo import create_redirect_url

        donate_redirect_url = create_redirect_url("/donate",
                                                  "hp_donate_button_click")

        from rssblog_model import RSSBlog
        template_values = {
            'rssblog': RSSBlog.get(0, 4),
            'marquee_video': marquee_video,
            'thumbnail_link_sets': thumbnail_link_sets,
            'library_content': library_content,
            'DVD_list': DVD_list,
            'is_mobile_allowed': True,
            'approx_vid_count': video_models.Video.approx_count(),
            'link_heat': self.request_bool("heat", default=False),
            'version_number': version_number,
            'donate_redirect_url': donate_redirect_url
            }

        self.render_jinja2_template('homepage.html', template_values)

        layer_cache.enable()
Example #3
0
 def get(self):
     """update get the blog entries add the new ones """
     logging.info("importing feed from edit version")
     RSSBlog.fetch_feed()