<commit_before>from django.shortcuts import render, render_to_response
from django.http import HttpResponse
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt

from .mongo_support_functions import CreateFromPOSTinfo
from .models import Annotation



def index(request):
    return HttpResponse("replace me with index text")

def hostpage(request):
    return render(request, 'searchapp/hostpage.html', {'iframe_on': 350})


# forbidden CSRF verification failed. Request aborted.
@csrf_exempt
def interface_main(request):
    
    if request.POST.get('ontology_json'):
        annotation_list = CreateFromPOSTinfo( request.POST.get('subject_tofeed'), request.POST.get('ontology_json') )
        

    annotation_list = Annotation.objects.all()

    pid_tofeed = ""
    if request.POST.get('pid_tofeed')!=None:
        pid_tofeed = request.POST.get('pid_tofeed')

    if request.POST.get('subject_tofeed')==None:
        context = RequestContext(request, {
	        'annotation_list': annotation_list,
                'subject_tofeed': "",
                'pid_tofeed': pid_tofeed,
        })
    else:
        #print request.POST.get('subject_tofeed')
        context = RequestContext(request, {
	        'annotation_list': annotation_list,
                'subject_tofeed': request.POST.get('subject_tofeed'),
                'pid_tofeed': pid_tofeed,
        })
    return render_to_response('searchapp/interface_main.html', context)
<commit_msg>Separate view for creating an annotation<commit_after>from django.shortcuts import render, render_to_response
from django.http import HttpResponse
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt

from .mongo_support_functions import CreateFromPOSTinfo
from .models import Annotation



def index(request):
    return HttpResponse("replace me with index text")

def hostpage(request):
    return render(request, 'searchapp/hostpage.html', {'iframe_on': 350})


# forbidden CSRF verification failed. Request aborted.
@csrf_exempt
def create_annotation(request):

    annotation_list = Annotation.objects.all()

    if request.POST.get('ontology_json'):
        annotation_list = CreateFromPOSTinfo( request.POST.get('subject_tofeed'), request.POST.get('ontology_json') )

    subject_tofeed = ""
    if request.POST.get('subject_tofeed')!=None:
        subject_tofeed = request.POST.get('subject_tofeed')

    pid_tofeed = ""
    if request.POST.get('pid_tofeed')!=None:
        pid_tofeed = request.POST.get('pid_tofeed')

    context = RequestContext(request, {
        'annotation_list': annotation_list,
        'subject_tofeed': subject_tofeed,
        'pid_tofeed': pid_tofeed,
    })
    return render_to_response('searchapp/interface_main.html', context)


# forbidden CSRF verification failed. Request aborted.
@csrf_exempt
def interface_main(request):
    
    if request.POST.get('ontology_json'):
        annotation_list = CreateFromPOSTinfo( request.POST.get('subject_tofeed'), request.POST.get('ontology_json') )
        

    annotation_list = Annotation.objects.all()

    pid_tofeed = ""
    if request.POST.get('pid_tofeed')!=None:
        pid_tofeed = request.POST.get('pid_tofeed')

    if request.POST.get('subject_tofeed')==None:
        context = RequestContext(request, {
	        'annotation_list': annotation_list,
                'subject_tofeed': "",
                'pid_tofeed': pid_tofeed,
        })
    else:
        #print request.POST.get('subject_tofeed')
        context = RequestContext(request, {
	        'annotation_list': annotation_list,
                'subject_tofeed': request.POST.get('subject_tofeed'),
                'pid_tofeed': pid_tofeed,
        })
    return render_to_response('searchapp/interface_main.html', context)

{'fraction_non_alphanumeric': 0.108023072889355, 'fraction_numerical': 0.0015731515469323545, 'mean_word_length': 3.6186440677966103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7176791', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1103, 'n_words': 213}