def RenderSubmissionReview(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() waitingList = SubmittedProject.query( SubmittedProject.accepted == None and SubmittedProject.rejected == None).fetch(1000) allUsers = Character.query().fetch(10000) submissionList = {} #print waitingList #print allUsers #print submissionList for submission in waitingList: for thisUser in allUsers: if thisUser.userID == submission.userID: submissionList.update( {submission.key.integer_id(): [submission, thisUser]}) break template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), 'allSubmissions': submissionList, 'allUsers': allUsers, } self.RenderTemplate("admin", template_values)
def RenderCharacterReview(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() waitingCharacters = Character.GetWaitingCharacters() allCharacters = Character.GetAllCharacters() allCourseNames = {} allCourses = Course.GetAllCourses() if not allCourses is None: for course in allCourses: allCourseNames[course.key.integer_id( )] = course.courseNumber + ": " + course.courseName template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), 'waitingCharacters': waitingCharacters, 'allCharacters': allCharacters, 'allCourseNames': allCourseNames, } self.RenderTemplate("admin_Characters", template_values) return
def ProcessPostMessage(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Signup - ' + users.get_current_user().nickname() user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'linkURL': "/", 'linkText': "MainPage", } character = Character.GetCharacterByUser(user) if not character.username == "GUEST": self.RenderTemplate("failure", template_values) fullName = self.request.get("fullName") nickname = self.request.get("nickname") imgURL = self.request.get("imageURL") selectedCourse = self.request.get("selectedCourse") Character.PutNewCharacter(user, fullName, nickname, selectedCourse, imgURL) self.RenderTemplate("success", template_values)
def RenderSuccess(self): url = users.create_logout_url(self.request.uri) path = str(self.request.path) pathSplit = filter(None, path.split('/')) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Welcome Back Guest' user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetGuestCharacter(), 'projects_list': Project.GetProjects(), 'levelReqForA': Course.GetCourseByNumber("GUEST").levelReqForA, 'levelIconURL': Character.GetGuestCharacter().GetLevelIconURL(), } templateRefs = { "charactersheet": "charactersheet", "contact": "contact", "projects": "projects", "admin": "admin", } if len(pathSplit) == 1: self.RenderTemplate("index", template_values) else: self.RenderTemplate(templateRefs.get(pathSplit[1], "index"), template_values)
def ProcessCourseSubmission(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), 'linkURL': "/admin?page=courses", 'linkText': "Courses", } delete = self.request.get("delete") == "True" courseID = self.request.get("number") course = Course.GetCourseByNumber(courseID) if delete and course is not None: if course: course.Delete() self.RenderTemplate("failure", template_values) return name = self.request.get("name") number = self.request.get("number") description = self.request.get("description") maxLevel = self.request.get("maxLevel") syllabusLink = self.request.get("link") levelReqForA = self.request.get("levelForA") iconURL = self.request.get("iconURL") if course is None: course = Course() if len(name) < 0 or len(name) < 0 or len(name) < 0 or len( name) < 0 or len(name) < 0 or len(name) < 0: self.RenderTemplate("failure", template_values) return course.courseName = name course.courseNumber = number course.courseDescription = description course.maxProjectLevel = int(maxLevel) course.syllabusLink = syllabusLink course.levelReqForA = int(levelReqForA) course.iconURL = iconURL course.put() self.RenderTemplate("success", template_values) return
def ProcessPostMessage(self): newProjectKey = int(self.request.get("currentProjectKey")) if newProjectKey: user = users.get_current_user() character = Character.GetCharacterByUser(user) character.currentProjectKey = newProjectKey character.put() if bool(self.request.get("SubmitProject")): self.SubmitNewProject(users.get_current_user(), newProjectKey) self.response.write("Submission Passed!")
def RenderSuccess(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), } self.RenderTemplate("contact", template_values)
def ProcessCharacterSubmission(self): accepted = self.request.get("Accept") == 'True' userID = self.request.get("userID") character = Character.GetCharacterByID(userID) if character.fullName == "GUEST": self.handle_404(self.request, self.response, "") return if accepted: character.isUnderReview = False character.put() else: character.Delete()
def RenderSuccess(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Welcome Back ' + users.get_current_user().nickname( ) user = users.get_current_user() character = Character.GetCharacterByUser(user) allList = SubmittedProject.query( SubmittedProject.userID == user.user_id()).fetch(1000) completedList = [i for i in allList if i.accepted] course = Course.GetCourse(character.courseID) if course is None: course = Course.GetCourseByNumber("GUEST") allProjects = Project.GetProjects() projectsToDo = [] for proj in allProjects: addProj = True for sub in completedList: if sub.projectID == proj.key.integer_id(): addProj = False break if addProj: if proj.level <= character.level or proj.level == course.maxProjectLevel: projectsToDo.append(proj) template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': character, 'projects_list': projectsToDo, 'levelReqForA': course.levelReqForA, 'levelIconURL': character.GetLevelIconURL(), } allList = SubmittedProject.query( SubmittedProject.userID == user.user_id()).fetch(100) completedList = [i for i in allList if i.accepted] waitingList = [i for i in allList if not i.accepted and not i.rejected] if len(waitingList) > 0: template_values["submitted"] = True if completedList: template_values["completed_projects_list"] = completedList self.RenderTemplate("charactersheet", template_values)
def RenderSuccess(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Welcome Back ' + users.get_current_user().nickname( ) user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), 'waitingSubmission': SubmittedProject.UserHasWaitingSubmission(user), } self.RenderTemplate("index", template_values)
def RenderProjectList(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() projects = Project.GetProjects() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'projects_list': projects, 'character': Character.GetCharacterByUser(user) } self.RenderTemplate("projects", template_values)
def RenderCourseReview(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() allCourses = Course.GetAllCourses() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'character': Character.GetCharacterByUser(user), 'allCourses': allCourses, } self.RenderTemplate("admin_Courses", template_values) return
def RenderSignupPage(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Signup - ' + users.get_current_user().nickname() user = users.get_current_user() template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, } character = Character.GetCharacterByUser(user) if character.username == "GUEST": courses = Course.GetCourses() template_values["allCourses"] = courses self.RenderTemplate("signup", template_values) else: template_values['character'] = character self.RenderTemplate("signupExists", template_values)
def ProcessProjectSubmission(self): subKey = int(self.request.get("submissionKey")) accepted = bool(self.request.get("Accept")) userID = str(self.request.get("userID")) subCharacter = Character.GetCharacterByID(userID) submittedProject = SubmittedProject.query( SubmittedProject.userID == subCharacter.userID and (SubmittedProject.accepted == None and SubmittedProject.rejected == None)).fetch(1) #submittedProject = SubmittedProject.query(ndb.AND(SubmittedProject.userID == subCharacter.userID, ndb.AND(SubmittedProject.accepted == None , SubmittedProject.rejected == None))).fetch(1) if accepted: logging.info(submittedProject) if not submittedProject is None and len(submittedProject) == 1: submittedProject = submittedProject[0] submittedProject.accepted = True submittedProject.rejected = False submittedProject.ReviewedTime = datetime.datetime.now( ) - datetime.timedelta(hours=7) submittedProject.put() subCharacter.xp += Project.GetProject( submittedProject.projectID).xp subCharacter.UpdateLevel() subCharacter.currentProjectKey = 0 if subCharacter.numProjects is None: subCharacter.numProjects = 0 subCharacter.numProjects += 1 subCharacter.put() else: logging.error("Could not find Submitted Project!") else: if not submittedProject is None and len(submittedProject) == 1: submittedProject = submittedProject[0] submittedProject.accepted = False submittedProject.rejected = True submittedProject.ReviewedTime = datetime.datetime.now( ) - datetime.timedelta(hours=7) submittedProject.put() else: logging.error("Could not find Submitted Project!")
def IsUserInWhitelist(self, user): character = Character.GetCharacterByUser(user) if character.username == "GUEST" or character.isUnderReview: return False return True '''
def ProcessPostMessage(self): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' PAGE_DESCRIPTION = 'Admin ' + users.get_current_user().nickname() user = users.get_current_user() if self.IsUserInAdminWhitelist(user): stringKey = self.request.get("projectKey") if not stringKey == '': projectKey = int(stringKey) else: projectKey = -1 project = Project() if not projectKey == -1: project = Project.GetProject(projectKey) if project is None: self.RenderProjectList() return if bool(self.request.get("delete")): project.key.delete() self.RenderProjectList() return isSubmission = bool(self.request.get("save")) if isSubmission: newName = self.request.get("projectName") newDesc = self.request.get("description") newLevel = int(self.request.get("level")) newXP = int(self.request.get("xp")) newVideoURL = self.request.get("videoURL") newRequirements = [] for i in range(100): requirementValue = self.request.get("requirement_" + str(i)) if requirementValue == "": break newRequirements.append(requirementValue) newAttachments = [] for j in range(100): attachmentValue = self.request.get("attachment_" + str(j)) if attachmentValue == "": break newAttachments.append(attachmentValue) project.projectName = newName project.xp = newXP project.level = newLevel project.description = newDesc project.requirements = newRequirements project.attachments = newAttachments if not newVideoURL == 'None' or newVideoURL == "": project.videoURL = newVideoURL project.put() self.RenderProjectList() else: template_values = { 'titleDesc': PAGE_DESCRIPTION, 'url': url, 'url_linktext': url_linktext, 'user': user, 'project': project, 'character': Character.GetCharacterByUser(user) } self.RenderTemplate("projectEditor", template_values) else: self.handle_404(self.request, self.response, "")