Example #1
0
    def get(self, args):
        # TODO: Create proper bridge crew editor.
        if not require_admin(self):
            return

        new_crew = BridgeCrew()
        new_crew.put()
Example #2
0
    def post(self, args):
        if not require_admin(self):
            return

        # Ensure a name was passed.
        name = self.request.get('name')
        if not name:
            self.error(422)
            self.response.write(
                '<h1>422 Unprocessable Entity</h1><p>No name was specified.</p>'
            )
            return

        # Ensure the name has not already been used.
        existing_entity = APIKey.query(APIKey.name == name).get()
        if existing_entity:
            self.error(409)
            self.response.write(
                '<h1>409 Conflict</h1><p>A key with that name already exists.</p>'
            )
            return

        # Create a new ID and verify it is unique.
        while True:
            new_key = uuid4().hex
            if not APIKey.query(APIKey.key == new_key).get():
                break

        # Add the new key entity to the datastore.
        new_entity = APIKey()
        new_entity.name = name
        new_entity.key = new_key
        new_entity.put()

        self.redirect('/admin/api', code=303)
Example #3
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 #4
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 #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 post(self, args):
		if not require_admin(self):
			return
		
		req_id = self.request.get('id')
		if not req_id:
			self.error(422)
			return
		
		mission = Mission.query(Mission.id == req_id).get()
		if not mission:
			mission = Mission()
			req_id = req_id.strip().lower().replace(' ', '-')
			mission.id = req_id
		
		# Update int values.
		for int_param in ['type']:
			req_val = self.request.get(int_param)
			if req_val or req_val == 0:
				req_val = int(req_val)
				setattr(mission, int_param, req_val)
		
		# Update string values.
		for str_param in ['title', 'description', 'location', 'wave_url', 'drive_url', 'intro_url', 'pres_url', 'sign_in_url', 'fb_url', 'gplus_url', 'the_link_url', 'youtube_url']:
			req_val = self.request.get(str_param)
			if req_val or req_val == '':
				req_val = urllib2.unquote(req_val)
				req_val = req_val.strip()
				setattr(mission, str_param, req_val)
		
		# Update date values.
		for date_param in ['start', 'end']:
			req_val = self.request.get(date_param)
			if req_val:
				req_val = urllib2.unquote(req_val)
				req_val = datetime.strptime(req_val, '%Y-%m-%dT%H:%M')
				setattr(mission, date_param, req_val)
			else:
				setattr(mission, date_param, None)
		
		# Update array values.
		req_runners = self.request.get('runners')
		if req_runners:
			req_runners = req_runners.replace(' ','').split(',')
			mission.runners = req_runners
		else:
			mission.runners = []
		
		# Save the updated mission.
		mission.put()
		
		if not mission.start:
			self.redirect('/missions/hidden', code=303)
			return
		
		self.redirect('/missions/' + mission.id, code=303)
Example #7
0
	def post(self, args):
		if not require_admin(self):
			return
		
		req_id = self.request.get('id')
		if not req_id:
			self.error(422)
			return
		
		mission = Mission.query(Mission.id == req_id).get()
		if not mission:
			mission = Mission()
			req_id = req_id.strip().lower().replace(' ', '-')
			mission.id = req_id
		
		# Update int values.
		for int_param in ['type']:
			req_val = self.request.get(int_param)
			if req_val or req_val == 0:
				req_val = int(req_val)
				setattr(mission, int_param, req_val)
		
		# Update string values.
		for str_param in ['title', 'description', 'location', 'wave_url', 'drive_url', 'intro_url', 'pres_url', 'sign_in_url', 'fb_url', 'gplus_url', 'the_link_url', 'youtube_url']:
			req_val = self.request.get(str_param)
			if req_val or req_val == '':
				req_val = urllib2.unquote(req_val)
				req_val = req_val.strip()
				setattr(mission, str_param, req_val)
		
		# Update date values.
		for date_param in ['start', 'end']:
			req_val = self.request.get(date_param)
			if req_val:
				req_val = urllib2.unquote(req_val)
				req_val = datetime.strptime(req_val, '%Y-%m-%dT%H:%M')
				setattr(mission, date_param, req_val)
			else:
				setattr(mission, date_param, None)
		
		# Update array values.
		req_runners = self.request.get('runners')
		if req_runners:
			req_runners = req_runners.replace(' ','').split(',')
			mission.runners = req_runners
		else:
			mission.runners = []
		
		# Save the updated mission.
		mission.put()
		
		if not mission.start:
			self.redirect('/missions/hidden', code=303)
			return
		
		self.redirect('/missions/' + mission.id, code=303)	
Example #8
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 #9
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 #10
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 #11
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 #12
0
	def get(self):
		if not require_admin(self):
			return
		
		members = Member.query(Member.mailing_list == True).fetch(limit=None)
		mailing_list = []
		
		for index, member in enumerate(members):
			if (index + 1) % 100 == 0:
				mailing_list.append('\n')
			if member.email:
				mailing_list.append(member.name + ' <' + member.email + '>')
			elif member.dce:
				mailing_list.append(member.name + ' <' + member.dce + '@rit.edu>')
		
		self.response.headers['Content-Type'] = 'text/plain'
		self.response.write('; '.join(mailing_list))
Example #13
0
    def post(self, args):
        if not require_admin(self):
            return

        home_text = self.request.get('home_text')
        if not home_text:
            self.error(422)
            self.response.write('<h1>422 Unprocessable Entity</h1>')
            return

        home_content = PageContent.query(PageContent.page == 'home').get()
        if not home_content:
            home_content = PageContent()
            home_content.page = 'home'

        home_content.text = home_text
        home_content.put()

        self.redirect('/admin', code=303)
Example #14
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 #15
0
	def post(self, args):
		if not require_admin(self):
			return
		
		req_id = self.request.get('id')
		if not req_id:
			self.error(422)
			return
		
		member = Member.query(Member.id == req_id).get()
		if not member:
			member = Member()
			member.id = req_id
		
		# Update string values.
		for str_param in ['name', 'dce', 'email', 'card_color', 'card_emblem']:
			req_val = self.request.get(str_param)
			if req_val or req_val == '':
				req_val = req_val.strip()
				setattr(member, str_param, urllib2.unquote(req_val))
		
		# Update boolean values.
		for bool_param in ['show','mailing_list', 'current_student', 'committee_rank', 'merit_rank1', 'merit_rank2', 'card_printed']:
			req_val = self.request.get(bool_param)
			setattr(member, bool_param, not not req_val)
		
		# Update multi-select values.
		member.semesters_paid = [float(semester) for semester in self.request.get('semesters_paid', allow_multiple=True)]
		
		# Save the updated member.
		member.put()
		
		if member.never_paid:
			self.redirect('/members/hidden', code=303)
			return
		
		self.redirect('/members/' + member.id, code=303)