Beispiel #1
0
def discussion_delete(request, discussion_id):
    root_comment = get_object_or_404(ThreadedComment, pk=discussion_id)
    if not root_comment.content_object.permission_to('read', request):
        return HttpResponseForbidden('You do not have permission \
                                     to view this discussion.')

    return delete_collaboration(request, root_comment.object_pk)
Beispiel #2
0
def discussion_delete(request, discussion_id):
    root_comment = get_object_or_404(ThreadedComment, pk=discussion_id)
    if not root_comment.content_object.permission_to('read', request):
        return HttpResponseForbidden('You do not have permission \
                                     to view this discussion.')

    return delete_collaboration(request, root_comment.object_pk)
Beispiel #3
0
def show_discussion(request, root_comment):
    space_viewer = request.user
    if space_viewer.is_staff and request.GET.has_key('as'):
        space_viewer = get_object_or_404(User,username=request.GET['as'])

    if request.method == "DELETE":
        return delete_collaboration(request, root_comment.object_pk)

    if not root_comment.content_object.permission_to('read',request):
        return HttpResponseForbidden('You do not have permission to view this discussion.')
    
    try:
        my_course = root_comment.content_object.context.content_object
    except:
        #legacy: for when contexts weren't being set in new()
        my_course = request.course
        root_comment.content_object.context = Collaboration.get_associated_collab(my_course)
        root_comment.content_object.save()

    target = None
    if root_comment.content_object._parent_id and \
            root_comment.content_object._parent.object_pk:
        target = root_comment.content_object._parent

    rv = {
        'is_space_owner': True,
        'edit_comment_permission': my_course.is_faculty(space_viewer),
        'space_owner': space_viewer, #for now
        'space_viewer': space_viewer,
        'root_comment': root_comment,
        'target':target,        
        'COMMENT_MAX_LENGTH':COMMENT_MAX_LENGTH, #change this in settings.COMMENT_MAX_LENGTH
        }
    
    return render_to_response('discussions/discussion.html', rv, context_instance=RequestContext(request))
Beispiel #4
0
def discussion_delete(request, discussion_id):
    space_viewer = request.user

    root_comment = get_object_or_404(ThreadedComment, pk=discussion_id)
    if not root_comment.content_object.permission_to("read", request):
        return HttpResponseForbidden("You do not have permission to view this discussion.")

    return delete_collaboration(request, root_comment.object_pk)
Beispiel #5
0
def show_discussion(request, root_comment):
    space_viewer = request.user
    if space_viewer.is_staff and request.GET.has_key('as'):
        space_viewer = get_object_or_404(User, username=request.GET['as'])

    if request.method == "DELETE":
        return delete_collaboration(request, root_comment.object_pk)

    if not root_comment.content_object.permission_to('read', request):
        return HttpResponseForbidden(
            'You do not have permission to view this discussion.')

    try:
        my_course = root_comment.content_object.context.content_object
    except:
        #legacy: for when contexts weren't being set in new()
        my_course = request.course
        root_comment.content_object.context = Collaboration.get_associated_collab(
            my_course)
        root_comment.content_object.save()

    switcher = {
        'init': reverse('annotations-fragment', args=[space_viewer.username])
    }
    target = None
    if root_comment.content_object._parent_id and \
            root_comment.content_object._parent.object_pk:
        target = root_comment.content_object._parent

        if 'project' == target.content_type.model:
            switcher['init'] = reverse('annotations-fragment-none',
                                       args=['none'])
            switcher['project_json'] = '%s%s' % (
                target.content_object.get_absolute_url(),
                'json',  #appended for json content (and avoiding cache poisoning webkit)
            )
        elif 'course' == target.content_type.model:
            #so we don't show a pointer for global discussions
            target = None

    return {
        'is_space_owner': True,
        'edit_comment_permission': my_course.is_faculty(space_viewer),
        'space_owner': space_viewer,  #for now
        'space_viewer': space_viewer,
        'root_comment': root_comment,
        'target': target,
        'switcher': switcher,
        'page_in_edit_mode': True,
        #change this in settings.COMMENT_MAX_LENGTH
        'COMMENT_MAX_LENGTH': COMMENT_MAX_LENGTH,
    }
Beispiel #6
0
def show_discussion(request, root_comment):
    space_viewer = request.user
    if space_viewer.is_staff and request.GET.has_key('as'):
        space_viewer = get_object_or_404(User,username=request.GET['as'])

    if request.method == "DELETE":
        return delete_collaboration(request, root_comment.object_pk)

    if not root_comment.content_object.permission_to('read',request):
        return HttpResponseForbidden('You do not have permission to view this discussion.')
    
    try:
        my_course = root_comment.content_object.context.content_object
    except:
        #legacy: for when contexts weren't being set in new()
        my_course = request.course
        root_comment.content_object.context = Collaboration.get_associated_collab(my_course)
        root_comment.content_object.save()

    switcher = {
        'init':reverse('annotations-fragment', args=[space_viewer.username])
        }
    target = None
    if root_comment.content_object._parent_id and \
            root_comment.content_object._parent.object_pk:
        target = root_comment.content_object._parent

        if 'project'==target.content_type.model:
            switcher['init'] = reverse('annotations-fragment-none', args=['none'])
            switcher['project_json'] = '%s%s' % (
                target.content_object.get_absolute_url(),
                'json', #appended for json content (and avoiding cache poisoning webkit)
                )
        elif 'course'==target.content_type.model:
            #so we don't show a pointer for global discussions
            target = None

    return {
        'is_space_owner': True,
        'edit_comment_permission': my_course.is_faculty(space_viewer),
        'space_owner': space_viewer, #for now
        'space_viewer': space_viewer,
        'root_comment': root_comment,
        'target':target,
        'switcher':switcher,
        'page_in_edit_mode': True,
        #change this in settings.COMMENT_MAX_LENGTH
        'COMMENT_MAX_LENGTH':COMMENT_MAX_LENGTH,
        }