def profiles_you_can_view(cls, user): if user.is_superuser: return MemberProfile.get_members() current_positions = cls.get_current_officer_positions(user) query_all = (Q(position__name='President') | Q(position__name='Vice President') | Q(position__name='Graduate Student Vice President')) query_actives = Q(position__name='Membership Officer') query_electees = Q(position__name='Graduate Student Coordinator') query_electee_groups = (Q(leaders=user.userprofile.memberprofile) | Q(officers=user.userprofile.memberprofile)) query_out = MemberProfile.objects.none() if current_positions: if current_positions.filter(query_all).exists(): return MemberProfile.get_members() if current_positions.filter(query_actives).exists(): query_out = query_out | MemberProfile.get_actives() if current_positions.filter(query_electees).exists(): query_out = query_out | MemberProfile.get_electees() electee_groups_led = ElecteeGroup.objects.filter( query_electee_groups ).filter(term=AcademicTerm.get_current_term()) for electee_group in electee_groups_led: query_out = query_out | electee_group.members.all() return query_out
def profiles_you_can_view(cls, user): if user.is_superuser: return MemberProfile.get_members() current_positions = cls.get_current_officer_positions(user) query_all = (Q(position__name='President') | Q(position__name='Vice President') | Q(position__name='Graduate Student Vice President')) query_actives = Q(position__name='Membership Officer') query_electees = Q(position__name='Graduate Student Coordinator') query_electee_groups = (Q(leaders=user.userprofile.memberprofile) | Q(officers=user.userprofile.memberprofile)) query_out = MemberProfile.objects.none() if current_positions: if current_positions.filter(query_all).exists(): return MemberProfile.get_members() if current_positions.filter(query_actives).exists(): query_out = query_out | MemberProfile.get_actives() if current_positions.filter(query_electees).exists(): query_out = query_out | MemberProfile.get_electees() electee_groups_led = ElecteeGroup.objects.filter( query_electee_groups ).filter(term=AcademicTerm.get_current_term()) for electee_group in electee_groups_led: query_out = query_out | electee_group.members.all() return query_out
def get_unassigned_electees(): current_electee_groups = ElecteeGroup.objects.filter( term=AcademicTerm.get_current_term() ) current_electees = MemberProfile.get_electees() for group in current_electee_groups.all(): current_electees = current_electees.exclude(pk__in=group.members.all()) return current_electees.order_by('standing', 'last_name')
def get_unassigned_electees(): current_electee_groups = ElecteeGroup.objects.filter( term=AcademicTerm.get_current_term() ) current_electees = MemberProfile.get_electees() for group in current_electee_groups.all(): current_electees = current_electees.exclude(pk__in=group.members.all()) return current_electees.order_by('standing', 'last_name')
class ExternalServiceForm(forms.ModelForm): member = forms.ModelChoiceField( widget=Select2Widget(), queryset=MemberProfile.get_electees() ) class Meta: model = ProgressItem exclude = ('term', 'date_completed', 'event_type', 'related_event')
def get_quorum_list_elections(): term = AcademicTerm.get_current_term() all_actives = MemberProfile.get_actives() electees = MemberProfile.get_electees() active_actives = get_active_members(term) members_who_graduated = get_members_who_graduated() actual_actives = get_active_members_who_came_to_something(term) potential_actives = get_active_members_only_if_they_come( term, is_last_voting_meeting=True ) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="MemberStatus.csv"' writer = UnicodeWriter(response) writer.writerow([ 'First Name', 'Last Name', 'uniqname', 'Active?', 'Alumni?', 'Present' ]) for m in all_actives: if m in potential_actives: active = 'If present' elif m in actual_actives: active = 'Yes' elif m.standing.name == 'Alumni': active = 'Confirm Manually' else: active = 'No' if m in members_who_graduated: alum_text = 'Maybe' elif m.standing.name == 'Alumni': alum_text = 'Yes' else: alum_text = 'No' writer.writerow([ m.first_name, m.last_name, m.uniqname, active, alum_text, '' ]) for m in electees: writer.writerow([ m.first_name, m.last_name, m.uniqname, 'Electee', 'No', '' ]) return response
def compile_electee_resumes(): try: shutil.rmtree(ELECTEE_RESUME_LOCATION) except OSError: pass os.makedirs(ELECTEE_RESUME_LOCATION) electees = MemberProfile.get_electees() for electee in electees: if electee.resume: standing_dir = os.path.sep.join([ELECTEE_RESUME_LOCATION,slugify(electee.standing.name)]) if not os.path.exists(standing_dir): os.makedirs(standing_dir) resume_name=slugify(electee.last_name+'_'+electee.first_name+'_'+electee.uniqname)+'.pdf' shutil.copy(PROJECT_PATH+electee.resume.url,os.path.sep.join([standing_dir,resume_name]))
def compile_electee_resumes(): try: shutil.rmtree(ELECTEE_RESUME_LOCATION()) except OSError: pass media_parent = '/'.join(settings.MEDIA_ROOT.split('/')[:-2])+'/' os.makedirs(ELECTEE_RESUME_LOCATION()) electees = MemberProfile.get_electees() for electee in electees: if electee.resume: standing_dir = os.path.sep.join([ELECTEE_RESUME_LOCATION(),slugify(electee.standing.name)]) if not os.path.exists(standing_dir): os.makedirs(standing_dir) resume_name=slugify(electee.last_name+'_'+electee.first_name+'_'+electee.uniqname)+'.pdf' shutil.copy(media_parent+electee.resume.url,os.path.sep.join([standing_dir,resume_name]))
def compile_electee_resumes(): try: shutil.rmtree(ELECTEE_RESUME_LOCATION()) except OSError: pass media_parent = '/'.join(settings.MEDIA_ROOT.split('/')[:-2])+'/' os.makedirs(ELECTEE_RESUME_LOCATION()) electees = MemberProfile.get_electees() for electee in electees: if electee.resume: standing_dir = os.path.sep.join([ELECTEE_RESUME_LOCATION(),slugify(electee.standing.name)]) if not os.path.exists(standing_dir): os.makedirs(standing_dir) resume_name=slugify(electee.last_name+'_'+electee.first_name+'_'+electee.uniqname)+'.pdf' shutil.copy(media_parent+electee.resume.url,os.path.sep.join([standing_dir,resume_name]))
def handle(self,*args,**options): term = AcademicTerm.get_current_term() current_surveys = ElecteeInterviewSurvey.objects.filter(term = term) if current_surveys.exists(): current_survey=current_surveys[0] else: return until_due = (current_survey.due_date - date.today()).days+1 electees = MemberProfile.get_electees() for electee in electees: completed = current_survey.check_if_electee_completed(electee) existing_progress = ProgressItem.objects.filter(member=electee,term=term,event_type__name='Interview Survey') if existing_progress.exists() and not completed: existing_progress.delete() elif completed and not existing_progress.exists(): p = ProgressItem(member=electee,term=term,amount_completed=1,date_completed=date.today(),name='Interview Survey Completed') p.event_type = EventCategory.objects.get(name='Interview Survey') p.save() if options['duedate']: if until_due==1: due_date = "Both are due tonight." else: return else: if until_due == 7 or until_due == 3 or until_due==1: due_date = "Both are due %s."%(current_survey.due_date.strftime("%A, %b %d" )) elif until_due<=0 and until_due>=-7: due_date = "Both were due %s."%(current_survey.due_date.strftime("%A, %b %d" )) else: return body_template = r'''Hi %(electee)s, This is a friendly reminder that you still need to finish the electee survey and upload your resume. %(duedate)s This can be done by visiting https://tbp.engin.umich.edu%(link)s and following the instructions for completing the survey. You can upload a resume from your profile page. Thanks, The TBP Website''' for electee in electees: if current_survey.check_if_electee_completed(electee): continue body=body_template%{'electee':electee.get_firstlast_name(),'link':reverse('electees:complete_survey'),'duedate':due_date} send_mail('[TBP] A friendly reminder to complete your survey.',body,'*****@*****.**',[electee.get_email()],fail_silently=False)
def view_interview_follow_up_table(request): if not Permissions.can_see_follow_up(request.user): request.session['error_message']='You are not authorized to view followups' return get_previous_page(request,alternate='electees:view_electee_groups') electees = MemberProfile.get_electees() electee_data = [] num_followups=0 for electee in electees: follow_ups = ElecteeInterviewFollowup.objects.filter(interview__interviewee_shift__attendees=electee) num_followups=follow_ups.count() if follow_ups.count()>num_followups else num_followups electee_data.append({'electee':electee,'followups':follow_ups}) template = loader.get_template('electees/interview_followup_table.html') interviewer_headers = ['Interviewer %d'%count for count in range(1,num_followups+1)] context_dict = { 'interviewer_headers':interviewer_headers, 'electees':electee_data, 'base':'electees/base_electees.html', } context_dict.update(get_common_context(request)) context_dict.update(get_permissions(request.user)) context = RequestContext(request, context_dict) return HttpResponse(template.render(context))
def view_interview_follow_up_table(request): if not Permissions.can_see_follow_up(request.user): request.session['error_message']='You are not authorized to view followups' return get_previous_page(request,alternate='electees:view_electee_groups') electees = MemberProfile.get_electees() green_electees=[] yellow_electees=[] red_electees=[] blank_electees=[] num_followups=0 for electee in electees: follow_ups = ElecteeInterviewFollowup.objects.filter(interview__interviewee_shift__attendees=electee).exclude(recommendation='X') num_followups=follow_ups.count() if follow_ups.count()>num_followups else num_followups num_red = follow_ups.filter(recommendation='N').count() num_yellow = follow_ups.filter(recommendation='M').count() if num_red: red_electees.append({'electee':electee,'followups':follow_ups}) elif num_yellow: yellow_electees.append({'electee':electee,'followups':follow_ups}) elif follow_ups.count(): green_electees.append({'electee':electee,'followups':follow_ups}) else: blank_electees.append({'electee':electee,'followups':follow_ups}) template = loader.get_template('electees/interview_followup_table.html') interviewer_headers = ['Interviewer %d'%count for count in range(1,num_followups+1)] context_dict = { 'interviewer_headers':interviewer_headers, 'green_electees':green_electees, 'yellow_electees':yellow_electees, 'red_electees':red_electees, 'blank_electees':blank_electees, 'base':'electees/base_electees.html', } context_dict.update(get_common_context(request)) context_dict.update(get_permissions(request.user)) return HttpResponse(template.render(context_dict, request))
class AddElecteeStatusForm(AddStatusForm): member = forms.ModelChoiceField(widget=Select2Widget(), queryset=MemberProfile.get_electees())
def handle(self, *args, **options): term = AcademicTerm.get_current_term() current_surveys = ElecteeInterviewSurvey.objects.filter(term=term) if current_surveys.exists(): current_survey = current_surveys[0] else: return until_due = (current_survey.due_date - date.today()).days + 1 electees = MemberProfile.get_electees() for electee in electees: completed = current_survey.check_if_electee_completed(electee) existing_progress = ProgressItem.objects.filter( member=electee, term=term, event_type__name='Interview Survey') if existing_progress.exists() and not completed: existing_progress.delete() elif completed and not existing_progress.exists(): p = ProgressItem(member=electee, term=term, amount_completed=1, date_completed=date.today(), name='Interview Survey Completed') p.event_type = EventCategory.objects.get( name='Interview Survey') p.save() if options['duedate']: if until_due == 1: due_date = "Both are due tonight." else: return else: if until_due == 7 or until_due == 3 or until_due == 1: due_date = "Both are due %s." % ( current_survey.due_date.strftime("%A, %b %d")) elif until_due <= 0 and until_due >= -7: due_date = "Both were due %s." % ( current_survey.due_date.strftime("%A, %b %d")) else: return body_template = r'''Hi %(electee)s, This is a friendly reminder that you still need to finish the electee survey and upload your resume. %(duedate)s This can be done by visiting https://tbp.engin.umich.edu%(link)s and following the instructions for completing the survey. You can upload a resume from your profile page. Thanks, The TBP Website''' for electee in electees: if current_survey.check_if_electee_completed(electee): continue body = body_template % { 'electee': electee.get_firstlast_name(), 'link': reverse('electees:complete_survey'), 'duedate': due_date } send_mail('[TBP] A friendly reminder to complete your survey.', body, '*****@*****.**', [electee.get_email()], fail_silently=False)