def get(self): user = auth.require_login(self) puzzleNum = self.request.get('p') logging.info(puzzleNum) if puzzleNum == '': self.display_not_found(user) else: puzzleNum = int(puzzleNum) if puzzleNum > NUM_PUZZLES or puzzleNum < 1: self.display_not_found(user) return attempts = get_attempts(user, puzzleNum-1) logging.info(attempts) for a in attempts: a['time_added'] = (a['time_added'] - timedelta(hours=6)).strftime('%Y-%m-%d %H:%M:%S') view = pages.render_view(PAGE_URI, {'attempts': attempts, 'puzzleNum': puzzleNum, 'puzzleTitle': models.puzzle_data.puzzle_titles[puzzleNum - 1]}) navbar = { 'team_name': user.team_name, 'logged_in' : True, 'team_score' : user.team_score } now = datetime.now() - timedelta(hours=6) #Get CST from UTC if now >= CLOSING_TIME: view = pages.render_view('/outoftime_main', {}) pages.render_page(self, view, navbar) return pages.render_page(self, view, navbar)
def get(self): user = authentication.auth.get_logged_in_user() if not user: authentication.auth.redirect_to_login(self) university = models.university.get_university(user.get_university()).to_json() semesters = models.semester.get_semesters_for_user(user) all_courses = {} for semester in semesters: all_courses[int(semester['number'])] = utils.utils.semester_as_list(semester['courses']) my_university = university['name'] my_majors = utils.utils.majors_as_text(user.get_majors()) all_majors = models.major.get_majors_for_university(university['id']) view = pages.render_view(DASHBOARD_URI, {'first_name': user.get_first_name(), 'last_name': user.get_last_name(), 'email': user.get_email(), 'my_university': my_university, 'my_majors': my_majors, 'my_courses': all_courses, 'all_majors': all_majors}) pages.render_page(self, view)
def get(self): user = auth.require_login(self) if not user: return self.redirect(ERROR_URI) ongoing_elections = models.election.get_ongoing_elections() for election in ongoing_elections: organization = models.organization.get_organization(election['organization']) election['organization'] = organization.title petitions = models.petition.get_petitions(user) expired_petitions = [] ongoing_petitions = [] for petition in petitions: election = models.election.get_election(petition['election']) petition['election'] = election.title organization = models.organization.get_organization(election.organization) petition['organization'] = organization.title petition['signatures_left'] = election.threshold - petition['signature_num'] if petition['signatures_left'] < 0: petition['signatures_left'] = 0 if election.end_date < date.today(): expired_petitions.append(petition) else: ongoing_petitions.append(petition) view = pages.render_view(MY_URI, {'expired_petitions': expired_petitions, 'ongoing_petitions': ongoing_petitions, 'ongoing_elections': ongoing_elections}) pages.render_page(self, view)
def get(self): user = authentication.auth.get_logged_in_user() if not user: authentication.auth.redirect_to_login(self) view = pages.render_view(LOAD_DATA_URI) pages.render_page(self, view)
def get(self): universities = models.university.get_all_universities() # utils.utils.add_test_data() # utils.load_data.load_data() view = pages.render_view(MAIN_URI, {"universities": universities}) pages.render_page(self, view)
def display_not_found(self, user): view = pages.render_view('/404', {}) navbar = { 'team_name': user.team_name, 'logged_in' : True, 'team_score' : user.team_score } pages.render_page(self, view, navbar)
def get(self): user = auth.require_login(self) #petitions = models.petition.get_petitions(user) effectivePetitions = models.petition.get_in_effect_petitions() expiredPetitions = models.petition.get_expired_petitions() logging.info("effective petitions: %s", effectivePetitions) for petition in effectivePetitions: print petition['votes'] view = pages.render_view(PAGE_URI, {'effectivePetitions': effectivePetitions, 'expiredPetitions':expiredPetitions}) pages.render_page(self, view)
def get(self): user = auth.require_login(self) if user.net_id in models.users_db.all_users: if user.team_name == None: #Initialize user.team_name = models.users_db.all_users[user.net_id] user.team_score = 0 user.put() view = pages.render_view(PAGE_URI, {'puzzles': PUZZLES_LIST}) navbar = { 'team_name': user.team_name, 'logged_in' : True, 'team_score' : user.team_score, 'puzzles' : True } pages.render_page(self, view, navbar) else: delete_user(user) view = pages.render_view('/notsignedup', {}) pages.render_page(self, view, {})
def get(self): user = auth.get_logged_in_user() navbar = {} if user: navbar = { 'team_name': user.team_name, 'logged_in' : True, 'team_score' : user.team_score, 'faq' : True } view = pages.render_view('/FAQ') pages.render_page(self, view, navbar)
def get(self): user = authentication.auth.get_logged_in_user() if not user: authentication.auth.redirect_to_login(self) semesters = models.semester.get_semesters_for_user(user) my_courses = {} all_my_courses = [] for semester in semesters: courses = [] for course_id in semester["courses"]: course = models.course.get_course(course_id).to_json() course = utils.utils.requisites_as_text(course) courses.append(course) all_my_courses.extend(courses) my_courses[int(semester["number"])] = courses majors = user.get_majors() logging.info("My Courses: %s", len(all_my_courses)) requirements = [] for major_id in majors: requirements.extend(models.requirement.get_requirements_for_major(major_id)) requirements_eval = utils.rules.evaluate_requirements(my_courses, requirements) all_courses = [] course_master = [] for requirement in requirements_eval["not_met"]: courses = [] for course_id in requirement["courses"]: course = models.course.get_course(course_id).to_json() course = utils.utils.requisites_as_text(course) if course not in course_master: course_master.append(course) courses.append(course) all_courses.append({"number": requirement["number"], "courses": courses}) messages, requisite_courses = utils.rules.evaluate_requisites(my_courses) missing_courses = [] for requisite_course in requisite_courses: if requisite_course not in course_master: missing_courses.append(requisite_course) if len(missing_courses) > 0: all_courses.append({"number": "requisites", "courses": missing_courses}) logging.info("All courses: %s", len(course_master) + len(missing_courses)) view = pages.render_view( PLAN_URI, {"semester_num": SEMESTER_NUM, "my_courses": my_courses, "all_courses": all_courses, "messages": messages}, ) pages.render_page(self, view)
def get(self): # if now #See if user if logged in user = auth.get_logged_in_user() navbar = {} if user: navbar = { 'team_name': user.team_name, 'logged_in' : True, 'team_score' : user.team_score } now = datetime.now() - timedelta(hours=6) #Get CST from UTC if now > HIDE_TIME and now < CLOSE_TIME: view = pages.render_view('/outoftime', {}) pages.render_page(self, view, navbar) return scores = get_users_leaderboard() view = pages.render_view(PAGE_URI, {'teams': scores}) pages.render_page(self, view, navbar)
def get(self): user = auth.require_login(self) if not user: return self.redirect(ERROR_URI) # Get the organization organization_id = self.request.get('id') organization = models.organization.get_organization(organization_id).to_json() logging.info("Organization: %s", organization) # Make sure the user is authorized to delete the organization assert user.get_id() in organization['admins'] admin_dict = {} for admin in organization['admins']: admin_dict[admin] = (user.get_id() == admin or ADMIN_ID == admin) organization['admins'] = admin_dict # Get all the elections for the organization elections = models.election.get_organization_elections(organization['id']) ongoing_elections = [] upcoming_elections = [] expired_elections = [] for election in elections: positions = {} for position in election['positions']: petitions = models.petition.get_petitions_for_position(election['id'], position) for petition in petitions: petition['signatures_left'] = election['threshold'] - petition['signature_num'] if petition['signatures_left'] < 0: petition['signatures_left'] = 0 positions[position] = petitions election['positions'] = positions if election['start_date'] > datetime.date.today(): upcoming_elections.append(election) elif election['end_date'] < datetime.date.today(): expired_elections.append(election) else: ongoing_elections.append(election) logging.info("Elections: %s", elections) view = pages.render_view(DASHBOARD_URI, {'organization': organization, 'ongoing_elections': ongoing_elections, 'upcoming_elections': upcoming_elections, 'expired_elections': expired_elections}) pages.render_page(self, view)
def get(self): user = auth.require_login(self) if not user: return self.redirect(ERROR_URI) # Get all the organizations organizations = models.organization.get_all_organizations() logging.info("organizations: %s", organizations) is_admin = user.get_id() == ADMIN_ID for organization in organizations: if user.get_id() in organization['admins'] or is_admin: organization['dashboard'] = True else: organization['dashboard'] = False if user.get_id() == ADMIN_ID: admins = ADMIN_ID else: admins = ADMIN_ID + ',' + user.get_id() view = pages.render_view(ORGANIZATION_URI, {'organizations': organizations, 'is_admin': is_admin, 'admins': admins, 'admin': ADMIN_ID}) pages.render_page(self, view)
def get(self): user = auth.require_login(self) if not user: return self.redirect(ERROR_URI) ongoing_elections = models.election.get_ongoing_elections() for election in ongoing_elections: organization = models.organization.get_organization(election['organization']) election['organization'] = organization.title logging.info("Ongoing Elections: %s", ongoing_elections) petitions = {} for election in ongoing_elections: election_id = election['id'] petitions[election['title']] = {} for position in election['positions']: petitions[election['title']][position] = models.petition.get_petitions_for_position(election_id, position) for petition in petitions[election['title']][position]: petition['signatures_left'] = election['threshold'] - petition['signature_num'] if petition['signatures_left'] < 0: petition['signatures_left'] = 0 if petition['user'].get_id() == user.get_id(): petition['own'] = True else: petition['own'] = False if user.get_id() in petition['signatures']: petition['signed'] = True else: petition['signed'] = False logging.info("Petitions: %s", petitions) view = pages.render_view(PETITIONS_URI, {'petitions': petitions, 'ongoing_elections': ongoing_elections}) pages.render_page(self, view)
def get(self): user = auth.require_login(self) stickies = models.sticky.get_stickies(user) view = pages.render_view(PAGE_URI, {'stickies': stickies}) pages.render_page(self, view)
def get(self): view = pages.render_view(MAIN_URI) pages.render_page(self, view)
def get(self): view = pages.render_view(ERROR_URI) pages.render_page(self, view)
def get(self): user = auth.require_login(self) myPetitions = models.petition.get_petitions(user) view = pages.render_view(MY_PAGE_URI, {'myPetitions': myPetitions}) pages.render_page(self, view)
def get(self): view = pages.render_view(PAGE_URI) pages.render_page(self, view)