Ejemplo n.º 1
0
def create_full_episodes(self):
    episodes = Episode.objects.all()
    for episode in episodes:
        if episode.youtube_url or episode.episode_url:
            # these try/excepts are a brutal hack
            # allowing it because development is basically finished until redevelopment
            try:
                full_episode_quote = Quote.objects.get(episode_id=episode.id, is_full_episode=True)
            except MultipleObjectsReturned:
                try:
                    full_episode_quote = Quote.objects.get(episode__title=episode.title, is_full_episode=True)
                except MultipleObjectsReturned:
                    continue
                except ObjectDoesNotExist:
                    # user with id=1 is the user "podverse" on podverse.tv
                    user = User.objects.get(id=1)
                    full_episode_quote = Quote.create(submitted_by=user,
                                                  rank_score=float(0.0),
                                                  episode=episode,
                                                  summary=episode.title,
                                                  text=episode.description,
                                                  time_quote_begins=int(0),
                                                  is_full_episode=True)
                    full_episode_quote.save()
                    vote = Vote.create(voter=user, quote=full_episode_quote, vote_type=1)
                    vote.save()
            except ObjectDoesNotExist:
                # user with id=1 is the user "podverse" on podverse.tv
                user = User.objects.get(id=1)
                full_episode_quote = Quote.create(submitted_by=user,
                                              rank_score=float(0.0),
                                              episode=episode,
                                              summary=episode.title,
                                              text=episode.description,
                                              time_quote_begins=int(0),
                                              is_full_episode=True)
                full_episode_quote.save()
                vote = Vote.create(voter=user, quote=full_episode_quote, vote_type=1)
                vote.save()
    return HttpResponseRedirect('/')
Ejemplo n.º 2
0
 def form_valid(self, form):
     self.object = episode = form.save(commit=False)
     if episode.youtube_url or episode.episode_url:
         try:
             full_episode_quote = Quote.objects.get(episode__id=episode.id, is_full_episode=True)
         except ObjectDoesNotExist:
             # user with id=1 is the user "podverse" on podverse.tv
             user = User.objects.get(id=1)
             full_episode_quote = Quote.create(submitted_by=user,
                                           rank_score=float(0.0),
                                           episode=episode,
                                           summary=episode.title,
                                           text=episode.description,
                                           time_quote_begins=int(0),
                                           is_full_episode=True)
             full_episode_quote.save()
             vote = Vote.create(voter=user, quote=full_episode_quote, vote_type=1)
             vote.save()
     episode.save()
     return HttpResponseRedirect(self.get_success_url())
Ejemplo n.º 3
0
 def form_valid(self, form):
     self.object = quote = form.save(commit=False)
     quote.submitted_by = self.request.user
     if quote.time_quote_begins == 0 and quote.time_quote_ends is None:
         # Redirect to full episode clip page if the full episode clip already exists
         try:
             obj = Quote.objects.get(episode__id=quote.episode.id, is_full_episode=True)
             url = obj.get_absolute_url()
             return HttpResponseRedirect(url)
         except ObjectDoesNotExist:
             pass
             
         quote.summary = quote.episode.title
         quote.text = quote.episode.description
         quote.is_full_episode = True
         
     quote.save()
     vote = Vote.create(voter=self.request.user, quote=quote, vote_type=1)
     vote.save()
     return HttpResponseRedirect(self.get_success_url())