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 })
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 })
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 })
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, })