Exemplo n.º 1
0
 def send_letter_translation_start(self, translation_version):
     video = translation_version.language.video
     language = translation_version.language
     for user in language.notification_list(translation_version.user):
         context = {
             'version': translation_version,
             'domain': self.domain,
             'user': user,
             'language': language,
             'video': video,
             'hash': user.hash_for_video(video.video_id)
         }
         subject = 'New %s translation by %s of "%s"' % \
             (language.language_display(), translation_version.user.__unicode__(), video.__unicode__())
         send_templated_email(user.email, subject, 
                              'videos/email_start_notification.html',
                              context, '*****@*****.**', 
                              fail_silently=not settings.DEBUG)
Exemplo n.º 2
0
 def send_letter_caption(self, caption_version):
     language = caption_version.language
     qs = SubtitleVersion.objects.filter(language=language) \
         .filter(version_no__lt=caption_version.version_no).order_by('-version_no')
     context = {
         'version': caption_version,
         'domain': self.domain,
         'translation': not language.is_original,
         'video': caption_version.video,
         'language': language
     }
     not_send = StopNotification.objects.filter(video=language.video) \
         .values_list('user_id', flat=True)         
     users = []
     for item in qs:
         if item.user and not caption_version.user == item.user and item.user.changes_notification \
             and not item.user in users and not item.user.id in not_send:
             users.append(item.user)
             context['user'] = item.user
             context['old_version'] = item
             
             second_captions = dict([(c.subtitle_id, c) for c in item.subtitles()])
             captions = []
             for caption in caption_version.subtitles():
                 try:
                     scaption = second_captions[caption.subtitle_id]
                 except KeyError:
                     scaption = None
                     changed = True
                 else:
                     changed = not caption.subtitle_text == scaption.subtitle_text
                 data = [caption, scaption, changed]
                 captions.append(data)
             context['captions'] = captions
             context['hash'] = item.user.hash_for_video(context['video'].video_id)
             subject = 'New edits to "%s" by %s on Universal Subtitles' % \
                 (language.video.__unicode__(), item.user.__unicode__())
             send_templated_email(item.user.email, subject, 
                                  'videos/email_notification.html',
                                  context, '*****@*****.**',
                                  fail_silently=not settings.DEBUG)
Exemplo n.º 3
0
def ajax_change_video_title(request):
    video_id = request.POST.get('video_id')
    title = request.POST.get('title')
    user = request.user
    
    try:
        video = Video.objects.get(video_id=video_id)
        if title and not video.title or video.is_html5():
            old_title = video.title or video.video_url
            video.title = title
            video.save()
            action = Action(new_video_title=video.title, video=video)
            action.user = user.is_authenticated() and user or None
            action.created = datetime.now()
            action.action_type = Action.CHANGE_TITLE
            action.save()
            
            users = video.notification_list(user)
            
            for obj in users:
                subject = u'Video\'s title changed on Universal Subtitles'
                context = {
                    'user': obj,
                    'domain': Site.objects.get_current().domain,
                    'video': video,
                    'editor': user,
                    'old_title': old_title,
                    'hash': obj.hash_for_video(video.video_id)
                }
                send_templated_email(obj.email, subject, 
                                     'videos/email_title_changed.html',
                                     context, '*****@*****.**',
                                     fail_silently=not settings.DEBUG)            
    except Video.DoesNotExist:
        pass
    
    return HttpResponse('')