Example #1
0
 def get_initial(self):
     initial = super(SubmitVideoView, self).get_initial()
     if getattr(self.video, 'tags', None):
         initial.update({
             'tags': get_or_create_tags(self.video.tags),
         })
     return initial
Example #2
0
 def get_initial(self):
     initial = super(SubmitVideoView, self).get_initial()
     if getattr(self.video, 'tags', None):
         initial.update({
             'tags': get_or_create_tags(self.video.tags),
         })
     return initial
    def test_get_initial_tags(self):
        """
        Tests that tags are in the initial data only if tags are defined on the
        video, and that the tags in the expected format - at the moment, this
        is the return value of get_or_create_tags(tags).

        """
        view = SubmitVideoView()
        view.video = VidscraperVideo('http://google.com')
        initial = view.get_initial()
        self.assertFalse('tags' in initial)

        tags = ['hello', 'goodbye']
        view.video.tags = tags
        initial = view.get_initial()
        self.assertTrue('tags' in initial)
        # This is perhaps not the best way to test this.
        self.assertEqual(initial['tags'], get_or_create_tags(tags))
    def test_get_initial_tags(self):
        """
        Tests that tags are in the initial data only if tags are defined on the
        video, and that the tags in the expected format - at the moment, this
        is the return value of get_or_create_tags(tags).

        """
        view = SubmitVideoView()
        view.video = VidscraperVideo('http://google.com')
        initial = view.get_initial()
        self.assertFalse('tags' in initial)

        tags = ['hello', 'goodbye']
        view.video.tags = tags
        initial = view.get_initial()
        self.assertTrue('tags' in initial)
        # This is perhaps not the best way to test this.
        self.assertEqual(initial['tags'], get_or_create_tags(tags))
Example #5
0
 def __init__(self, *args, **kwargs):
     self.vidscraper_video = kwargs.pop('vidscraper_video', {})
     if self.vidscraper_video.tags:
         kwargs.setdefault('initial', {})['tags'] = \
             get_or_create_tags(self.vidscraper_video.tags)
     SecondStepSubmitVideoForm.__init__(self, *args, **kwargs)
Example #6
0
 def __init__(self, *args, **kwargs):
     self.vidscraper_video = kwargs.pop('vidscraper_video', {})
     if self.vidscraper_video.tags:
         kwargs.setdefault('initial', {})['tags'] = \
             get_or_create_tags(self.vidscraper_video.tags)
     SecondStepSubmitVideoForm.__init__(self, *args, **kwargs)