Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
0
 def test_resume_compile(self):
     compile_resumes()
     # check that the resumes are in the right place
     self.assertTrue(exists(RESUMES_BY_MAJOR_LOCATION()))
     self.assertTrue(exists(RESUMES_BY_YEAR_LOCATION()))
     guide = CorporateResourceGuide.objects.get()
     # first test the major directory
     resource_guide_url = sep.join([RESUMES_BY_MAJOR_LOCATION(), guide.name+'.pdf'])
     self.assertTrue(isfile(resource_guide_url))
     major_dirs = set()
     for major in Major.objects.all():
         major_dir = sep.join([RESUMES_BY_MAJOR_LOCATION(), slugify(major.name)])
         major_dirs.add(slugify(major.name))
         self.assertTrue(exists(major_dir))
         self.assertFalse(isfile(major_dir))
         major_resumes = set()
         for member in MemberProfile.get_members().filter(major=major):
             if not member.resume:
                 continue
             resume_file = sep.join([major_dir, member.get_resume_name()])
             major_resumes.add(member.get_resume_name())
             self.assertTrue(isfile(resume_file))
         self.assertEqual(major_resumes, set(listdir(major_dir)))
     major_dirs.add(guide.name+'.pdf')
     self.assertEqual(major_dirs,set(listdir(RESUMES_BY_MAJOR_LOCATION())))
     # now check the by year, basically checking that what is there is all
     # and only what is supposed to be
     resource_guide_url = sep.join([RESUMES_BY_YEAR_LOCATION(), guide.name+'.pdf'])
     self.assertTrue(isfile(resource_guide_url))
     standing_dirs = set()
     for standing in Standing.objects.all():
         sub_dir = slugify(standing.name) +( '' if standing.name == 'Alumni' else '-student')
         standing_dir = sep.join([RESUMES_BY_YEAR_LOCATION(), sub_dir])
         standing_dirs.add(sub_dir) 
         self.assertTrue(exists(standing_dir))
         self.assertFalse(isfile(standing_dir))
         year_dirs = {}
         for member in MemberProfile.get_members().filter(standing=standing):
             if not member.resume:
                 continue
             year_dir = 'Graduating'+slugify(member.expect_grad_date.year)
             if year_dir not in year_dirs:
                 year_dirs[year_dir]=set()
             year_dirs[year_dir].add( member.get_resume_name())
             resume_file = sep.join([standing_dir, year_dir, member.get_resume_name()])
         for year_dir in year_dirs:
             self.assertEqual(year_dirs[year_dir],set(listdir(sep.join([standing_dir, year_dir]))))
         self.assertEqual(set(year_dirs.keys()),set(listdir(standing_dir)))
     standing_dirs.add(guide.name+'.pdf')
     self.assertEqual(standing_dirs,set(listdir(RESUMES_BY_YEAR_LOCATION())))
Ejemplo n.º 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)
Ejemplo n.º 6
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
Ejemplo n.º 7
0
def view_map(request):
    """ The view of member locations.
    """
    if (not hasattr(request.user, 'userprofile') or
       not request.user.userprofile.is_member()):
        request.session['error_message'] = ('You must be logged in and a '
                                            'member to view this.')
        return get_previous_page(
                        request,
                        alternate='member_resources:index'
        )
    members_with_location = MemberProfile.get_members().exclude(location='')
    template = loader.get_template('fora/map.html')
    member = request.user.userprofile.memberprofile
    location = (member.location if member.location
                else GeoLocation(42.26, -83.7483))
    context_dict = {
        'members': members_with_location,
        'center': location,
        'can_center_on_me': bool(member.location),
    }
    context_dict.update(get_permissions(request.user))
    context_dict.update(get_common_context(request))
    context = RequestContext(request, context_dict)
    return HttpResponse(template.render(context))
Ejemplo n.º 8
0
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')
Ejemplo n.º 9
0
class BaseNEPParticipantForm(forms.ModelForm):
    """ Base form for adding participants to a non-event project."""
    participant = forms.ModelChoiceField(widget=Select2Widget(),
                                         queryset=MemberProfile.get_members())

    class Meta:
        model = NonEventProjectParticipant
        fields = ['project', 'participant', 'hours']
Ejemplo n.º 10
0
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')
Ejemplo n.º 11
0
class AwardForm(forms.ModelForm):
    """ Form for giving out an award."""
    recipient = forms.ModelChoiceField(widget=Select2Widget(),
                                       queryset=MemberProfile.get_members())

    class Meta:
        model = Award
        fields = ['award_type', 'term', 'recipient', 'comment']
Ejemplo n.º 12
0
class ManageProjectLeaderForm(ModelForm):
    member_profile = forms.ModelChoiceField(
                        widget=Select2Widget(),
                        queryset=MemberProfile.get_members()
    )

    class Meta:
        model = ProjectLeaderList
        fields = ['member_profile']
Ejemplo n.º 13
0
class CommitteeMemberForm(forms.ModelForm):
    """ Form for adding committee members for a given term."""
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_members(),
                                    label='Member')

    class Meta:
        model = CommitteeMember
        exclude = ['term']
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
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')
Ejemplo n.º 16
0
class CompleteEventForm(ModelForm):
    """
    Form used to specify how many hours the attendee was at the event.
    """
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_members())

    class Meta:
        model = ProgressItem
        exclude = ('term', 'event_type', 'date_completed', 'related_event',
                   'name')
Ejemplo n.º 17
0
def compile_resumes():
    media_parent = '/'.join(settings.MEDIA_ROOT.split('/')[:-2])+'/'
    if os.path.exists(RESUMES_BY_MAJOR_LOCATION()):
        shutil.rmtree(RESUMES_BY_MAJOR_LOCATION())
    os.makedirs(RESUMES_BY_MAJOR_LOCATION())
    resource_guides = CorporateResourceGuide.objects.filter(active=True)
    if resource_guides:
        shutil.copy(media_parent+resource_guides[0].resource_guide.url,os.path.sep.join([RESUMES_BY_MAJOR_LOCATION(),slugify(resource_guides[0].name)+'.pdf']))
    for resume_major in Major.objects.all():
        query=Q(major=resume_major)
        users_in_major = MemberProfile.get_members().filter(query)
        for user in users_in_major:
            if user.resume:
                major_dir = os.path.sep.join([RESUMES_BY_MAJOR_LOCATION(),slugify(resume_major.name)])
                if not os.path.exists(major_dir):
                    os.makedirs(major_dir)
                resume_name=user.get_resume_name()
                shutil.copy(media_parent+user.resume.url,os.path.sep.join([major_dir,resume_name]))
    if os.path.exists(RESUMES_BY_YEAR_LOCATION()):
        shutil.rmtree(RESUMES_BY_YEAR_LOCATION())
    os.makedirs(RESUMES_BY_YEAR_LOCATION())
    if resource_guides:
        shutil.copy(media_parent+resource_guides[0].resource_guide.url,os.path.sep.join([RESUMES_BY_YEAR_LOCATION(),slugify(resource_guides[0].name)+'.pdf']))

    for standing in Standing.objects.all():
        members = MemberProfile.get_members().filter(standing=standing)
        if standing.name == 'Alumni':
            status_dir = os.path.sep.join([RESUMES_BY_YEAR_LOCATION(),slugify(standing.name)])
        else:
            status_dir = os.path.sep.join([RESUMES_BY_YEAR_LOCATION(), slugify(standing.name)+'-student'])
        if not os.path.exists(status_dir):
            os.makedirs(status_dir)
        for user in members:
            if user.resume:
                current_grad_year = user.expect_grad_date.year
                year_dir = os.path.sep.join([status_dir,'Graduating'+slugify(current_grad_year)])
                if not os.path.exists(year_dir):
                    os.makedirs(year_dir)
                resume_name=slugify(user.last_name+'_'+user.first_name+'_'+user.uniqname)+'.pdf'
                shutil.copy(media_parent+user.resume.url,os.path.sep.join([year_dir,resume_name]))
Ejemplo n.º 18
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',)
Ejemplo n.º 19
0
class BaseAnnouncementForm(ModelForm):
    """
    Form for creating and submitting announcements to be included in the weekly
    announcements sent to membership.
    """
    contacts = forms.ModelMultipleChoiceField(
        widget=Select2MultipleWidget(), queryset=MemberProfile.get_members())

    class Meta:
        model = AnnouncementBlurb
        fields = [
            'start_date', 'end_date', 'title', 'text', 'contacts',
            'sign_up_link'
        ]
Ejemplo n.º 20
0
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]))
Ejemplo n.º 21
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
Ejemplo n.º 22
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'
        ]
Ejemplo n.º 23
0
class OfficerForm(forms.ModelForm):
    """ Form for specifying an officer.

    Excludes term, since that is specified externally.
    """
    user = forms.ModelChoiceField(widget=Select2Widget(),
                                  queryset=MemberProfile.get_members(),
                                  label='Member')
    position = forms.ModelChoiceField(widget=Select2Widget(),
                                      queryset=OfficerPosition.get_current())

    class Meta:
        model = Officer
        exclude = ['term']
Ejemplo n.º 24
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()
Ejemplo n.º 25
0
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]))
Ejemplo n.º 26
0
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]))
Ejemplo n.º 27
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
Ejemplo n.º 28
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
Ejemplo n.º 29
0
class WebArticleForm(forms.ModelForm):
    """ Form for submitting website articles."""
    TWEET_CHOICES = (
        ('N', 'No Tweet'),
        ('T', 'Tweet normally'),
        ('H', 'Tweet with #UmichEngin'),
    )
    tagged_members = forms.ModelMultipleChoiceField(
        widget=Select2MultipleWidget(),
        queryset=MemberProfile.get_members(),
        required=False)
    tweet_option = forms.ChoiceField(choices=TWEET_CHOICES, initial='N')

    class Meta:
        model = WebsiteArticle
        exclude = ['created_by', 'approved']
Ejemplo n.º 30
0
    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)
Ejemplo n.º 31
0
class CompleteFixedProgressEventForm(ModelForm):
    """
    For events where progress is fixed (i.e. you were there or you weren't)
    only listing attendees is necessary.
    """
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_members())

    class Meta:
        model = ProgressItem
        exclude = (
            'term',
            'event_type',
            'date_completed',
            'amount_completed',
            'related_event',
            'name',
            'hours',
        )
Ejemplo n.º 32
0
class BaseNEPForm(forms.ModelForm):
    """ Base form for filling out a non-event project summary.
    """
    leaders = forms.ModelMultipleChoiceField(
        widget=Select2MultipleWidget(), queryset=MemberProfile.get_members())
    term = forms.ModelChoiceField(widget=Select2Widget(),
                                  queryset=AcademicTerm.get_rchron(),
                                  initial=AcademicTerm.get_current_term())
    assoc_officer = forms.ModelChoiceField(
        widget=Select2Widget(),
        queryset=OfficerPosition.get_current(),
        label='Associated Officer')

    class Meta:
        model = NonEventProject
        fields = [
            'name', 'description', 'leaders', 'assoc_officer', 'term',
            'start_date', 'end_date', 'location'
        ]
Ejemplo n.º 33
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))
Ejemplo n.º 34
0
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))    
Ejemplo n.º 35
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)
Ejemplo n.º 36
0
class LeadershipCreditForm(forms.ModelForm):
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_members())
    approve = forms.BooleanField(required=False)

    class Meta:
        model = ProgressItem
        exclude = ('term', 'event_type', 'amount_completed', 'date_completed',
                   'related_event')

    def save(self, commit=True):
        approved = self.cleaned_data.pop('approve', False)
        if approved:
            instance = super(LeadershipCreditForm, self).save(commit=False)
            instance.term = AcademicTerm.get_current_term()
            instance.event_type = EventCategory.objects.get(name='Leadership')
            instance.amount_completed = 1
            instance.date_completed = date.today()
            if commit:
                instance.save()
            return instance
        else:
            return None
Ejemplo n.º 37
0
def view_map(request):
    """ The view of member locations.
    """
    if (not hasattr(request.user, 'userprofile') or
       not request.user.userprofile.is_member()):
        request.session['error_message'] = ('You must be logged in and a '
                                            'member to view this.')
        return get_previous_page(
                        request,
                        alternate='member_resources:index'
        )
    members_with_location = MemberProfile.get_members().exclude(location='')
    template = loader.get_template('fora/map.html')
    member = request.user.userprofile.memberprofile
    location = (member.location if member.location
                else GeoLocation(42.26, -83.7483))
    context_dict = {
        'members': members_with_location,
        'center': location,
        'can_center_on_me': bool(member.location),
    }
    context_dict.update(get_permissions(request.user))
    context_dict.update(get_common_context(request))
    return HttpResponse(template.render(context_dict, request))
Ejemplo n.º 38
0
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))
Ejemplo n.º 39
0
class NominationForm(forms.ModelForm):
    """ Form for submitting nominations.
    Overrides the default behavior to make it so that you can only nominate
    someone to a position that is part of the current election.
    """
    nominee = forms.ModelChoiceField(widget=Select2Widget(),
                                     queryset=MemberProfile.get_members())
    position = forms.ModelChoiceField(widget=Select2Widget(),
                                      queryset=OfficerPosition.get_current())

    class Meta:
        model = Nomination
        exclude = (
            'election',
            'nominator',
            'accepted',
        )

    def __init__(self, *args, **kwargs):
        election = kwargs.pop('election', None)
        super(NominationForm, self).__init__(*args, **kwargs)
        if election:
            officers = election.officers_for_election.all()
            self.fields['position'].queryset = officers
Ejemplo n.º 40
0
def get_members_who_graduated():
    members = MemberProfile.get_actives().exclude(standing__name='Alumni')

    return members.filter(expect_grad_date__lt=date.today()).distinct()
Ejemplo n.º 41
0
def compile_resumes(include_alums=False):
    media_parent = '/'.join(settings.MEDIA_ROOT.split('/')[:-2]) + '/'
    if os.path.exists(RESUMES_BY_MAJOR_LOCATION()):
        shutil.rmtree(RESUMES_BY_MAJOR_LOCATION())
    os.makedirs(RESUMES_BY_MAJOR_LOCATION())
    resource_guides = CorporateResourceGuide.objects.filter(active=True)
    if resource_guides:
        shutil.copy(
            media_parent + resource_guides[0].resource_guide.url,
            os.path.sep.join([
                RESUMES_BY_MAJOR_LOCATION(),
                slugify(resource_guides[0].name) + '.pdf'
            ]))
    for resume_major in Major.objects.all():
        query = Q(major=resume_major)
        users_in_major = MemberProfile.get_members(
            include_alums=include_alums).filter(query)
        for user in users_in_major:
            if user.resume:
                major_dir = os.path.sep.join(
                    [RESUMES_BY_MAJOR_LOCATION(),
                     slugify(resume_major.name)])
                if not os.path.exists(major_dir):
                    os.makedirs(major_dir)
                resume_name = user.get_resume_name()
                shutil.copy(media_parent + user.resume.url,
                            os.path.sep.join([major_dir, resume_name]))
    if os.path.exists(RESUMES_BY_YEAR_LOCATION()):
        shutil.rmtree(RESUMES_BY_YEAR_LOCATION())
    os.makedirs(RESUMES_BY_YEAR_LOCATION())
    if resource_guides:
        shutil.copy(
            media_parent + resource_guides[0].resource_guide.url,
            os.path.sep.join([
                RESUMES_BY_YEAR_LOCATION(),
                slugify(resource_guides[0].name) + '.pdf'
            ]))

    for standing in Standing.objects.all():
        members = MemberProfile.get_members().filter(standing=standing)
        if standing.name == 'Alumni':
            if not include_alums:
                continue
            status_dir = os.path.sep.join(
                [RESUMES_BY_YEAR_LOCATION(),
                 slugify(standing.name)])
        else:
            status_dir = os.path.sep.join([
                RESUMES_BY_YEAR_LOCATION(),
                slugify(standing.name) + '-student'
            ])
        if not os.path.exists(status_dir):
            os.makedirs(status_dir)
        for user in members:
            if user.resume:
                current_grad_year = user.expect_grad_date.year
                year_dir = os.path.sep.join(
                    [status_dir, 'Graduating' + slugify(current_grad_year)])
                if not os.path.exists(year_dir):
                    os.makedirs(year_dir)
                resume_name = slugify(user.last_name + '_' + user.first_name +
                                      '_' + user.uniqname) + '.pdf'
                shutil.copy(media_parent + user.resume.url,
                            os.path.sep.join([year_dir, resume_name]))
Ejemplo n.º 42
0
class AddContactForm(forms.Form):
    address = forms.CharField(widget=forms.Textarea, required=False)
    company = forms.ModelChoiceField(
                    widget=Select2Widget(),
                    queryset=Company.objects.order_by('name'),
                    label='Company',
    )
    gets_email = forms.BooleanField(required=False)
    has_contacted = forms.BooleanField(required=False)
    personal_contact_of = forms.ModelChoiceField(
                    widget=Select2Widget(),
                    queryset=MemberProfile.get_members(),
                    label='Personal contact of',
                    required=False
    )
    member = forms.ModelChoiceField(
                    widget=Select2Widget( ),
                    queryset=MemberProfile.get_members(),
                    label='Contact',
                    required=False,
                    initial=None
    )

    speaking_interest = forms.BooleanField(required=False)
    name = forms.CharField(max_length=256, required=False)
    email = forms.EmailField(max_length=254, required=False)
    phone = USPhoneNumberField(required=False)
    short_bio = forms.CharField(widget=forms.Textarea, required=False)
    initiating_chapter = forms.ModelChoiceField(
                    widget=Select2Widget(),
                    queryset=TBPChapter.objects.order_by('state', 'letter'),
                    label='Initiating TBP Chapter (if any)',
                    required=False
    )

    id = forms.IntegerField(widget=forms.HiddenInput(), initial=0)
    is_member = forms.BooleanField(
                        widget=forms.HiddenInput(),
                        initial=None,
                        required=False
    )

    def __init__(self, *args, **kwargs):
        c = kwargs.pop('contact', None)
        ed = kwargs.pop('can_edit', False)
        super(AddContactForm, self).__init__(*args, **kwargs)
        if not ed:
            self.fields['gets_email'].widget = forms.HiddenInput()
        if c:
            self.fields['address'].initial = c.address
            self.fields['company'].initial = c.company
            self.fields['gets_email'].initial = c.gets_email
            self.fields['has_contacted'].initial = c.has_contacted
            self.fields['personal_contact_of'].initial = c.personal_contact_of
            self.fields['speaking_interest'].initial = c.speaking_interest
            self.fields['id'].initial = c.id
            if hasattr(c, 'member'):
                self.fields['is_member'].initial = True
                self.fields['member'].initial = c.member
            else:
                self.fields['is_member'].initial = None
                self.fields['member'].initial = None
                self.fields['name'].initial = c.name
                self.fields['email'].initial = c.email
                self.fields['phone'].initial = c.phone
                self.fields['short_bio'].initial = c.short_bio
                self.fields['initiating_chapter'].initial = c.initiating_chapter

    def clean(self):
        cleaned_data = super(AddContactForm, self).clean()
        member = cleaned_data.get('member')
        name = cleaned_data.get('name')

        if self.has_changed() and not(name or member):
            raise forms.ValidationError(
                            ('Either a member profile or a '
                             'contact name must be provided'))

    def is_overdetermined(self):
        if self.cleaned_data.get('member'):
            name = self.cleaned_data.get('name')
            email = self.cleaned_data.get('email')
            phone = self.cleaned_data.get('phone')
            bio = self.cleaned_data.get('short_bio')
            chapter = self.cleaned_data.get('initiating_chapter')
            if name or email or phone or bio or chapter:
                return True
        return False

    def save(self):
        if not self.has_changed():
            return
        id = self.cleaned_data.get('id')
        was_instance = id and id > 0
        was_member = self.cleaned_data.get('is_member')
        member = self.cleaned_data.get('member')
        if member:
            # save a MemberContact
            if was_instance and was_member:
                c = MemberContact.objects.get(id=id)
            else:
                c = MemberContact()
            if was_instance and not was_member:
                NonMemberContact.objects.filter(id=id).delete()
            c.member = member
        else:
            # save a NonMemberContact
            if was_instance and not was_member:
                c = NonMemberContact.objects.get(id=id)
            else:
                c = NonMemberContact()
            if was_instance and was_member:
                MemberContact.objects.filter(id=id).delete()
            c.name = self.cleaned_data.get('name')
            c.email = self.cleaned_data.get('email')
            c.phone = self.cleaned_data.get('phone')
            c.short_bio = self.cleaned_data.get('short_bio')
            c.initiating_chapter = self.cleaned_data.get('initiating_chapter')
        c.address = self.cleaned_data.get('address')
        c.company = self.cleaned_data.get('company')
        c.gets_email = self.cleaned_data.get('gets_email')
        c.has_contacted = self.cleaned_data.get('has_contacted')
        c.personal_contact_of = self.cleaned_data.get('personal_contact_of')
        c.speaking_interest = self.cleaned_data.get('speaking_interest')
        c.save()
        return c

    def delete(self):
        id = self.cleaned_data.get('id')
        was_instance = id and id > 0
        was_member = self.cleaned_data.get('is_member')
        if not was_instance:
            return
        if was_member:
            MemberContact.objects.filter(id=id).delete()
        else:
            NonMemberContact.objects.filter(id=id).delete()
Ejemplo n.º 43
0
class AddElecteeStatusForm(AddStatusForm):
    member = forms.ModelChoiceField(widget=Select2Widget(),
                                    queryset=MemberProfile.get_electees())
Ejemplo n.º 44
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
        )