コード例 #1
0
ファイル: views.py プロジェクト: tmnogueira/mediathread
def annotation_create(request, asset_id):
    """
    delegate to djangosherd view and redirect back to asset workspace

    but first, stuff a range into the request
    and get the annotation context from the url
    """

    # Verify asset exists
    get_object_or_404(Asset, pk=asset_id, course=request.course)

    form = request.POST.copy()
    form['annotation-context_pk'] = asset_id

    # If the data comes through as json, parse the request.body into
    # the form.
    if request.content_type == 'application/json':
        d = json.loads(request.body)
        d['annotation-annotation_data'] = json.dumps(
            d['annotation-annotation_data'])
        form.update(d)

    request.POST = form

    form = request.GET.copy()
    form['annotation-next'] = reverse('asset-view', args=[asset_id])
    request.GET = form

    return create_annotation(request)
コード例 #2
0
ファイル: test_views.py プロジェクト: c0cky/mediathread
    def test_create_annotation(self):
        request = RequestFactory().post('/', self.data)
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 302)

        note = SherdNote.objects.get(title='Annotation Test')
        self.assertEquals(note.range1, -4.5)
        self.assertEquals(note.range2, 23)
        self.assertEquals(note.tags, 'foo,bar')
コード例 #3
0
ファイル: test_views.py プロジェクト: tmnogueira/mediathread
    def test_create_annotation(self):
        request = RequestFactory().post('/', self.data)
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 302)

        note = SherdNote.objects.get(title='Annotation Test')
        self.assertEquals(note.range1, -4.5)
        self.assertEquals(note.range2, 23)
        self.assertEquals(note.tags, 'foo,bar')
コード例 #4
0
ファイル: test_views.py プロジェクト: c0cky/mediathread
    def test_create_annotation_with_project(self):
        project = ProjectFactory()
        self.data['project'] = project.id

        request = RequestFactory().post('/', self.data)
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 302)

        note = SherdNote.objects.get(title='Annotation Test')
        ProjectNote.objects.get(annotation=note, project=project)
コード例 #5
0
ファイル: test_views.py プロジェクト: tmnogueira/mediathread
    def test_create_annotation_with_project(self):
        project = ProjectFactory()
        self.data['project'] = project.id

        request = RequestFactory().post('/', self.data)
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 302)

        note = SherdNote.objects.get(title='Annotation Test')
        ProjectNote.objects.get(annotation=note, project=project)
コード例 #6
0
ファイル: test_views.py プロジェクト: c0cky/mediathread
    def test_create_annotation_ajax(self):
        request = RequestFactory().post('/', self.data,
                                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 200)

        note = SherdNote.objects.get(title='Annotation Test')

        the_json = loads(response.content)
        self.assertEquals(the_json['asset']['id'], self.asset.id)
        self.assertEquals(the_json['annotation']['id'], note.id)
コード例 #7
0
ファイル: test_views.py プロジェクト: tmnogueira/mediathread
    def test_create_annotation_ajax(self):
        request = RequestFactory().post('/',
                                        self.data,
                                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.student_one
        response = create_annotation(request)
        self.assertEquals(response.status_code, 200)

        note = SherdNote.objects.get(title='Annotation Test')

        the_json = loads(response.content)
        self.assertEquals(the_json['asset']['id'], self.asset.id)
        self.assertEquals(the_json['annotation']['id'], note.id)
コード例 #8
0
ファイル: views.py プロジェクト: ccnmtl/mediathread
def annotation_create(request, asset_id):
    """
    delegate to djangosherd view and redirect back to asset workspace

    but first, stuff a range into the request
    and get the annotation context from the url
    """

    # Verify asset exists
    get_object_or_404(Asset, pk=asset_id, course=request.course)

    form = request.POST.copy()
    form['annotation-context_pk'] = asset_id
    request.POST = form

    form = request.GET.copy()
    form['annotation-next'] = reverse('asset-view', args=[asset_id])
    request.GET = form

    return create_annotation(request)
コード例 #9
0
def annotation_create(request, asset_id):
    """
    delegate to djangosherd view and redirect back to asset workspace

    but first, stuff a range into the request
    and get the annotation context from the url
    """

    # Verify asset exists
    get_object_or_404(Asset, pk=asset_id, course=request.course)

    form = request.POST.copy()
    form['annotation-context_pk'] = asset_id
    request.POST = form

    form = request.GET.copy()
    form['annotation-next'] = reverse('asset-view', args=[asset_id])
    request.GET = form

    return create_annotation(request)