Exemplo n.º 1
0
    def change_title_video(self, video_pk, title, user):
        title = title.strip()
        if not user.is_authenticated():
            return Error(self.authentication_error_msg)

        if not title:
            return Error(_(u'Title can\'t be empty'))

        try:
            video = Video.objects.get(pk=video_pk)
            if title and not video.title or video.is_html5(
            ) or user.is_superuser:
                if title != video.title:
                    old_title = video.title_display()
                    video.title = title
                    video.slug = slugify(video.title)
                    video.save()
                    update_search_index.delay(Video, video.pk)
                    Action.change_title_handler(video, user)
                    send_change_title_email.delay(video.id, user and user.id,
                                                  old_title.encode('utf8'),
                                                  video.title.encode('utf8'))
            else:
                return Error(_(u'Title can\'t be changed for this video'))
        except Video.DoesNotExist:
            return Error(_(u'Video does not exist'))

        return Msg(_(u'Title was changed success'))
Exemplo n.º 2
0
def reject_version(version, team, user, rejection_message=None, sender=None, updates_meta=True, ):
    v = _set_version_moderation_status(version, team, user, REJECTED, updates_meta)
    latest = version.language.latest_version(public_only=False)
    if latest and latest.moderation_status == REJECTED:
        # rollback to the last moderated status
        latest_approved = version.language.latest_version(public_only=True)
        if latest_approved:
            latest_approved.rollback(user)
    if bool(rejection_message) and bool(sender):
        comment = create_comment_for_rejection(version, rejection_message, sender)
        notify_comment_by_email(comment, version.language, moderator = sender, is_rejection=True )
    Action.create_rejected_video_handler(version, user)    
    return v
Exemplo n.º 3
0
def reject_version(version, team, user, rejection_message=None, sender=None, updates_meta=True, ):
    v = _set_version_moderation_status(version, team, user, REJECTED, updates_meta)
    latest = version.language.latest_version(public_only=False)
    if latest and latest.moderation_status == REJECTED:
        # rollback to the last moderated status
        latest_approved = version.language.latest_version(public_only=True)
        if latest_approved:
            latest_approved.rollback(user)
    if bool(rejection_message) and bool(sender):
        comment = create_comment_for_rejection(version, rejection_message, sender)
        notify_comment_by_email(comment, version.language, moderator = sender, is_rejection=True )
    Action.create_rejected_video_handler(version, user)    
    return v
Exemplo n.º 4
0
def video_url_remove(request):
    output = {}
    id = request.POST.get('id')
    status = 200
    if id:
        try:
            obj = VideoUrl.objects.get(id=id)
            tv = obj.video.get_team_video()
            if tv and not permissions.can_user_edit_video_urls(obj.video, request.user):
                output['error'] = ugettext('You have not permission delete this URL')
                status = 403
            else:
                if obj.primary:
                    output['error'] = ugettext('You can\'t remove primary URL')
                    status = 403
                else:
                    # create activity record
                    act = Action(video=obj.video, action_type=Action.DELETE_URL)
                    act.new_video_title = obj.url
                    act.created = datetime.datetime.now()
                    act.user = request.user
                    act.save()
                    # delete
                    obj.delete()
        except VideoUrl.DoesNotExist:
            output['error'] = ugettext('Object does not exist')
            status = 404
    return HttpResponse(json.dumps(output), status=status)
Exemplo n.º 5
0
def approve_version( version, team, user, updates_meta=True):
    res =  _set_version_moderation_status(version, team, user, APPROVED, updates_meta)
    Action.create_approved_video_handler(version, user)
Exemplo n.º 6
0
def approve_version( version, team, user, updates_meta=True):
    res =  _set_version_moderation_status(version, team, user, APPROVED, updates_meta)
    Action.create_approved_video_handler(version, user)