def get(self, args): template_vals = generate_base_template_vals(self) template_vals['title'] = 'Members' template_vals['page'] = 'members' # Check for a search query. search_query = self.request.get('q') # If there was no search or semester specified, default to the current semester. if not search_query: search_query = 'semester:' + str(get_current_semester()) # Run the search. search_results = search.Index(MEMBER_SEARCH_INDEX_NAME).search(search.Query( query_string=search_query, options=search.QueryOptions( limit=999, ids_only=True, sort_options=search.SortOptions( expressions=[ search.SortExpression( expression='name', direction=search.SortExpression.ASCENDING, default_value='') ])))) # Fetch the members. show_private = users.is_current_user_admin() members = [] for result in search_results.results: member = Member.query(Member.id == result._doc_id).get() if member and (member.show or show_private): members.append(member) template_vals['members'] = members # Get all possible semesters to put in the menu. selected_semester = get_semester_from_query(search_query) semesters = [] for semester in get_all_semesters(): semesters.append({ 'id': semester, 'pretty': semester_pretty(semester), 'selected': semester == selected_semester }) template_vals['semesters'] = semesters if selected_semester and selected_semester > FIRST_SEMESTER: template_vals['prev_semester'] = prev_semester(selected_semester) if selected_semester and selected_semester < get_current_semester(): template_vals['next_semester'] = next_semester(selected_semester) if selected_semester and selected_semester >= FIRST_SEMESTER and selected_semester <= get_current_semester(): template_vals['selected_semester'] = selected_semester template = JINJA_ENVIRONMENT.get_template('members_list.html') self.response.write(template.render(template_vals))
def get(self, args): template_vals = generate_base_template_vals(self) template_vals['title'] = 'Missions' template_vals['page'] = 'missions' # Get all users from the given semester try: selected_semester = float(self.request.get('semester')) except Exception: selected_semester = get_current_semester() next_semester_date = semester_date(next_semester(selected_semester)) selected_semester_date = semester_date(selected_semester) template_vals['missions'] = Mission.query(Mission.start >= semester_date(selected_semester), Mission.start < next_semester_date).order(Mission.start).fetch(limit=None) # Get all possible semesters to put in the menu. semesters = [] for semester in get_all_semesters(): semesters.append({ 'id': semester, 'pretty': semester_pretty(semester), 'selected': semester == selected_semester }) template_vals['semesters'] = semesters template_vals['prev_semester'] = prev_semester(selected_semester) if selected_semester != FIRST_SEMESTER else None template_vals['next_semester'] = next_semester(selected_semester) if selected_semester != get_current_semester() else None template = JINJA_ENVIRONMENT.get_template('missions_list.html') self.response.write(template.render(template_vals))
def get(self, args): template_vals = generate_base_template_vals(self) template_vals['title'] = 'Missions' template_vals['page'] = 'missions' # Get all users from the given semester try: selected_semester = float(self.request.get('semester')) except Exception: selected_semester = get_current_semester() next_semester_date = semester_date(next_semester(selected_semester)) selected_semester_date = semester_date(selected_semester) template_vals['missions'] = Mission.query(Mission.start >= semester_date(selected_semester), Mission.start < next_semester_date).order(Mission.start).fetch(limit=None) # Get all possible semesters to put in the menu. semesters = [] for semester in get_all_semesters(): semesters.append({ 'id': semester, 'pretty': semester_pretty(semester), 'selected': semester == selected_semester }) template_vals['semesters'] = semesters template_vals['prev_semester'] = prev_semester(selected_semester) if selected_semester != FIRST_SEMESTER else None template_vals['next_semester'] = next_semester(selected_semester) if selected_semester != get_current_semester() else None template = JINJA_ENVIRONMENT.get_template('missions_list.html') self.response.write(template.render(template_vals))
def rank(member, semester=get_current_semester()): paid = False num_semesters_paid_to_date = 0 for semester_paid in member.semesters_paid: if semester_paid <= semester: paid = True if semester_paid < semester: num_semesters_paid_to_date += 1 # Cadets cannot earn ranks if not paid: return 0 rank = 1 # Longevity if num_semesters_paid_to_date >= 4: rank += 1 # Led weekly mission if Mission.query(Mission.runners == member.id, Mission.type == 0, Mission.start < semester_date(semester)).count(limit=1) != 0: rank += 1 # Volunteered with special mission or committee if member.committee_rank or Mission.query(Mission.runners == member.id, Mission.type == 1, Mission.start < semester_date(semester)).count(limit=1) != 0: rank += 1 # Merit ranks if member.merit_rank1: rank += 1 if member.merit_rank2: rank += 1 # Voted captain if BridgeCrew.query(BridgeCrew.captain == member.id, BridgeCrew.start < semester_date(semester)).count(limit=1) != 0: rank = 6 # Alumni ranks if not member.current_student: if rank == 6: # Captains become rear admirals rank = 8 else: # Non-captains become commodores rank = 7 # Was an admiral (advisor) if BridgeCrew.query(BridgeCrew.admiral == member.id, BridgeCrew.start < semester_date(semester)).count(limit=1) != 0: rank = 10 return rank
def get(self): if not require_admin(self): return template_vals = generate_base_template_vals(self) template_vals['title'] = 'Every User Ever' template_vals['page'] = 'members' template_vals['members'] = Member.query().order(Member.name).fetch(limit=None) template_vals['current_semester'] = get_current_semester() template = JINJA_ENVIRONMENT.get_template('members_hidden.html') self.response.write(template.render(template_vals))
def get_name_with_rank(self, semester=get_current_semester()): from ranks import name_with_rank if not semester: semester = get_current_semester() return name_with_rank(self, semester)
def get_rank_name(self, semester=get_current_semester()): from ranks import rank_name if not semester: semester = get_current_semester() return rank_name(self, semester)
def get(self): members = Member.query(Member.card_printed == False, Member.current_student == True, Member.semesters_paid == get_current_semester()).order(Member.name).fetch(limit=None) # TODO: Replace with fetching the current semester once semester formatting functions are merged in. semester = 'Fall 2017' # Replace 0 with O because it looks better in the font. semester_mod = semester.replace('0', 'O') template_vals = { 'title': 'ID cards for ' + semester, 'members': members, 'semester': semester_mod } template = JINJA_ENVIRONMENT.get_template('cards.html') self.response.write(template.render(template_vals))
def name_with_rank(member, semester=get_current_semester()): return RANKS[rank(member, semester)]['abbr'] + ' ' + member.name
def rank_name(member, semester=get_current_semester()): return RANKS[rank(member, semester)]['name']
def rank_disp(member, semester=get_current_semester()): return RANKS[rank(member, semester)]['disp']