Ejemplo n.º 1
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)
Ejemplo n.º 2
0
    def clean(self):
        data = super(CreateVideoUrlForm, self).clean()
        video = data.get('video')
        if video and not can_user_edit_video_urls(video, self.user):
            raise forms.ValidationError(_('You have not permission add video URL for this video'))

        return self.cleaned_data
Ejemplo n.º 3
0
def video_url_make_primary(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 change this URL')
                status = 403
            else:
                obj.make_primary(user=request.user)
        except VideoUrl.DoesNotExist:
            output['error'] = ugettext('Object does not exist')
            status = 404
    return HttpResponse(json.dumps(output), status=status)