示例#1
0
    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
示例#2
0
def get_members_for_COE():
    members = MemberProfile.get_actives().exclude(standing__name='Alumni')
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="MemberData.csv"'

    writer = UnicodeWriter(response)
    writer.writerow([
        'First Name', 'Last Name', 'uniqname', 'Active?', 'Officer?',
        'Standing', 'Major'
    ])
    for member in members:
        current_term = AcademicTerm.get_current_term()
        was_active = 'Active' if Distinction.objects.filter(
            member=member, term=current_term.get_previous_full_term()).exists(
            ) else 'Inactive'
        officer_terms = Officer.objects.filter(
            user=member,
            term__in=[
                current_term.get_previous_full_term(),
                current_term,
            ])
        if officer_terms.exists():
            officer_pos = ', '.join([
                unicode(officer.position) + ' ' +
                ', '.join([unicode(term) for term in officer.term.all()])
                for officer in officer_terms
            ])
        else:
            officer_pos = 'Member'
        writer.writerow([
            member.first_name, member.last_name, member.uniqname, was_active,
            officer_pos, member.standing.name,
            ', '.join([major.name for major in member.major.all()])
        ])
    return response
示例#3
0
 def handle(self, *args, **options):
     active_html = loader.render_to_string(
         'member_resources/member_list.html', {
             'members': MemberProfile.get_actives(),
             'member_type': 'Actives'
         })
     cache.set('active_list_html', active_html)
示例#4
0
    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
示例#5
0
 def handle(self, *args, **options):
     active_html = loader.render_to_string(
                     'member_resources/member_list.html',
                     {
                         'members': MemberProfile.get_actives(),
                         'member_type': 'Actives'
                     }
     )
     cache.set('active_list_html', active_html)
示例#6
0
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
示例#7
0
class BaseElecteeGroupForm(forms.ModelForm):
    leaders = forms.ModelMultipleChoiceField(
                widget=Select2MultipleWidget(),
                queryset=MemberProfile.get_actives()
    )
    officers = forms.ModelMultipleChoiceField(
                widget=Select2MultipleWidget(),
                queryset=Officer.get_current_members()
    )

    class Meta:
        model = ElecteeGroup
        exclude = ('term', 'members', 'points',)
示例#8
0
 def get_actives_with_status(self, term, temp_active_ok=False):
     query =  Q(distinction_type=self) & Q(term=term.semester_type)
     requirements = Requirement.objects.filter(query)
     unflattened_reqs = Requirement.package_requirements(requirements)
     active_profiles = MemberProfile.get_actives() 
     actives_with_status = []
     for profile in active_profiles:
         packaged_progress = ProgressItem.package_progress(ProgressItem.objects.filter(member=profile,term=term))
         amount_req = 0;
         amount_has = 0;
         has_dist = self.has_distinction_met(packaged_progress, unflattened_reqs, temp_active_ok)
         if has_dist:
             actives_with_status.append(profile)
     return actives_with_status
示例#9
0
class BaseProjectReportHeaderForm(forms.ModelForm):
    """ Form for starting the project report compilation.
    """
    terms = forms.ModelMultipleChoiceField(widget=Select2MultipleWidget(),
                                           queryset=AcademicTerm.get_rchron())
    preparer = forms.ModelChoiceField(widget=Select2Widget(),
                                      queryset=MemberProfile.get_actives())

    class Meta:
        model = ProjectReportHeader
        exclude = [
            'finished_processing', 'finished_photos', 'last_processed',
            'last_photo'
        ]
示例#10
0
def get_active_members(term):
    members = MemberProfile.get_actives()
    terms = [term, term.get_previous_full_term()]
    officer_terms = Officer.objects.filter(term__in=[term])
    distinctions = Distinction.objects.filter(term__in=terms)
    query_active_status = Q(distinction__in=distinctions)
    query_initiated_last_term = Q(init_term=term.get_previous_full_term())
    query_officer = Q(officer__in=officer_terms)
    query_alumni = (Q(standing__name='Alumni') |
                    Q(expect_grad_date__lt=date.today()))
    query = query_officer | (
            (query_active_status | query_initiated_last_term) & ~query_alumni
    )

    return members.filter(query).distinct()
示例#11
0
def get_members_for_COE():
    members = MemberProfile.get_actives().exclude(standing__name='Alumni')
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition']='attachment; filename="MemberData.csv"'

    writer = UnicodeWriter(response)
    writer.writerow([ 'First Name','Last Name','uniqname','Active?','Officer?','Standing','Major'])
    for member in members:
        was_active='Active' if Distinction.objects.filter(member=member,term=get_previous_full_term(AcademicTerm.get_current_term())).exists() else 'Inactive'
        officer_terms = Officer.objects.filter(user=member,term__in=[get_previous_full_term(AcademicTerm.get_current_term()),AcademicTerm.get_current_term()])
        if officer_terms.exists():
            officer_pos = ', '.join([unicode(officer.position)+' '+', '.join([unicode(term) for term in officer.term.all()]) for officer in officer_terms ])
        else:
            officer_pos='Member'
        writer.writerow([member.first_name,member.last_name,member.uniqname,was_active,officer_pos,member.standing.name,', '.join([ major.name for major in member.major.all()])])
    return response
示例#12
0
class AddStatusForm(forms.ModelForm):
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_actives())
    approve = forms.BooleanField(required=False)

    class Meta:
        model = Distinction
        exclude = ('term', )

    def save(self, commit=True):
        approved = self.cleaned_data.pop('approve', False)
        if approved:
            return super(AddStatusForm, self).save(commit=commit)
        else:
            print 'unapproved'
            return None
示例#13
0
def get_active_members_only_if_they_come(term, is_last_voting_meeting=False):
    members = MemberProfile.get_actives()
    terms = [term, term.get_previous_full_term()]
    officer_terms = Officer.objects.filter(term__in=[term])
    distinctions = Distinction.objects.filter(term__in=terms)
    query_active_status = Q(distinction__in=distinctions)
    query_initiated_last_term = Q(init_term=term.get_previous_full_term())
    query_officer = Q(officer__in=officer_terms)
    query_alumni = (Q(standing__name='Alumni') |
                    Q(expect_grad_date__lt=date.today()))
    query_all_active = query_officer | (
            (query_active_status | query_initiated_last_term) & ~ query_alumni
    )
    progress_items = ProgressItem.objects.filter(
                                    term=term,
                                    event_type__name='Meeting Attendance'
    )
    query_actives_absent_now = ~Q(progressitem__in=progress_items)
    # figure out actives will gain status if they have the meeting credit

    query_inactives_need_meeting = (
        ~query_officer & ~query_active_status & ~query_initiated_last_term & ~query_alumni
    )
    query = (query_all_active & query_actives_absent_now)
    set1 = set(members.filter(query).distinct()[:])
    active_dist = DistinctionType.objects.get(name='Active')
    temp_active_ok = not is_last_voting_meeting
    set2 = set(
            members.filter(
                    query_inactives_need_meeting).distinct()[:]
        ).intersection(
            set(
                active_dist.get_actives_with_status(
                                            term,
                                            temp_active_ok=temp_active_ok
                )
            )
        )

    return list(set1.union(set2))
示例#14
0
    def handle(self,*args,**options):
        term = AcademicTerm.get_current_term()
        all_actives = MemberProfile.get_actives()
        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)
        body_template = r'''Hi %(member)s,
This is a friendly reminder that we have a critical voting meeting tomorrow (Tuesday) at 6:30pm in 1013 Dow and we need to have a quorum of active members present.
Our records indicate that %(status)s

%(alumni)s

If you believe this to be in error, or especially if you are no longer on campus, please let us know by emailing [email protected] or by speaking to the president or website chair at the meeting tonight.

Thanks,
The TBP Website'''
        for m in all_actives:
            print 'emailing '+m.uniqname+'...'
            sleep(1)
            if m in potential_actives:
                status_text=' you will be considered active and eligible to vote upon attending the meeting. While your absence will not count against quorum, please be advised that voting meetings are required to achieve DA/PA status.'
            elif m in actual_actives:
                status_text=' you are an active member. You will be eligible to vote at the meeting and will count against quorum if you cannot or do not attend tonight.'
            elif m.standing.name=='Alumni':
                continue
            else:
                status_text=' you are no longer active in the chapter. You are welcome to attend the meeting, but you will be unable to vote.'
                if m in members_who_graduated:
                    status_text+=' This may be that you are listed as having graduated. Alumni may specially request active status, but may not vote on candidate election'
            if m in members_who_graduated:
                alum_text = 'Our records additionally indicate that you have likely graduated but are not yet listed as an alumni. If this is the case, please let us know and update your website profile accordingly. If not please update your expected graduation date accordingly. Those listed as alumni will be ineligible to vote on candidate election.'
            elif m.standing.name=='Alumni':
                alum_text = ' Our records have you noted as an alumni. Note that regardless of active status, alumni may not vote on candidate election or changes to the initiation fee.'
            else:
                alum_text=''
            body=body_template%{'member':m.first_name,'status':status_text,'alumni':alum_text}
            send_mail('[TBP] Voting meeting active status update.',body,'*****@*****.**',[m.get_email(),'*****@*****.**'] ,fail_silently=False)
示例#15
0
def email_active_status(meeting, is_elections):
    term = AcademicTerm.get_current_term()
    all_actives = MemberProfile.get_actives()
    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=is_elections
    )
    body_template = r'''Hi %(member)s,
This is a friendly reminder that we have a critical voting meeting -
%(name)s - %(date)s
in %(location)s and we need to have a quorum of active members
present. Please remember to bring your iClickers. 

Our records indicate that %(status)s

%(alumni)s

If you believe this to be in error, or especially if you are no longer on
campus, please let us know by emailing [email protected] or by speaking
to the president or website chair at the meeting.

Thanks,
The TBP Website'''
    emailed_people = []
    location = meeting.get_locations()
    if len(location)>0:
        location = location[0]
    else:
        location = 'TBD'
    start_end = meeting.get_start_and_end()
    start = timezone.localtime(start_end['start']).strftime('%A (%b %d) at %I:%M%p')
    start_string = 'this '+start
    event_name = meeting.name
    print event_name
    print location
    sleep(5)
    for m in all_actives:
        print 'emailing ' + m.uniqname+'...'
        sleep(1)
        short_code = 'active'
        status_code = ''
        if m in potential_actives:
            status_text = (' you will be considered active and eligible '
                           'to vote upon attending the meeting. While '
                           'your absence will not count against quorum, '
                           'please be advised that voting meetings are '
                           'required to achieve DA/PA status.')
            short_code = 'conditional active'
        elif m in actual_actives:
            status_text = (' you are an active member. You will be '
                           'eligible to vote at the meeting and will '
                           'count against quorum if you cannot or do not '
                           'attend.')
        elif m.standing.name == 'Alumni':
            continue
        else:
            status_text = (' you are no longer active in the chapter. '
                           'You are welcome to attend the meeting, but '
                           'you will be unable to vote.')
            short_code = 'not active'
            if m in members_who_graduated:
                status_text += (' This may be that you are listed as '
                                'having graduated. Alumni may specially '
                                'request active status, but may not vote '
                                'on candidate election')
                short_code = 'non-active alum'
        if m in members_who_graduated:
            alum_text = ('Our records additionally indicate that you have '
                         'likely graduated but are not yet listed as an '
                         'alumni. If this is the case, please let us know '
                         'and update your website profile accordingly. If '
                         'not please update your expected graduation date '
                         'accordingly. Those listed as alumni will be '
                         'ineligible to vote on candidate election.')
            status_code = 'graduated'
        elif m.standing.name == 'Alumni':
            alum_text = (' Our records have you noted as an alumni. Note '
                         'that regardless of active status, alumni may '
                         'not vote on candidate election or changes to '
                         'the initiation fee.')
            status_code = 'alum'
        else:
            alum_text = ''
        body = body_template % {
                    'member': m.first_name,
                    'status': status_text,
                    'alumni': alum_text,
                    'location': location,
                    'date': start_string,
                    'name': event_name
        }
        emailed_people.append([m.uniqname, short_code, status_code])
        send_mail(
            '[TBP] Voting meeting active status update.',
            body,
            '*****@*****.**',
            [m.get_email()],
            fail_silently=False
        )
    web_summary_body = 'The following members were emailed:\n\n'
    web_summary_body += '\n'.join(
            ['\t\t'.join(sub_list) for sub_list in emailed_people])
    send_mail(
        '[TBP] Voting meeting active status update - summary.',
        web_summary_body,
        '*****@*****.**',
        ['*****@*****.**'],
        fail_silently=False
    )
示例#16
0
    def handle(self, *args, **options):
        term = AcademicTerm.get_current_term()
        all_actives = MemberProfile.get_actives()
        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=options['is_elections'])
        body_template = r'''Hi %(member)s,
This is a friendly reminder that we have a critical voting meeting tomorrow
(Tuesday) at 6:30pm in 1013 Dow and we need to have a quorum of active members
present.
Our records indicate that %(status)s

%(alumni)s

If you believe this to be in error, or especially if you are no longer on
campus, please let us know by emailing [email protected] or by speaking
to the president or website chair at the meeting tonight.

Thanks,
The TBP Website'''
        emailed_people = []
        for m in all_actives:
            print 'emailing ' + m.uniqname+'...'
            sleep(1)
            short_code = 'active'
            status_code = ''
            if m in potential_actives:
                status_text = (' you will be considered active and eligible '
                               'to vote upon attending the meeting. While '
                               'your absence will not count against quorum, '
                               'please be advised that voting meetings are '
                               'required to achieve DA/PA status.')
                short_code = 'conditional active'
            elif m in actual_actives:
                status_text = (' you are an active member. You will be '
                               'eligible to vote at the meeting and will '
                               'count against quorum if you cannot or do not '
                               'attend tonight.')
            elif m.standing.name == 'Alumni':
                continue
            else:
                status_text = (' you are no longer active in the chapter. '
                               'You are welcome to attend the meeting, but '
                               'you will be unable to vote.')
                short_code = 'not active'
                if m in members_who_graduated:
                    status_text += (' This may be that you are listed as '
                                    'having graduated. Alumni may specially '
                                    'request active status, but may not vote '
                                    'on candidate election')
                    short_code = 'non-active alum'
            if m in members_who_graduated:
                alum_text = ('Our records additionally indicate that you have '
                             'likely graduated but are not yet listed as an '
                             'alumni. If this is the case, please let us know '
                             'and update your website profile accordingly. If '
                             'not please update your expected graduation date '
                             'accordingly. Those listed as alumni will be '
                             'ineligible to vote on candidate election.')
                status_code = 'graduated'
            elif m.standing.name == 'Alumni':
                alum_text = (' Our records have you noted as an alumni. Note '
                             'that regardless of active status, alumni may '
                             'not vote on candidate election or changes to '
                             'the initiation fee.')
                status_code = 'alum'
            else:
                alum_text = ''
            body = body_template % {
                        'member': m.first_name,
                        'status': status_text,
                        'alumni': alum_text
            }
            emailed_people.append([m.uniqname, short_code, status_code])
            send_mail(
                '[TBP] Voting meeting active status update.',
                body,
                '*****@*****.**',
                [m.get_email()],
                fail_silently=False
            )
        web_summary_body = 'The following members were emailed:\n\n'
        web_summary_body += '\n'.join(
                ['\t\t'.join(sub_list) for sub_list in emailed_people])
        send_mail(
            '[TBP] Voting meeting active status update - summary.',
            web_summary_body,
            '*****@*****.**',
            ['*****@*****.**'],
            fail_silently=False
        )
示例#17
0
def get_members_who_graduated():
    members = MemberProfile.get_actives().exclude(standing__name='Alumni')

    return members.filter(expect_grad_date__lt=date.today()).distinct()