Example #1
0
	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))
Example #2
0
	def get(self, args):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Edit Mission'
		template_vals['page'] = 'missions'
		
		req_id = self.request.get('id')
		
		if not req_id:
			new_mission = Mission()
			new_mission.name = 'New Mission'
			template_vals['mission'] = new_mission
		else:
			mission = Mission.query(Mission.id == req_id).get()
			if mission:
				template_vals['mission'] = mission
			else:
				self.error(404)
				return
		
		template_vals['semesters'] = get_all_semesters()
		
		template = JINJA_ENVIRONMENT.get_template('mission_edit.html')
		self.response.write(template.render(template_vals))
Example #3
0
	def get(self, args):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Edit Member'
		template_vals['page'] = 'members'
		
		req_id = self.request.get('id')
		
		if not req_id:
			while True:
				# Create a new ID and verify it is unique.
				new_id = uuid4().hex
				if not Member.query(Member.id == new_id).get():
					new_member = Member()
					new_member.id = new_id
					new_member.name = 'New Member'
					template_vals['member'] = new_member
					break
		else:
			member = Member.query(Member.id == req_id).get()
			if member:
				template_vals['member'] = member
			else:
				self.error(404)
				return
		
		template_vals['semesters'] = get_all_semesters()
		
		template = JINJA_ENVIRONMENT.get_template('member_edit.html')
		self.response.write(template.render(template_vals))
Example #4
0
	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))
Example #5
0
	def get(self, args):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Edit Mission'
		template_vals['page'] = 'missions'
		
		req_id = self.request.get('id')
		
		if not req_id:
			new_mission = Mission()
			new_mission.name = 'New Mission'
			template_vals['mission'] = new_mission
		else:
			mission = Mission.query(Mission.id == req_id).get()
			if mission:
				template_vals['mission'] = mission
			else:
				self.error(404)
				return
		
		template_vals['semesters'] = get_all_semesters()
		
		template = JINJA_ENVIRONMENT.get_template('mission_edit.html')
		self.response.write(template.render(template_vals))
Example #6
0
	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))
Example #7
0
	def get(self):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Hidden Missions'
		template_vals['page'] = 'missions'
		
		template_vals['missions'] = Mission.query(ndb.OR(Mission.start == None)).order(Mission.id).fetch(limit=None)
		
		template = JINJA_ENVIRONMENT.get_template('missions_hidden.html')
		self.response.write(template.render(template_vals))
Example #8
0
	def get(self):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Hidden Missions'
		template_vals['page'] = 'missions'
		
		template_vals['missions'] = Mission.query(ndb.OR(Mission.start == None)).order(Mission.id).fetch(limit=None)
		
		template = JINJA_ENVIRONMENT.get_template('missions_hidden.html')
		self.response.write(template.render(template_vals))
Example #9
0
    def get(self, args):
        if not require_admin(self):
            return

        template_vals = generate_base_template_vals(self)
        template_vals['title'] = 'API Admin'
        template_vals['page'] = 'admin'

        template_vals['keys'] = APIKey.query().fetch(limit=None)

        template = JINJA_ENVIRONMENT.get_template('admin_api.html')
        self.response.write(template.render(template_vals))
Example #10
0
	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))
Example #11
0
    def get(self):
        template_vals = generate_base_template_vals(self)
        template_vals['title'] = 'Bridge Crew'
        template_vals['page'] = 'bridgecrew'

        # Get the bridge crew.
        template_vals['current_crew'] = BridgeCrew.query().order(
            -BridgeCrew.start).get()

        # Get past bridge crews.
        template_vals['past_crews'] = BridgeCrew.query().order(
            -BridgeCrew.start).fetch(limit=None)[1:]

        template = JINJA_ENVIRONMENT.get_template('bridge_crew_view.html')
        self.response.write(template.render(template_vals))
Example #12
0
	def get(self, req_id):
		if not req_id:
			# Redirect to the members list if no member is specified.
			self.redirect('/members')
			return
		
		member = Member.query(Member.id == req_id).get()
		if not member:
			# 404 if a nonexistent member is specified.
			self.error(404)
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['page'] = 'members'
		
		template_vals['member'] = member
		template_vals['title'] = member.name
		
		template = JINJA_ENVIRONMENT.get_template('member_info.html')
		self.response.write(template.render(template_vals))
Example #13
0
    def get(self, args):
        if not require_admin(self):
            return

        template_vals = generate_base_template_vals(self)
        template_vals['title'] = 'Admin Hub'
        template_vals['page'] = 'admin'

        # Get custom home page text.
        home_content = PageContent.query(PageContent.page == 'home').get()
        if not home_content:
            home_content = PageContent()
            home_content.page = 'home'
            home_content.text = ''
            home_content.put()

        template_vals['home_text'] = home_content.text

        template = JINJA_ENVIRONMENT.get_template('admin.html')
        self.response.write(template.render(template_vals))
Example #14
0
	def get(self, req_id):
		if not req_id:
			# Redirect to the missions page if no mission is specified.
			self.redirect('/missions')
			return
		
		mission = Mission.query(Mission.id == req_id).get()
		if not mission:
			# 404 if a nonexistent mission is specified.
			self.error(404)
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['page'] = 'missions'
		
		template_vals['mission'] = mission
		template_vals['title'] = mission.title
		
		template = JINJA_ENVIRONMENT.get_template('mission_info.html')
		self.response.write(template.render(template_vals))
Example #15
0
	def get(self, req_id):
		if not req_id:
			# Redirect to the missions page if no mission is specified.
			self.redirect('/missions')
			return
		
		mission = Mission.query(Mission.id == req_id).get()
		if not mission:
			# 404 if a nonexistent mission is specified.
			self.error(404)
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['page'] = 'missions'
		
		template_vals['mission'] = mission
		template_vals['title'] = mission.title
		
		template = JINJA_ENVIRONMENT.get_template('mission_info.html')
		self.response.write(template.render(template_vals))
Example #16
0
	def get(self):
		template_vals = generate_base_template_vals(self)
		template_vals['page'] = 'home'
		
		# Get the home page text.
		home_content = PageContent.query(PageContent.page == 'home').get()
		template_vals['home_html'] = home_content.html_text if home_content else ''
		
		# Get the next five missions.
		# Include missions happening today.
		now = datetime.now()
		today = datetime(now.year, now.month, now.day)
		template_vals['missions'] = Mission.query(Mission.start >= today).order(Mission.start).fetch(limit=5)
		
		# Pick an end quote.
		template_vals['greeting'] = choice([
			'Greetings from Earth!',
			'Greetings, program!',
			'Hello there!',
			'Welcome aboard!'
		])
		template_vals['groups_call_to_action'] = choice([
			'Boldly chat where some have chatted before',
			'Come chat with us',
			'Explore strange new groups',
			'Join our groups',
			'Join the collective',
			'Join the conversation'
		])
		template_vals['end_quote'] = choice([
			'Excelsior!',
			'Live long and prosper.',
			'May the Force be with you.',
			'Never give up!  Never surrender!'
		])
		
		template = JINJA_ENVIRONMENT.get_template('home.html')
		self.response.write(template.render(template_vals))
Example #17
0
	def get(self):
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'A/V Test'
		
		template = JINJA_ENVIRONMENT.get_template('av_test.html')
		self.response.write(template.render(template_vals))