Example #1
0
    def test_delete_annotation(self):
        note = SherdNoteFactory(
            asset=self.asset, author=self.student_one,
            title='Selection', range1=116.25, range2=6.75)

        request = RequestFactory().post('/', {'next': 'foo'})
        request.user = self.student_two
        response = delete_annotation(request, note.id)
        self.assertEquals(response.status_code, 403)

        request.user = self.student_one
        response = delete_annotation(request, note.id)
        self.assertEquals(response.status_code, 302)

        with self.assertRaises(SherdNote.DoesNotExist):
            SherdNote.objects.get(title='Selection')
Example #2
0
    def test_delete_annotation(self):
        note = SherdNoteFactory(asset=self.asset,
                                author=self.student_one,
                                title='Selection',
                                range1=116.25,
                                range2=6.75)

        request = RequestFactory().post('/', {'next': 'foo'})
        request.user = self.student_two
        response = delete_annotation(request, note.id)
        self.assertEquals(response.status_code, 403)

        request.user = self.student_one
        response = delete_annotation(request, note.id)
        self.assertEquals(response.status_code, 302)

        with self.assertRaises(SherdNote.DoesNotExist):
            SherdNote.objects.get(title='Selection')
Example #3
0
def annotation_delete(request, asset_id, annot_id):
    try:
        # Verify annotation exists
        SherdNote.objects.get(pk=annot_id,
                              asset=asset_id,
                              asset__course=request.course)

        redirect_to = reverse('asset-view', args=[asset_id])

        form = request.GET.copy()
        form['next'] = redirect_to
        request.GET = form
        return delete_annotation(request, annot_id)  # djangosherd.views
    except SherdNote.DoesNotExist:
        return HttpResponseNotFound()
Example #4
0
def annotation_delete(request, asset_id, annot_id):
    try:
        # Verify annotation exists
        SherdNote.objects.get(pk=annot_id,
                              asset=asset_id,
                              asset__course=request.course)

        redirect_to = reverse('asset-view', args=[asset_id])

        form = request.GET.copy()
        form['next'] = redirect_to
        request.GET = form
        return delete_annotation(request, annot_id)  # djangosherd.views
    except SherdNote.DoesNotExist:
        return HttpResponseNotFound()