<commit_before>from django.conf import settings
from django.core.cache import cache
from django.contrib.auth.models import User

from djsani.medical_history.models import StudentMedicalHistory
from djsani.medical_history.models import AthleteMedicalHistory
from djsani.medical_history.waivers.models import Sicklecell
from djsani.insurance.models import StudentHealthInsurance
from djsani.core.models import StudentMedicalContentType
from djsani.core.models import StudentMedicalManager
from djtools.utils.users import in_group
from djtools.fields import TODAY

from sqlalchemy.orm.session import make_transient
from sqlalchemy import desc

EARL = settings.INFORMIX_EARL

def get_content_type(session, name):
    """
    simple function to return a content type from cache
    or get and set it if it does not exist in cache.
    default is never to expire.
    """
    ct = cache.get(name)
    if not ct:
        ct = session.query(StudentMedicalContentType).\
                filter_by(name=name).first()
        cache.set(name, ct, None)
    return ct

def facstaff(cid):
    """
    is user faculty or staff?
    """
    try:
        user = User.objects.get(pk=cid)
        status = in_group(user, "carthageStaffStatus","carthageFacultyStatus")
    except:
        status = False
    return status

def _doop(session, mod, man):
    """
    check for an object and duplicate it.
    returns the new object or None
    """
    obj = session.query(mod).filter_by(college_id=man.college_id).\
        order_by(desc(mod.id)).first()

    if obj:
        # copy the previous object to new
        session.expunge(obj)
        make_transient(obj)
        obj.id = None
        obj.created_at = None
        # associate the new obj with the new manager
        obj.manager_id = man.id
        session.add(obj)
        # in case we need PK id
        session.flush()
    return obj

def get_term():
    sess = "RA"
    sd = settings.START_DATE
    r = "RA"
    year = TODAY.year
    if (TODAY.month < sd.month or TODAY.month == 12):
        r = "RC"
        if TODAY.month == 12:
            year = year+1
    return {"yr": year, "sess":r}

def get_manager(session, cid):<commit_msg>removed the december month limit for term for now until we can better handle the times between terms<commit_after>from django.conf import settings
from django.core.cache import cache
from django.contrib.auth.models import User

from djsani.medical_history.models import StudentMedicalHistory
from djsani.medical_history.models import AthleteMedicalHistory
from djsani.medical_history.waivers.models import Sicklecell
from djsani.insurance.models import StudentHealthInsurance
from djsani.core.models import StudentMedicalContentType
from djsani.core.models import StudentMedicalManager
from djtools.utils.users import in_group
from djtools.fields import TODAY

from sqlalchemy.orm.session import make_transient
from sqlalchemy import desc

EARL = settings.INFORMIX_EARL

def get_content_type(session, name):
    """
    simple function to return a content type from cache
    or get and set it if it does not exist in cache.
    default is never to expire.
    """
    ct = cache.get(name)
    if not ct:
        ct = session.query(StudentMedicalContentType).\
                filter_by(name=name).first()
        cache.set(name, ct, None)
    return ct

def facstaff(cid):
    """
    is user faculty or staff?
    """
    try:
        user = User.objects.get(pk=cid)
        status = in_group(user, "carthageStaffStatus","carthageFacultyStatus")
    except:
        status = False
    return status

def _doop(session, mod, man):
    """
    check for an object and duplicate it.
    returns the new object or None
    """
    obj = session.query(mod).filter_by(college_id=man.college_id).\
        order_by(desc(mod.id)).first()

    if obj:
        # copy the previous object to new
        session.expunge(obj)
        make_transient(obj)
        obj.id = None
        obj.created_at = None
        # associate the new obj with the new manager
        obj.manager_id = man.id
        session.add(obj)
        # in case we need PK id
        session.flush()
    return obj

def get_term():
    sess = "RA"
    sd = settings.START_DATE
    r = "RA"
    year = TODAY.year
    #if (TODAY.month < sd.month or TODAY.month == 12):
    if (TODAY.month < sd.month):
        r = "RC"
        #if TODAY.month == 12:
        #    year = year+1
    return {"yr": year, "sess":r}

def get_manager(session, cid):
{'fraction_non_alphanumeric': 0.08591832180316894, 'fraction_numerical': 0.0022316447221602323, 'mean_word_length': 2.837328767123288, 'pattern_counts': {'":': 4, '<': 6, '<?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': '3472562', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1346, 'n_words': 415}