def post(self): """Handles POST requests.""" user = self.personalize_page_and_get_user() if not user: self.redirect(users.create_login_url(self.request.uri)) return if not self.assert_xsrf_token_or_fail(self.request, 'register-post'): return can_register = self.app_context.get_environ( )['reg_form']['can_register'] if not can_register: self.template_value['course_status'] = 'full' else: name = self.request.get('form01') # create new or re-enroll old student student = Student.get_by_email(user.email()) if not student: student = Student(key_name=user.email()) student.user_id = user.user_id() student.is_enrolled = True student.name = name student.put() # Render registration confirmation page self.template_value['navbar'] = {'registration': True} self.render('confirmation.html')
def post(self): args = parse.parse_args() s_name = args.get('s_name') student = Student() student.s_name = s_name if not student.save(): abort(400, msg='not') return {'msg': 'Hello World'}
def get(self): schedule_items = [] schedule_items.append( ScheduleItem(time_from='10.30', time_until='12.50', vak_code='ANL05', docent_code='paris', chamber='h.05.002')) schedule_items.append( ScheduleItem(time_from='13.30', time_until='15.50', vak_code='SLC', docent_code='muill', chamber='H.04.318')) schedule_item_keys = [] for i in schedule_items: schedule_item_keys.append(i.put()) schedule = Schedule(day='Wednesday', schedule_item=schedule_item_keys) schedule_key = [schedule.put()] grade = Grade(study_points=4, passed=True, grades=8.1, docent='Busker', concept=False, exam_date='1-5-2015', mutation_date='5-5-2015', weight=1) grade_key = grade.put() grades_list = GradesList(vak_code='dev06', grades=grade_key) grades_list_key = [grades_list.put()] student = Student(parent=student_key(key="0846735"), student_nr="0846735", password='******', first_name='Jeroen', last_name='Stravers', country='Nederland', birthday='12-08-1988', email='*****@*****.**', telephone_nr='0678945032', groups=['inf1F', 'inf2c'], zip_address='4435-GK', street='Kruisplein', schedule=schedule_key, grade_list=grades_list_key) student.put() obj = {"test:", "done"} self.response.write(obj)
def __init__(self): self.newStudent_interest = Student_interest() self.newCourse_interest = Course_interest() self.newInterest = Interest() self.newCourse = Course() self.newStudent_subscription = Student_subscription() self.newStudent = Student() self.newInstructor = Instructor() self.newLesson = Lesson()
def post(self): schedule_items = [] schedule_items.append( ScheduleItem(time_from='08.30', time_until='10.50', vak_code='Dev05', docent_code='paris', chamber='wd.03.002')) schedule_items.append( ScheduleItem(time_from='11.30', time_until='13.50', vak_code='Skils', docent_code='Yolo', chamber='H.04.318')) schedule_item_keys = [] for i in schedule_items: schedule_item_keys.append(i.put()) schedule = Schedule(day='Monday', schedule_item=schedule_item_keys) schedule_key = [schedule.put()] grade = Grade(study_points=3, passed=True, grades=7.0, docent='busker', concept=False, exam_date='1-5-2015', mutation_date='5-5-2015', weight=1) grade_key = grade.put() grades_list = GradesList(vak_code='dev04', grades=grade_key) grades_list_key = [grades_list.put()] student = Student(parent=student_key(key="0883374"), student_nr="0883374", password='******', first_name='Geddy', last_name='Schellevis', country='Nederland', birthday='05-03-1990', email='*****@*****.**', telephone_nr='0653380120', groups=['inf1F', 'inf2c'], zip_address='4444-LP', street='ergens', schedule=schedule_key, grade_list=grades_list_key) student.put()
def add_students(self, prepod_id=None, count=10): for _ in range(count): student = Student(name=fake.first_name()) if prepod_id is None: prepod_id = self.add_prepod().id student.prepod_id = prepod_id self.connection.session.add(student) self.connection.session.commit()
def student_add(self, name): """Adds a student """ if name: new_student = Student(name=name) self.session.add(new_student) self.session.commit() click.secho(("Added student " + "'%s'" + " succesfully.") % (name), fg='green') else: click.secho("Warning! students'[name] cannot be empty.", fg='red')
def __init__(self): if 'student' not in session: return redirect(url_for('index')) self.newStudent_interest = Student_interest() self.newCourse_interest = Course_interest() self.newInterest = Interest() self.newCourse = Course() self.newStudent_subscription = Student_subscription() self.newStudent = Student() self.newInstructor = Instructor() self.newLesson = Lesson()
def __init__(self): if 'instructor' in session: self.loggedIn = True self.newStudent_interest = Student_interest() self.newCourse_interest = Course_interest() self.newInterest = Interest() self.newCourse = Course() self.newStudent_subscription = Student_subscription() self.newStudent = Student() self.newInstructor = Instructor() self.newLesson = Lesson() self.newStudent_question = Student_question() self.newQuestion_response = Question_response()
def add_students(self, prepod_id=None, count=10): for _ in range(count): # Создаем нового студента student = Student(name=fake.first_name()) if prepod_id is None: # Генерируем случайного препода, запоминаем его id prepod_id = self.add_prepod().id # Указываем преподавателя для студента student.prepod_id = prepod_id # Записываем созданную модуль в базу self.connection.session.add(student) self.connection.session.commit()
def signup(self): form = SignupForm() if request.method == 'POST': if form.validate() == False: return render_template('signup.html', form=form) else: session['student'] = {} newStudent = Student() id = newStudent.add(form.name.data, form.email.data, form.password.data, form.phone.data) session['student']['id'] = id session['student']['name'] = form.name.data session['student']['email'] = form.email.data return redirect(url_for('select_interests')) return render_template('signup.html', form=form)
def __init__(self): if 'instructor' in session: self.loggedIn = True else: return redirect(url_for('instructor_login')) self.newStudent_interest = Student_interest() self.newCourse_interest = Course_interest() self.newInterest = Interest() self.newCourse = Course() self.newStudent_subscription = Student_subscription() self.newStudent = Student() self.newInstructor = Instructor() self.newLesson = Lesson() self.newStudent_question = Student_question() self.newQuestion_response = Question_response() self.uploadFolder = 'static/images/courses_cover_photos' self.allowedExtensions = set(['png', 'jpg', 'jpeg', 'gif', 'psd'])
def _generate_students(self, student_emails): course = self.get_course() for email in student_emails: user_id = datastore_stub_util.SynthesizeUserId(email) student = Student(name='Student%s' % user_id, key_name=user_id, email=email, user_id=user_id, is_enrolled=True) Student.put(student) # Record our new student visiting the home page for our course, # then registering user = users.User(email=email, _user_id=user_id) host = os.environ['HTTP_HOST'] self.visit_page(user, 'http://%s/%s' % (host, course.title)) self.visit_page( user, 'http://%s/%s' '/course#registration_confirmation' % (host, course.title))
def run(self): """Computes student statistics.""" enrollment = EnrollmentAggregator() scores = ScoresAggregator() query = db.GqlQuery('SELECT * FROM %s' % Student().__class__.__name__, batch_size=10000) for student in query.run(): enrollment.visit(student) scores.visit(student) data = { 'enrollment': { 'enrolled': enrollment.enrolled, 'unenrolled': enrollment.unenrolled }, 'scores': scores.name_to_tuple } return data
def post(self): """Handles POST requests.""" user = self.personalize_page_and_get_user() if not user: self.redirect(users.create_login_url(self.request.uri), normalize=False) return if not self.assert_xsrf_token_or_fail(self.request, 'register-post'): return can_register = self.app_context.get_environ( )['reg_form']['can_register'] if not can_register: self.template_value['course_status'] = 'full' else: name = self.request.get('form01') additional_fields = transforms.dumps(self.request.POST.items()) # create new or re-enroll old student student = Student.get_by_email(user.email()) if not student: student = Student(key_name=user.email()) student.user_id = user.user_id() student_by_uid = Student.get_student_by_user_id(user.user_id()) is_valid_student = (student_by_uid is None or student_by_uid.user_id == student.user_id) assert is_valid_student, ( 'Student\'s email and user id do not match.') student.user_id = user.user_id() student.is_enrolled = True student.name = name student.age = self.request.get('form02') student.additional_fields = additional_fields student.put() # Render registration confirmation page self.template_value['navbar'] = {'registration': True} self.render('confirmation.html')
def post(self): username = self.request.get("username") password = self.request.get("password") regId = self.request.get("regId") student_query = Student.query(ancestor=student_key( key=username)).order(Student.student_nr) students = student_query.fetch(1) logging.info(students) if students: logging.info("student bestaat al") else: # call the crawler api for injecting the user to the crawler logging.info(username) logging.info(password) student = Student(parent=student_key(key=username), student_nr=username, password=password, registration_id=regId) student.put()
def addstu(): grades = Grade.query.all() if request.method == 'GET': students = Student.query.all() return render_template('addstu.html', students=students, grades=grades) if request.method == 'POST': s_name = request.form['s_name'] s_sex = request.form['s_sex'] # print(s_sex) g_name = request.form['g_name'] name = Student.query.filter(Student.s_name == s_name).first() if name: msg = '学生已经存在' return render_template('addstu.html', msg=msg, grades=grades) elif s_name == '': msg = '添加失败,学生名为空' return render_template('addstu.html', msg=msg, grades=grades) else: student = Student(s_name=s_name, s_sex=s_sex, grade_id=g_name) db.session.add(student) db.session.commit() return redirect('/user/student/')
def post(self): user = users.get_current_user() if user: email = user.email() self.templateValue['email'] = email self.templateValue['logoutUrl'] = users.create_logout_url('/') # Restrict the maximum course size to 250000 people # FIXME: you can change this number if you wish. students = Student.all(keys_only=True) if (students.count() > 249999): self.templateValue['course_status'] = 'full' # Create student record name = self.request.get('form01') student = Student(key_name=user.email(), name=name) student.put() # Render registration confirmation page navbar = {'registration': True} self.templateValue['navbar'] = navbar self.render('confirmation.html')
def post(self): args = parser.parse_args() student = Student(name=args['name'], group=args['group']) db.session.add(student) db.session.commit() return 201
def post(self): """Handles POST requests.""" user = self.personalize_page_and_get_user() if not user: self.redirect( users.create_login_url(self.request.uri), normalize=False) return if not self.assert_xsrf_token_or_fail(self.request, 'register-post'): return can_register = self.app_context.get_environ( )['reg_form']['can_register'] if not can_register: self.template_value['course_status'] = 'full' else: missing = self.find_missing_fields(self.request.POST) if missing: self.template_value['navbar'] = {'registration': True} self.template_value['content'] = ''' <div class="gcb-col-11 gcb-aside"> <h2>Something is missing...</h2> <p>You didn't fill out all the required fields in the registration form. Please use your browser's BACK button, and complete the form before submitting.</p> <p>Missing: {0}</p> <p>Thanks!</p> </div> '''.format(", ".join(missing)) self.render('bare.html') return # We accept the form. Now populate the student model: # create new or re-enroll old student student = Student.get_by_email(user.email()) if not student: student = Student(key_name=user.email()) student.user_id = user.user_id() student_by_uid = Student.get_student_by_user_id(user.user_id()) is_valid_student = (student_by_uid is None or student_by_uid.user_id == student.user_id) assert is_valid_student, ( 'Student\'s email and user id do not match.') student.user_id = user.user_id() student.is_enrolled = True string_fields = ('name', 'location_city', 'location_state', 'location_country', 'education_level', 'role', 'other_role') for field in string_fields: setattr(student, field, self.request.POST.get(field, None)) string_list_fields = ('grade_levels', 'title_and_setting', 'research_area', 'faculty_area', 'student_subject') for field in string_list_fields: raw = self.request.POST.get(field, '') if len(raw) > 0: values = [s.strip() for s in raw.split(',')] setattr(student, field, values) student.put() # now that we're in full registration, don't subscribe to pre-reg any more #mailchimp.subscribe('pre-reg', user.email(), student.name) self.redirect('confirm') return # Render registration confirmation page self.template_value['navbar'] = {'registration': True} self.render('confirmation.html')