<commit_before># -*- coding: utf-8 -*-
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required

from exam.models import ExamType
from exam.forms import get_exam_form
from exam.dynamic_import import create_specific_exam
from patients.models import Paciente
from core.views import user_belongs_to_groups


@login_required(login_url='/', redirect_field_name='')
def new_exam(request):
    exam_types = ExamType.objects.all()
    patient_id = request.POST.get("patient_id")
    patient = Paciente.objects.using("hub").get(codigo=patient_id)

    if user_belongs_to_groups(request.user, ['Staff Doctor', 'Administrative', 'Assistant Medical', 'Resident Doctor']):
        return render_to_response(
           'new_exam.html',
            {"exam_types": exam_types,
            "patient": patient},
            context_instance=RequestContext(request)
        )

    return render_to_response(
       '403.html',
        context_instance=RequestContext(request)
    )

@login_required(login_url='/', redirect_field_name='')
def register_exam(request):
    exam = get_exam_form(request)
    exam.save()

    specific_exam = create_specific_exam(
        exam.exam_type.name_class)
    specific_exam.exam = exam
    specific_exam.save()

    exam_type_id = request.POST['exam_type']
    exam_type = ExamType.objects.get(pk=exam_type_id).name_class
    template_exam = 'new_' + exam_type.lower() + '.html'

    return render_to_response(
        template_exam,
        {"exam_id": exam.id},
        context_instance=RequestContext(request)
    )
<commit_msg>An exam type should to redirect a specific url<commit_after># -*- coding: utf-8 -*-
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required

from exam.models import ExamType
from exam.forms import get_exam_form
from exam.dynamic_import import create_specific_exam
from patients.models import Paciente
from core.views import user_belongs_to_groups


@login_required(login_url='/', redirect_field_name='')
def new_exam(request):
    exam_types = ExamType.objects.all()
    patient_id = request.POST.get("patient_id")
    patient = Paciente.objects.using("hub").get(codigo=patient_id)

    if user_belongs_to_groups(request.user, ['Staff Doctor', 'Administrative', 'Assistant Medical', 'Resident Doctor']):
        return render_to_response(
           'new_exam.html',
            {"exam_types": exam_types,
            "patient": patient},
            context_instance=RequestContext(request)
        )

    return render_to_response(
       '403.html',
        context_instance=RequestContext(request)
    )

@login_required(login_url='/', redirect_field_name='')
def register_exam(request):
    exam = get_exam_form(request)
    exam.save()

    specific_exam = create_specific_exam(
        exam.exam_type.name_class)
    specific_exam.exam = exam
    specific_exam.save()

    exam_type_id = request.POST['exam_type']

    if exam_type_id == '1':
        return redirect('/biopsia/nova/')
    elif exam_type_id == '2':
        return redirect('/necropsia/novo')
    elif exam_type_id == '3':
        return redirect('/citologia/nova')
    elif exam_type_id == '4':
        return redirect('/imunohistoquimica/nova')

    # exam_type = ExamType.objects.get(pk=exam_type_id).name_class
    # template_exam = 'new_' + exam_type.lower() + '.html'

    # return render_to_response(
    #     template_exam,
    #     {"exam_id": exam.id},
    #     context_instance=RequestContext(request)
    # )

{'fraction_non_alphanumeric': 0.10900604063701264, 'fraction_numerical': 0.0032948929159802307, 'mean_word_length': 3.7808398950131235, 'pattern_counts': {'":': 6, '<': 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': '2677354', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1149, 'n_words': 215}