Esempio n. 1
0
def ajax_delete_demonstration_form(request, course_id, demonstration_id):
    demonstration = get_object_or_404(Demonstration, pk=demonstration_id)
    item = demonstration.item
    if not request.user.has_perm(
            'grades.delete_grade') and not item.marking_period.active:
        # you aren't a registrar, so you can't modify an inactive marking period
        return HttpResponse(status=403)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (demonstration, )
    demonstration.delete()
    # TODO: degrossify
    if not Demonstration.objects.filter(item=item):
        if Mark.objects.filter(item=item):
            raise Exception(
                'Stray marks found after attempting to delete last demonstration.'
            )
        else:
            # the last demonstration is dead. kill the item.
            item.delete()

    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 2
0
def ajax_delete_item_form(request, course_id, item_id):
    item = get_object_or_404(Item, pk=item_id)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (item, )
    item.delete()
    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 3
0
def ajax_delete_item_form(request, course_id, item_id):
    item = get_object_or_404(Item, pk=item_id)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (item,)
    item.delete()
    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 4
0
def ajax_delete_item_form(request, course_id, item_id):
    item = get_object_or_404(Item, pk=item_id)
    if not request.user.has_perm('grades.delete_grade') and not item.marking_period.active:
        # you aren't a registrar, so you can't modify an inactive marking period
        return HttpResponse(status=403)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (item,)
    item.delete()
    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 5
0
def ajax_delete_item_form(request, course_id, item_id):
    item = get_object_or_404(Item, pk=item_id)
    if not request.user.has_perm(
            'grades.delete_grade') and not item.marking_period.active:
        # you aren't a registrar, so you can't modify an inactive marking period
        return HttpResponse(status=403)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (item, )
    item.delete()
    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 6
0
def ajax_delete_demonstration_form(request, course_id, demonstration_id):
    demonstration = get_object_or_404(Demonstration, pk=demonstration_id)
    item = demonstration.item
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (demonstration,)
    demonstration.delete()
    if not Demonstration.objects.filter(item=item):
        if Mark.objects.filter(item=item):
            raise Exception('Stray marks found after attempting to delete last demonstration.')
        else:
            # the last demonstration is dead. kill the item.
            item.delete()

    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 7
0
def ajax_delete_demonstration_form(request, course_id, demonstration_id):
    demonstration = get_object_or_404(Demonstration, pk=demonstration_id)
    item = demonstration.item
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (demonstration, )
    demonstration.delete()
    if not Demonstration.objects.filter(item=item):
        if Mark.objects.filter(item=item):
            raise Exception(
                'Stray marks found after attempting to delete last demonstration.'
            )
        else:
            # the last demonstration is dead. kill the item.
            item.delete()

    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')
Esempio n. 8
0
def ajax_delete_demonstration_form(request, course_id, demonstration_id):
    demonstration = get_object_or_404(Demonstration, pk=demonstration_id)
    item = demonstration.item
    if not request.user.has_perm('grades.delete_grade') and not item.marking_period.active:
        # you aren't a registrar, so you can't modify an inactive marking period
        return HttpResponse(status=403)
    ghost_item = Item()
    ghost_item.course = item.course
    ghost_item.category = item.category
    ghost_item.marking_period = item.marking_period
    message = '%s deleted' % (demonstration,)
    demonstration.delete()
    if not Demonstration.objects.filter(item=item):
        if Mark.objects.filter(item=item):
            raise Exception('Stray marks found after attempting to delete last demonstration.')
        else:
            # the last demonstration is dead. kill the item.
            item.delete()

    gradebook_recalculate_on_item_change(ghost_item)
    messages.success(request, message)
    return HttpResponse('SUCCESS')