<commit_before>from django.shortcuts import render_to_response, RequestContext
from django.shortcuts import redirect
from django.views.generic.base import View
from django.core.urlresolvers import reverse
from django.contrib.auth.models import Group


# todo update ophg registries to use new demographics and patients listing forms: we need to fix this properly
def in_fkrp(user):
    user_reg_codes = [ r.code for r in user.registry.all()]
    return "fkrp" in user_reg_codes


class RouterView(View):

    def get(self, request):
        user = request.user
        
        redirect_url = None

        if user.is_authenticated():
            if user.is_superuser:
                redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_clinician:
                if in_fkrp(user):
                    redirect_url = reverse("patientslisting")
                else:
                    redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_genetic_staff:
                redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_working_group_staff:
                redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_genetic_curator:
                redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_curator:
                redirect_url = reverse("admin:patients_patient_changelist")
            elif user.is_patient:
                regs = user.get_registries()
                if regs:
                    if len(regs) == 1:
                        redirect_url = reverse("patient_page", args=[regs[0].code])
            else:<commit_msg>FKRP-95 Login routing for FKRP users<commit_after>from django.shortcuts import render_to_response, RequestContext
from django.shortcuts import redirect
from django.views.generic.base import View
from django.core.urlresolvers import reverse
from django.contrib.auth.models import Group


# todo update ophg registries to use new demographics and patients listing forms: we need to fix this properly
def in_fkrp(user):
    user_reg_codes = [ r.code for r in user.registry.all()]
    return "fkrp" in user_reg_codes

_ADMIN_PATIENT_LISTING = "admin:patients_patient_changelist"
_NEW_PATIENT_LISTING = "patientslisting"

class RouterView(View):

    def get(self, request):
        user = request.user
        
        redirect_url = None

        if user.is_authenticated():
            if user.is_superuser:
                redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_clinician:
                if in_fkrp(user):
                    redirect_url = reverse(_NEW_PATIENT_LISTING)
                else:
                    redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_genetic_staff:
                redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_working_group_staff:
                redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_genetic_curator:
                redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_curator:
                if in_fkrp(user):
                    redirect_url = reverse(_NEW_PATIENT_LISTING)
                else:
                    redirect_url = reverse(_ADMIN_PATIENT_LISTING)
            elif user.is_patient:
                regs = user.get_registries()
                if regs:
                    if len(regs) == 1:
                        redirect_url = reverse("patient_page", args=[regs[0].code])
            else:
{'fraction_non_alphanumeric': 0.0684931506849315, 'fraction_numerical': 0.0016773832820799553, 'mean_word_length': 2.2263300270513975, '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': '5077701', 'n_tokens_mistral': 1038, 'n_tokens_neox': 960, 'n_words': 221}