当前位置: 首页>>代码示例>>Python>>正文


Python Student.put方法代码示例

本文整理汇总了Python中models.models.Student.put方法的典型用法代码示例。如果您正苦于以下问题:Python Student.put方法的具体用法?Python Student.put怎么用?Python Student.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.models.Student的用法示例。


在下文中一共展示了Student.put方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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')
            surname = self.request.get('form02')
            age = self.request.get('form03')

            # 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 = False
            student.name = name
            student.surname = surname
            student.age = age
            student.put()

        # Render registration confirmation page
        self.template_value['navbar'] = {'registration': True}
        self.render('confirmation.html')
开发者ID:osushkov,项目名称:greekcoursebuilder,代码行数:36,代码来源:utils.py

示例2: get

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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='Hello',
            first_name='Jeroen',
            last_name='Stravers',
            country='Nederland',
            birthday='12-08-1988',
            email='[email protected]',
            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)
开发者ID:ProjectCalla,项目名称:Datastore,代码行数:62,代码来源:api.py

示例3: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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")
开发者ID:roderickfanou,项目名称:Learning_analytics_on_GCB,代码行数:31,代码来源:utils.py

示例4: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
  def post(self):
    user = self.personalizePageAndGetUser()
    if not user:
      self.redirect(users.create_login_url(self.request.uri))
      return

    if (MAX_CLASS_SIZE and Student.all(keys_only=True).count() >= MAX_CLASS_SIZE):
      self.templateValue['course_status'] = 'full'
    else:
      # Create student record
      name = self.request.get('form01')

      # create new or re-enroll old student
      student = Student.get_by_email(user.email())
      if student:
        if not student.is_enrolled:
          student.is_enrolled = True
          student.name = name
      else:
        student = Student(key_name=user.email(), name=name, is_enrolled=True)
      student.put()

    # Render registration confirmation page
    self.templateValue['navbar'] = {'registration': True}
    self.render('confirmation.html')
开发者ID:maxwillzq,项目名称:AllAboutPython,代码行数:27,代码来源:utils.py

示例5: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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='Hello',
            first_name='Geddy',
            last_name='Schellevis',
            country='Nederland',
            birthday='05-03-1990',
            email='[email protected]',
            telephone_nr='0653380120',
            groups=['inf1F', 'inf2c'],
            zip_address='4444-LP',
            street='ergens',
            schedule=schedule_key,
            grade_list=grades_list_key
        )
        student.put()
开发者ID:ProjectCalla,项目名称:Datastore,代码行数:59,代码来源:api.py

示例6: _generate_students

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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))
开发者ID:google,项目名称:coursebuilder-core,代码行数:19,代码来源:gen_sample_data.py

示例7: create_or_enroll_student

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    def create_or_enroll_student(self, user, name):
        # 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()

            # Add to global student
            namespace = namespace_manager.get_namespace()
            try:
                namespace_manager.set_namespace("")
                global_student = Student(key_name=user.email())
                global_student.user_id = user.user_id()
                global_student.name = name
                global_student.put()
            finally:
                namespace_manager.set_namespace(namespace)

        student.is_enrolled = True
        student.name = name
        student.put()
开发者ID:sesamesushi,项目名称:satisrevude,代码行数:23,代码来源:utils.py

示例8: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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.additional_fields = additional_fields
            student.put()

        # Render registration confirmation page
        self.template_value['navbar'] = {'registration': True}
        self.render('confirmation.html')
开发者ID:ksh,项目名称:gpirecertification,代码行数:42,代码来源:utils.py

示例9: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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")
开发者ID:alu042,项目名称:bmed,代码行数:24,代码来源:utils.py

示例10: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
  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')
开发者ID:InDei-Haiti,项目名称:course-builder,代码行数:24,代码来源:utils.py

示例11: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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()
开发者ID:ProjectCalla,项目名称:Datastore,代码行数:25,代码来源:student.py

示例12: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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("formAge")
            student.additional_fields = additional_fields
            student.put()

        # Render registration confirmation page
        self.template_value["navbar"] = {"registration": True}
        self.render("confirmation.html")
开发者ID:esacosta,项目名称:u-mooc,代码行数:39,代码来源:utils.py

示例13: post

# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import put [as 别名]
    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')
开发者ID:twiffy,项目名称:eabooc,代码行数:81,代码来源:utils.py


注:本文中的models.models.Student.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。