Example #1
0
def special_trust_managers(request):

    USER_EID = request.META['HTTP_UTLOGIN_EID']

    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)

    filt = '(&(utexasEduPersonSpecialTrustSw=Y)(eduPersonOrgDN=ou=UTAUS,ou=institutions,dc=entdir,dc=utexas,dc=edu)(manager=uid='+USER_EID+',ou=people,dc=entdir,dc=utexas,dc=edu))'

    attrs = ['utexasEduPersonEid','mail','displayName','utexasedupersonprimarytitle']

    search = conn.search(filt, attrs=attrs)

    subordinates = []

    for item in search:
        tmp = []
        tmp.append(item['utexasEduPersonEid'][0])
        tmp.append(item['mail'][0])
        tmp.append(item['displayName'][0])
        tmp.append(item['utexasEduPersonPrimaryTitle'][0])
        tmp.append(last_post_or_never(tmp[0]))
        
        if tmp[4] == 'Never' or strtotime(tmp[4]) < strtotime('-1 year -2 weeks'):
            tmp.append('<span class="overdue">Overdue</span>')
        elif strtotime(tmp[4]) <= strtotime('-1 year'):
            tmp.append('Due')
        else:
            tmp.append('Current')

        subordinates.append(tmp)
    
    subordinates.sort()

    person = {'eid':USER_EID}

    return render(request, 'forms/specialtrust_manager.html', {
        'person': person,
        'subordinates': subordinates
    })
Example #2
0
def quarterly_summaries(request):
    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)
    
    managers = {}
    users_to_managers = {}
    post_users = []

    filt = '(&(utexasEduPersonSpecialTrustSw=Y)(eduPersonOrgDN=ou=UTAUS,ou=institutions,dc=entdir,dc=utexas,dc=edu))'

    attrs = ['utexasEduPersonEid','displayName']

    search = conn.search(filt, attrs=attrs)
    
    # GET SPECIAL TRUST USERS
    for item in search:
        if item['utexasEduPersonEid']:
            tmp = []
            tmp.append(item['displayName'][0])
            tmp.append(item['utexasEduPersonEid'][0])
            post_users.append(tmp)  
    post_users.sort()

    special_trust_users = []

    for user in post_users:
        name = user[0]
        eid = user[1]

        dept_name = ''
        manager_eid = ''
        manager_name = ''
        manager_email = ''
    
        attrs = ['displayName','manager','edupersonorgunitdn']

        p = conn.get_by_eid(eid, attrs=attrs)

        if 'edupersonorgunitdn' in p:
            dept_name = p['edupersonorgunitdn']
            if len(dept_name) < 2:
                if 'manager' in p:
                    manager_eid = p['manager'][0].split(',')[0][4:]

                if manager_eid:


                    #used for testing
                    snth = []
                    snth.append(eid)
                    snth.append(name)
                    snth.append(manager_eid)
                    special_trust_users.append(snth)


                    attrs = ['displayName','mail']
                    conn1 = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)
                    if manager_eid not in managers:
                        q = conn1.get_by_eid(manager_eid, attrs=attrs)
                        manager_name = q['displayName'][0]
                        if 'mail' in q:
                            manager_email = q['mail'][0]
                        manager_info = {
                            'name' : manager_name,
                            'email' : manager_email
                        }
                        managers[manager_eid] = {
                            'info' : manager_info,
                            'done' : {},
                            'notdone' : {}
                        }    
                    managers[manager_eid]['notdone'][eid] = name
                    users_to_managers[eid] = manager_eid


    active = active_entries()

    #used for testing
    active_people = []


    other_people = []


    for entry in active:
        name = entry[0]
        eid = entry[1]

        snth = []
        snth.append(eid)
        snth.append(name)
        active_people.append(snth)

        if eid in users_to_managers: # and eid in managers[manager_eid]['notdone']
            manager_eid = users_to_managers[eid]
            if eid in managers[manager_eid]['notdone']:
                managers[manager_eid]['done'][eid] = managers[manager_eid]['notdone'].pop(eid)
        else:
            other_people.append(eid+" "+name)

    managers_no_email = {}
    aoeu = []

    for manager_eid, key in managers.iteritems():
        if key['info']['email']:
            name = key['info']['name']
            email = key['info']['email']
            done = key['done']
            notdone = key['notdone']
            tmp = []
            tmp.append(name)
            tmp.append(email)
            tmp.append(done)
            tmp.append(notdone)
            aoeu.append(tmp)
            # cron_send_manager_quarterly_summary_mail(name, email, done, notdone)
        else:
            managers_no_email[manager_eid] = managers[manager_eid]['info']['name']

    # if managers_no_email:
    #     for key, value in managers_no_email.iteritems():

        # cron_send_audit_quarterly_warning_mail(managers_no_email)

    return render(request, 'forms/quarterly_summaries.html', {
        'special_trust_users':special_trust_users,
        'active_people': active_people,
        'aoeu':aoeu,
        'managers_no_email':managers_no_email,
        'other_people':other_people
    })
Example #3
0
def notify_users(request):
    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)
    notify_users = []

    filt = '(&(utexasEduPersonSpecialTrustSw=Y)(eduPersonOrgDN=ou=UTAUS,ou=institutions,dc=entdir,dc=utexas,dc=edu))'

    attrs = ['utexasEduPersonEid','mail','displayName']

    search = conn.search(filt, attrs=attrs)
    
    # GET SPECIAL TRUST USERS
    for item in search:
        if item['utexasEduPersonEid']:
            tmp = []
            tmp.append(item['displayName'][0])
            tmp.append(item['utexasEduPersonEid'][0])
            
            if 'mail' in item:
                tmp.append(item['mail'][0])
            else:
                tmp.append('')
            
            notify_users.append(tmp)  
    notify_users.sort()

    unable_to_notify = []

    active = active_eids()

    # Remove active eids from notify_users
    notify_users = [user for user in notify_users if user[1] not in active]
    timestamp = strtotime('-1 year -2 weeks')
    cc_manager_date = datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d')

    users_to_notify = []
    l = len(notify_users)

    for user in notify_users:
        name = user[0]
        eid = user[1]
        email = user[2]
        if email:
            attrs = ['cn','manager','edupersonorgunitdn']

            p = conn.get_by_eid(eid, attrs=attrs)

            manager = ''
            manager_email = ''
            dept_name = ''
            tmp = []

            if 'manager' in p:
                manager = p['manager'][0].split(',')[0][4:]
                attrs = ['cn','mail']
                conn1 = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)
                if manager:
                    q = conn1.get_by_eid(manager, attrs=attrs)
                if 'mail' in q:
                    manager_email = q['mail'][0]

            if 'edupersonorgunitdn' in p:
                dept_name = p['edupersonorgunitdn']

            if len(dept_name) < 2:
                # if last_post(eid) <= cc_manager_date and manager:
            
                tmp.append(eid)
                tmp.append(name)
                tmp.append(email)
                tmp.append(manager_email)                
                tmp.append(last_post(eid))
                tmp.append(cc_manager_date)
                users_to_notify.append(tmp)
                    # cron_send_user_mail(eid,name,email,manager_email)
        else:
            unable_to_notify.append(eid)

        # cron_send_iso_mail( len(notify_users), unable_to_notify)

    #delete this after
    unable_to_notify.sort()

    return render(request, 'forms/notify_users.html', {
        'l':l,
        'users_count': len(users_to_notify),
        'users_to_notify': users_to_notify,
        'unable_count': len(unable_to_notify),
        'unable_to_notify': unable_to_notify
    })
Example #4
0
def pdf_view(request):
    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)

    USER_EID = request.META['HTTP_UTLOGIN_EID']
    USER_NAME = request.META['HTTP_UTLOGIN_NAME']
    
    attrs = [
        'cn',
        'givenName',
        'sn',
        'utexasEduPersonOrgUnitName',
        'utexasEduPersonPrimaryTitle',
        'utexasEduPersonOrgUnitName',
        'manager',
        'utexasEduPersonOfficeLocation',
        'telephoneNumber'
    ]

    p = conn.get_by_eid(USER_EID, attrs=attrs)

    USER_TITLE = p['utexasedupersonprimarytitle'][0]
    WORKPLACE = p['utexasedupersonorgunitname'][0]
    MANAGER = p['manager'][0]

    MANAGER_LST = MANAGER.replace('=',',').split(',')
    MANAGER_EID = MANAGER_LST[1]
    MANAGER_NAME = ''
    if 'restrict' in MANAGER_LST:
        MANAGER_NAME = 'your manager'
    else:
        mngr_attrs= ['cn']
        q = conn.get_by_eid(MANAGER_EID, attrs=mngr_attrs)
        MANAGER_NAME = q['cn'][0]

    USER_DEPARTMENT  = p['utexasEduPersonOrgUnitName'][0]
    USER_ROOM = p['utexasEduPersonOfficeLocation'][0]
    
    if 'telephoneNumber' in p:
        USER_WORKPHONE = p['telephoneNumber']
    else:
        USER_WORKPHONE = 'N/A'

    AGREE = request.POST.get('agree', 'electronically declined')

    dt = datetime.now()
    df = DateFormat(dt)

    textdate = str(df.format(get_format('DATE_FORMAT')))

    timestamp = str(df.format('m/d/Y')) + " at " + str(time.strftime("%H:%M:%S"))

    stamp = last_valid_post(USER_EID)
    stamp_textdate = ' '.join(stamp.split(' ')[:-1])
    stamp_time = ''.join(stamp.split(' ')[-1])
    tmp = stamp_textdate.replace(',','')
    stamp_date = str(datetime.strptime(tmp, '%B %d %Y').strftime('%m/%d/%Y'))
    # stamp_date = tmp
    msg = "I acknowledge my role as a Custodian of The University of Texas at Austin Information Resources."+ \
        " I realize that I have been assigned duties that will bring me in contact with information or information"+\
        " resources that are of value to the university and that require confidentiality and protection."+\
        " I further acknowledge that I am required to uphold university policies and standards to safeguard "+\
        "the information and associated resources that are entrusted to me or with which I have contact."+\
        " I agree to report violations of policies, standards, procedures, or guidelines that come to my attention "+\
        "to my supervisor and/or the Information Security Office.\n\nI understand and agree that violations of "+\
        "university policies, standards, and procedures pertaining to custodians of the university's Information Resources "+\
        "and confidential information shall be subject to disciplinary action up to and including termination.\n\n" +\
        USER_NAME +' '+ AGREE + \
        " concurrence with this responsibility on "+\
        stamp_textdate +\
        " for the job title and department listed above.\n\nThis form has been submitted to "+\
        MANAGER_NAME +\
        " and the Information Security Office.\n\nForm submitted: "+\
        stamp_date + ' at ' + stamp_time + \
        " \n\nReferences:\n\n"

    reference_links = [
        ["http://www.utexas.edu/cio/policies/pdfs/AUP.pdf", "UT Austin Acceptable Use Policy", "(section V, rule 11)"],
        ["http://www.utexas.edu/cio/policies/pdfs/Information%20Resources%20Use%20and%20Security%20Policy.pdf",
            "UT Austin Inform.ation Resources Use and Security Policy","(section V, item 4)"],
        ["http://www.utsystem.edu/policy/policies/uts165.html","UT System Information Resources Use and Security Policy","(section 4)"],
        ["http://info.sos.state.tx.us/pls/pub/readtac$ext.TacPage?sl=R&app=9&p_dir=&p_rloc=&p_tloc=&p_ploc=&pg=1&ti=1&ch=202&rl=75",
            "Texas Administrative Code 202", "(Rule 202.75, 7.C)"],
        ["http://www.statutes.legis.state.tx.us/Docs/PE/htm/PE.33.htm", "Texas Computer Crimes Act",'' ]
    ]

    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'filename="download.pdf"'

    pdf = MyFPDF()
    pdf.add_page()

    pdf.set_left_margin(20)
    pdf.set_right_margin(20)

    pdf.set_font('Times','',12)

    pdf.set_line_width(0.1)
    pdf.line(20,12,196,12)
    pdf.set_xy(14,5)
    pdf.cell(0,10,'POSITION OF SPECIAL TRUST FORM',border=0,ln=1,align='C')
    pdf.cell(0,0,'The University of Texas at Austin',border=0,ln=1,align='C')

    pdf.set_xy(20,20)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Employee EID:")
    pdf.set_xy(60,20)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_EID)

    pdf.set_xy(20,25)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Employee Name:") 
    pdf.set_xy(60,25)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_NAME)

    pdf.set_xy(20,30)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Title:")
    pdf.set_xy(60,30)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_TITLE)

    pdf.set_xy(20,35)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Department:")
    pdf.set_xy(60,35)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_DEPARTMENT)

    pdf.set_xy(20,40)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Room Number:")
    pdf.set_xy(60,40)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_ROOM)

    pdf.set_xy(20,45)
    pdf.set_font('Times','B',12)
    pdf.write(3,"Office Phone:")
    pdf.set_xy(60,45)
    pdf.set_font('Times','',12)
    pdf.write(3,USER_WORKPHONE)

    pdf.set_xy(20,55)
    pdf.write(5,msg)

    for link in reference_links:
        tmp = '<a href="'+link[0]+'">'+link[1]+'</a>'
        pdf.write_html(tmp)
        pdf.write(5, ' '+link[2]+'\n')
        pdf.set_font('Times','',9)
        tmp = '['+ link[0]+']\n'
        pdf.write(5,tmp)
        pdf.set_font('Times','',12)

    response.write(pdf.output('','S'))
    return response
Example #5
0
def special_trust_hrcontacts(request):

    USER_EID = request.META['HTTP_UTLOGIN_EID']

    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)
    
    filt = '(&(utexasEduRoleSource=OHSC)(member=uid='+USER_EID+',ou=people,dc=entdir,dc=utexas,dc=edu)(|(utexasEduRoleCode=0HC001)(utexasEduRoleCode=0DC200)(utexasEduRoleCode=0UN004))(utexasEduRoleAttribute=All))'

    attrs = ['utexasEduRoleScope']
    search = conn.search(filt, attrs=attrs)
    
    subordinates = []
    dept_search = ''
    filt = ''

    if len(search):

        for item in search:
            dept_search += "(eduPersonOrgUnitDn="+item['utexasEduRoleScope'][0]+")"

        if len(search) > 1:
            dept_search = "(|" + dept_search

        dept_search += ")"

        attrs = [
            'utexasEduPersonEid',
            'mail',
            'displayName',
            'title',
            'edupersonorgunitDN'
        ]

        filt = "(&(utexasEduPersonSpecialTrustSw=Y)(eduPersonOrgDN=ou=UTAUS,ou=institutions,dc=entdir,dc=utexas,dc=edu)" + dept_search+")"

        search = conn.search(filt, attrs=attrs)

        for item in search:
            if item['utexasEduPersonEid']:
                tmp = []
                tmp.append(item['displayName'][0])
                tmp.append(item['utexasEduPersonEid'][0])
                tmp.append(item['title'][0])
                
                if 'mail' in item:
                    tmp.append(item['mail'][0])
                else:
                    tmp.append('')
                
                tmp.append(last_post_or_never(tmp[1]))
                
                if tmp[4] == 'Never' or strtotime(tmp[4]) < strtotime('-1 year -2 weeks'):
                    tmp.append('<span class="overdue">Overdue</span>')
                elif strtotime(tmp[4]) <= strtotime('-1 year'):
                    tmp.append('Due')
                else:
                    tmp.append('Current')
                
                dept_name = item['eduPersonOrgUnitDn'][0].split(',')[0][6:].upper()
                tmp.append(dept_name)
                subordinates.append(tmp)  
        subordinates.sort()

    person = {'eid':USER_EID}

    return render(request, 'forms/specialtrust_hrcontacts.html', {
        'person': person,
        'subordinates': subordinates,
    })
Example #6
0
def special_trust_form(request):
    USER_EID = request.META['HTTP_UTLOGIN_EID']
    USER_NAME = request.META['HTTP_UTLOGIN_NAME']

    conn = TEDConnection(eid=SERVICE_EID, password=SERVICE_PASS)

    attrs = [
        'cn',
        'givenName',
        'sn',
        'utexasEduPersonPrimaryTitle',
        'utexasEduPersonOrgUnitName',
        'edupersonorgunitdn',
        'manager',
        'utexasEduPersonOfficeLocation',
        'telephoneNumber',
        'mail'
    ]
 
    p = conn.get_by_eid(USER_EID, attrs=attrs)

    USER_TITLE = p['utexasedupersonprimarytitle'][0]
    USER_MAIL = p['mail'][0]
    WORKPLACE = p['utexasedupersonorgunitname'][0]
    MANAGER = p['manager'][0]

    MANAGER_LST = MANAGER.replace('=',',').split(',')
    MANAGER_EID = MANAGER_LST[1]
    MANAGER_NAME = ''
    MANAGER_EMAIL = ''
    if 'restrict' in MANAGER_LST:
        MANAGER_NAME = 'your manager'
    else:
        mngr_attrs= [
            'cn',
            'mail'
        ]
        q = conn.get_by_eid(MANAGER_EID, attrs=mngr_attrs)
        MANAGER_NAME = q['cn'][0]
        MANAGER_EMAIL = q['mail'][0]

    USER_DEPARTMENT  = p['utexasEduPersonOrgUnitName'][0]
    DEPARTMENT = p['edupersonorgunitdn'][0].split(',')[0][6:]
    USER_ROOM = p['utexasEduPersonOfficeLocation'][0]
    
    if 'telephoneNumber' in p:
        USER_WORKPHONE = p['telephoneNumber']
    else:
        USER_WORKPHONE = 'N/A'

    info = {
        'eid':USER_EID,
        'name':USER_NAME,
        'title':USER_TITLE,
        'manager_name':MANAGER_NAME,
        'manager_eid': MANAGER_EID,
        'room':USER_ROOM,
        'phone':USER_WORKPHONE,
        'dept':USER_DEPARTMENT
    }

    if request.method == 'GET':
        last_date = last_valid_post(USER_EID)
        skip_check = request.GET.get('skip_check','')

        if not skip_check and last_date:
            return HttpResponseRedirect("/forms/specialtrust/exists/")
            
        form = SpecialTrustForm()
    else:
        form = SpecialTrustForm(request.POST)

        if form.is_valid():
            answer = str(form.cleaned_data['acceptance']).lower()

            answer = 1 if answer == "i agree" else 0

            add_entry(USER_EID, USER_NAME, DEPARTMENT, MANAGER_EID, MANAGER_NAME, USER_DEPARTMENT, answer)

            send_accept_mail(answer, USE_EID, USER_NAME, USER_MAIL, USER_TITLE, USER_DEPARTMENT,
                USER_ROOM, USER_WORKPHONE, MANAGER_EID, MANAGER_NAME, MANAGER_EMAIL)

            form_url = '/forms/specialtrust/accept/'
            return HttpResponseRedirect((str(form_url)))
 
    return render(request, 'forms/specialtrust_form.html', {
        'form': form,
        'info': info 
    })