def show_form(request): console.log('notes.views.show_form - request:') console.log(request) fmt = Format.objects.get(pk=1) # wrk = Annotation.objects.get(pk=) form = AnnotationForm(fmt) ctx = RequestContext(request,{'form' : form}) return HttpResponse(form.as_table())
def _handle_update(request,note): if not note.can_edit(request.user): return HttpResponseForbidden() form = AnnotationForm(request.POST) if form.is_valid(): note.comment = form.cleaned_data['comment'] note.save() return HttpResponse(_serialize_annotation(note), mimetype="application/json") else: return HttpReponse(unicode(form.errors))
def update(self, request, creator_id, annotation_id, **kwargs): """ This function updates annotation. Annotation instance should have id. """ try: # instance = Annotation.objects.get(id=request.form.cleaned_data['id']) instance = Annotation.annotations.active().get(id=annotation_id, author__id=creator_id) form = AnnotationForm(request.PUT, instance=instance) if form.is_valid(): return form.save() return form except Annotation.DoesNotExist as e: return rc.NOT_FOUND
def ocvePageImageview(request, id, selectedregionid=0): mode = "OCVE" noteURL = "/ocve/getAnnotationRegions/" + id + "/" regionURL = "/ocve/getBarRegions/" + id + "/" view = request.GET.get('view') pi = PageImage.objects.get(id=id) p = pi.page annotation = Annotation(pageimage=pi) if request.user and request.user.id: ocve_user = OCVEUser.objects.get(id=request.user.id) annotation.user = ocve_user annotationForm = AnnotationForm(instance=annotation) source = pi.page.sourcecomponent.source accode = source.getAcCodeObject() achash = None if accode: achash = accode.accode_hash pageimages = getOCVEPageImages(source) cursor = connections['ocve_db'].cursor() cursor.execute("""select bar.barlabel, pi.id from ocve_bar as bar, ocve_bar_barregion as brr, ocve_barregion as barregion, ocve_pageimage as pi, ocve_page as p, ocve_sourcecomponent as sc where bar.id=brr.bar_id and brr.barregion_id=barregion.id and barregion.pageimage_id=pi.id and pi.page_id=p.id and p.sourcecomponent_id=sc.id and sc.source_id=""" + str(source.id) + " order by bar.barnumber") notes = Annotation.objects.filter(pageimage_id=id, type_id=1) comments = Annotation.objects.filter(pageimage_id=id, type_id=2) [next_page, prev_page] = getNextPrevPages(pi, pageimages) work = getPageImageWork(pi, source) #Check if work has information so we don't display dead link if len(work.workinformation.OCVE) > 0: workinfoexists = True else: workinfoexists = False if pi.width == 0: #Resolution not set, add addImageDimensions(pi) zoomifyURL = pi.getZoomifyPath() request.session['page_image'] = id return render_to_response('frontend/pageview.html', { 'workinfoexists': workinfoexists, 'selectedregionid': selectedregionid, 'achash': achash, 'annotationForm': annotationForm, 'notes': notes, 'comments': comments, 'allBars': cursor, 'work': work, 'source': source, 'prev': prev_page, 'next': next_page, 'IMAGE_SERVER_URL': settings.IMAGE_SERVER_URL, 'pageimages': pageimages, 'mode': mode, 'zoomifyURL': zoomifyURL, 'regionURL': regionURL, 'noteURL': noteURL, 'page': p, 'pageimage': pi, 'view': view }, context_instance=RequestContext(request))