• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Course类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parse_schedule

def parse_schedule():
    html = open("switcher/schedule.txt")
    counter = 0
    department = ""
    for line in html:
        print counter
        counter += 1
        if re.findall(r'\S+', line) == []:
            continue
        x = re.findall('([A-Z]+[\s,/&]*?[A-Z]+)\s\s+([0-9A-Z]+)\s+([\s\S]+[\S])', line)
        if x == []:
            department = line.strip()
            #print department
            #"""
            d = Department()
            d.init(department)
            d.save()
            #"""
        else:
            #print x
            code = x[0][0] + "." + x[0][1] + ".Spring.2014"
            #"""
            c = Course()
            c.init(code, d)
            c.save()
开发者ID:young-geng,项目名称:sectionswitcher,代码行数:25,代码来源:parse_schedule.py


示例2: get

    def get(self):
        from models import *

        from google.appengine.ext import db
        db.delete(Course.all())
        db.delete(Offerings.all())

        import re
        rx_department = re.compile(r'[A-Z]+')
        import csv
        reader = csv.DictReader(open('resources/dump.csv'))
        try:
            for course in reader:
                name = course['name']
                number = course['number']
                description = course['description'][:500]
                match = rx_department.match(number)
                department = number
                if match:
                    department = match.group(0)
                entry = Course(name=name, number=number, description=description, department=department)
                entry.put()

                for item in ['winter', 'spring', 'fall', 'summer']:
                    if 1 < len(course[item]):
                        offering = Offerings(course=entry, offered=item)
                        offering.put()
        except KeyError, e:
            pass
开发者ID:sampwing,项目名称:cmpe231_project,代码行数:29,代码来源:main.py


示例3: _course_exists

def _course_exists(request):
    form = CourseInitialForm(request.POST, request.FILES)
    if form.is_valid():
        section_number = ""
        if request.user.get_profile().school.title == "James Madison University":
            section_number = request.POST['course_id'].zfill(4)
        else:
            section_number = request.POST['course_id']
        try:
            course = Course.objects.get(
                number__iexact=request.POST['course_number'],
                course_id__iexact=section_number,
                institution__iexact=request.user.get_profile().school.title)
            return (True, course)
        except Course.DoesNotExist:
            wall = ConvoWall(wall_type=3)
            wall.save()
            course = Course(
                wall=wall,
                number=request.POST['course_number'],
                course_id=section_number,
                institution=request.user.get_profile().school.title)
            course.save()
        return (False, course)
    return (False, None)
开发者ID:mdavoodi,项目名称:konkourse-python,代码行数:25,代码来源:views.py


示例4: setUp

    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()

        # should all return None, because this is simply creating data and is all meant to be correct
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teacher', 't'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teachertwo', 'ttwo'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'student', 's'))

        self.teacher = User.all().filter('email =', '[email protected]').get()
        self.teacher2 = User.all().filter('email =', '[email protected]').get()
        self.student = User.all().filter('email =', '[email protected]' ).get()

        self.assertIsNotNone(self.teacher)
        self.assertIsNone(self.teacher.make_teacher())
        self.assertIsNotNone(self.teacher2)
        self.assertIsNone(self.teacher2.make_teacher())

        self.assertIsNone(Course.create(self.teacher, 'public', ''))
        self.public = Course.all().filter('name =', 'Public').get()
        self.assertIsNotNone(self.public)
        self.assertIsNone(Course.create(self.teacher, 'private', 'on'))
        self.private = Course.all().filter('name =', 'Private').get()
        self.assertIsNotNone(self.private)
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:25,代码来源:basetest.py


示例5: insert_course

def insert_course(dept, num, text):
    """ Regexes for extracting class properties; results go into capture group 1 """

    # Course Title  
    m = re.search("[\d\w]{5} - ([\w ]*)", text)
    title = m.group(1) if m else "nomatch"

    # Course Description
    m = re.search("\.\s(.*)\sTypically",text)
    des = m.group(1) if m else "nomatch"

    # Credit hours aren't fixed for every course
    # Credit Hours: 2.00
    # Credit Hours: 2.00 or 3.00. 
    # Credit Hours: 1.00 to 18.00. 
    m = re.search("Credit Hours: (\d+\.\d+)",text, flags=re.IGNORECASE)
    m = re.search("(\d+\.\d+)(.*?)Credit hours",text, flags=re.IGNORECASE) if not m else m
    cr = m.group(1) if m else "-1"

    # Semesters Offered
    m = re.search("Typically offered (.*?)\.", text)
    sem = m.group(1).split() if m else ["nomatch"]

    # Course Type: Lecture, Recitation, Lab, Seminar, etc.
    m = re.search("Schedule Types:\s((?:[\w ]+)(?:,[\w ]+)*) \s+", text)
    form = m.group(1).split(", ") if m else ["nomatch"]

    # Learning objectives will not necessarily follow campuses
    m = re.search("campuses:(\s+([\w\s])+\n)", text)
    campus = m.group(1).strip().split("\n\n") if m else ["nomatch"]
    campus = [camp.strip() for camp in campus]

    # prereq regex and decomosition of prereqs into lists of AND conditions (works for most classes, not 477 and similar)
    # re.DOTALL matches all characters, including "\n"
    idx = text.find("campuses:")
    m = re.search("Prerequisites:(.*)",text[idx:],flags=re.DOTALL)
    if m:
        allReqs = []
        prereqText = m.group(1).strip()
        prereqText =  prereqText.encode('ascii', 'ignore') 
        for i in PrereqParser.parseprereq(prereqText):
            reqArr = []
            for j in i.split():
                if j.find("-C") != -1:
                    j = j.replace("-C","")
                    reqArr.append(Requisite(course=j,reqType=False))
                else:
                    reqArr.append(Requisite(course=j,reqType=True))                    
            allReqs.append(RequisiteList(courses=reqArr))

    else:
        allReqs = []

    # create course entity
    course = Course(number=num, title=title, department=dept, form=form,
                     description=des, credits=float(cr), semesters=sem,
                     campuses=campus,requisites=allReqs, id=dept + num)
    # store course 
    course.put()
开发者ID:joey9z,项目名称:368_Project,代码行数:59,代码来源:main.py


示例6: test_create_course

 def test_create_course(self):
     c = Course(title = 'Some Course',
                start_time='09:00',
                slots=20)
     c.save()
     self.assertQuerysetEqual(Course.objects.all(),
                             ['<Course: Some Course>'])
     
开发者ID:regisan,项目名称:eventex-regisan,代码行数:7,代码来源:tests.py


示例7: test_course_insert

  def test_course_insert(self):
    print "in test_course_insert"
    setup(self)

    self.assertEqual(Course.objects.count(), 2)
    course3 = Course(teacher=Teacher.objects.get(pk=1), name="Grad3", position=3)
    course3.save()
    self.assertEqual(Course.objects.count(), 3)
开发者ID:Darkmer,项目名称:masterchief,代码行数:8,代码来源:tests.py


示例8: populate

def populate(line):
	overall = line.split('#')
	forCourses = overall[0].strip().split(',')
	y = [y.strip() for y in overall[1].strip().split('$')]
	c = Course(course_name=forCourses[0], course_ID=forCourses[1], course_acronym=forCourses[2], course_credits=int(forCourses[3]))
	c.save()
	c = Course.objects.get(pk=c.pk)
	for x in y:
		temp = [e.strip() for e in x.split(',')]
		c.offered_set.create(class_day=temp[0],start_time=str(1+TIME_CHOICES.index(temp[1])),end_time=str(1+TIME_CHOICES.index(temp[2])))
开发者ID:MayankVachher,项目名称:kron,代码行数:10,代码来源:populateScript.py


示例9: test_day

 def test_day(self):
     course = Course(
         slug='day-course',
         days=[
             ('Mondays', '7:00', '8:00pm'), ('Tuesdays', '3:00', '4:00pm')
         ]
     )
     self.assertEqual(course.day('mondays'), course.days[0])
     self.assertEqual(course.day('Tuesdays'), course.days[1])
     self.assertRaises(KeyError, lambda: course.day('Saturdays'))
开发者ID:mstriemer,项目名称:sweatitout,代码行数:10,代码来源:test.py


示例10: addcourses

    def addcourses(self):
        fields = ['name', 'short_desc', 'dept', 'number', 'level']

        parent = Key(Source, 'Udacity')

        for course in cdata:
            opt = dict(zip(fields, course))
            opt['source'] = parent
            kn = self.centid('Udacity', opt['dept'], opt['number'])
            opt['number'] = int(opt['number'])

            Course.get_or_insert(kn, **opt)
开发者ID:joshz,项目名称:testbulk,代码行数:12,代码来源:main.py


示例11: create_course

def create_course(request, name, description, price, discount, init_date, end_date):

    s = Session.objects.get(session_key=request.session["auth_token"])
    user = User.objects.get(login=s.get_decoded()['login'])
    if user.user_type != 'Creator':
        return HttpResponseBadRequest('User is not Creator')
    init_date_parsed = dateutil.parser.parse(init_date)
    end_date_parsed = dateutil.parser.parse(end_date)
    course = Course(creator=user, name=name, description=description, price=price, discount=discount,
                    init_date=init_date_parsed, end_date=end_date_parsed)
    course.save()
    return HttpResponse('Course created successful')
开发者ID:tak30,项目名称:coursapi,代码行数:12,代码来源:views.py


示例12: post

    def post(self):
        fields = ['source', 'number', 'dept', 'name', 'level', 'description']
        p = self.get_params_dict(fields)
        s = Source.query()
        c = Course.query()

        errors, p, kn = self.prepare_course(p, fields)
        context = {'errors': errors, 'sources': s, 'courses': c}

        if not errors:
            Course.get_or_insert(kn, **p)
            self.redirect('/')
        else:
            self.render('classes.html', context)
开发者ID:joshz,项目名称:testbulk,代码行数:14,代码来源:main.py


示例13: create_sample_courses

def create_sample_courses():
    for y in range(2009,2012):
        create_semester('Fall', y, 9, 1, 12, 31)
        create_semester('Spring', y, 1, 1, 5, 30)
    semesters = Semester.objects.all()

    for co,nm in [("CS 101", "Fundamentals of Computer Science"),
                  ("CS 102", "Programming I"),
                  ("CS 117", "Programming II"),
                  ("CS 150", "Operating Systems"),
                  ("CS 164", "Software Engineering"),
                  ("CS 130", "Algorithms & Data Structures")]:
        for sem in random.sample(semesters, 3):
            tag = co.replace(' ', '').lower() + sem.tag
            grp = Group(name=tag)
            grp.save()
            key = '%x' % random.getrandbits(24)
            c = Course(tag=tag, name=nm, code=co, semester=sem,
                       group=grp, key=key,
                       is_active=_flip())
            c.save()

            us = random.sample(User.objects.all(), random.randrange(4,8))
            num_instructors = random.choice([1,2])
            instrs = us[:num_instructors]
            studs = us[num_instructors:]

            for u in us:
                e = Enrollment(course=c, user=u,
                               kind = 'I' if u in instrs
                               else random.choice(['A', 'G']),
                               notify_on_commit = _flip(),
                               notify_new_grades = _flip())
                e.save()

            ln = CourseLink(course=c, kind='H',
                            url='http://liucs.net/%s/' % tag)
            ln.save()

            if _flip():
                ln = CourseLink(course=c, kind='T',
                                url='http://amazon.com/%s' % nm)
                ln.save()

            if _flip():
                fmt = random.choice(['http://liucs.net/svn/%s/',
                                     'http://github.com/league/%s'])
                ln = CourseLink(course=c, kind='R', url=fmt % tag)
                ln.save()
开发者ID:league,项目名称:l3ms,代码行数:49,代码来源:tests.py


示例14: _get_or_create_course

 def _get_or_create_course(self, course, department, instructors, attributes, restrictions, section):
     course_record = Course.query.filter_by(name=course.course_name).first()
     if not course_record:
         course_record = Course(name=course.course_name, subject=course.subject, subject_level=course.course_number)
         #print "Adding Course: \"%s-%s\"" % (course.subject, course.course_number)
         self.num_new_courses += 1
     if course.course_name not in self.course_names:
         self.num_courses += 1
         self.course_names[course.course_name] = True
     course_record.department = department
     course_record.attributes = attributes
     course_record.restrictions = restrictions
     course_record.sections.append(section)
     db.session.add(course_record)
     #db.session.commit()
     return course_record
开发者ID:Space-Cadets,项目名称:Oberon,代码行数:16,代码来源:database_builder.py


示例15: updateSummary

def updateSummary():

    logging.info("UPDATING SUMMARY")
    query = Summary.all()
    db.delete(query)
    courses = Course.all()
    items = []
    
    for course in courses:
        item = {}
        item['name'] = course.name
        item['id'] = course.cid
        item['hasSept'] = course.hasSeptemberResults
        item['hasFebr'] = course.hasFebruaryResults
        item['hasJune'] = course.hasJuneResults
        item['recent'] = course.nTimesUpdated
        item['addedJune'] = str(course.added_june)
        item['addedSept'] = str(course.added_sept)
        item['addedFebr'] = str(course.added_febr)
        items.append(item)
    
    summary = Summary()
    summary.courses = simplejson.dumps(items)
    summary.put()
    logging.info("FINISHED UPDATING SUMMARY")
开发者ID:ihasb33r,项目名称:dtps-students,代码行数:25,代码来源:update.py


示例16: myget

 def myget(self, course_id):
     course = Course.get_by_id(int(course_id))
     if course is None:
         return self.error(404)
     if not self.user.has_permission(course):
         self.redirect(LIST_COURSES_URL)
     return {'course': course}
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:7,代码来源:view.py


示例17: browse_one_course

def browse_one_course(request, course_query, school):
    """ View for viewing notes from a fuzzy course search
        :course_query: unicode url match, to be type parsed
    """
    # TODO: combine this function with `b_school_course`
    response = nav_helper(request)
    try:
        course_query = int(course_query)
    except ValueError:
        # cant be cast as an int, so we will search for it as a string
        pass
    course, files = Course.get_notes(course_query, school)
    response['course'], response['files'] = course, files
    # get the users who are members of the course
    response['profiles'] = course.userprofile_set.all()

    # get the karma events associated with the course
    response['events'] = course.reputationevent_set.order_by('-timestamp').all()  # FIXME: possibly order-by
    response['viewed_files'] = request.user.get_profile().files.all()

    # FIXME: I don't like this logic one bit, either annotate the db query or fix the schema to NEVER do this
    response['thanked_files'] = []
    response['flagged_files'] = []
    for file in files:
        _vote = file.votes.filter(user=request.user)
        if _vote.exists():
            if _vote[0].up:  # assuming only one vote result
                response['thanked_files'].append(file.id)
            else:
                response['flagged_files'].append(file.id)

    return render(request, 'browse_one_course.html', response)
开发者ID:mpevner,项目名称:djKarma,代码行数:32,代码来源:views.py


示例18: join_course

 def join_course(self, course_id, code=None):
     from models import Course, UserCourse  # do this because users.py & courses.py import each other
     if code is not None:
         course = Course.all().filter('code =', code).get()
     elif course_id is not None:
         course = Course.get_by_id(course_id)
     else:
         return ''
     if course is None:
         return 'Invalid code'
     if UserCourse.all().filter('user =', self).filter('course =', course).get():
         return 'You are already in the course'
     if course.teacher.key().id() == self.key().id():
         return 'You teach that course'
     UserCourse(user=self, course=course).put()
     return course
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:16,代码来源:users.py


示例19: get

    def get(self):
        query_text = cgi.escape(self.request.get("query"))
        q = Course.all().search(query_text).fetch(50)
        courses = []
        for course in q:
            coursevals = {'courseName': course.courseName,
                          'lat': course.latitude,
                          'lon': course.longitude,
                          'numholes': course.numberHoles,
                          'id': course.courseId,
                          'description': course.description.replace('\n', '<br />'),
                          'city': course.city,
                          'state': course.state,
                          'zip' : course.zip,
                          'teeType': course.teeType,
                          'basketType': course.basketType,
                          'holesLT300': course.holesLT300,
                          'holesBW300400': course.holesBW300400,
                          'holesGT400': course.holesGT400 }
            courses.append(coursevals)

        template_vals = {'courses': courses,
                         'query_text': query_text,
                         'gmaps_api_key': GMAPS_API_KEY,
                         'facebook': self.get_facebook() }
        path = os.path.join(os.path.dirname(__file__), 'templates/searchpage.html')
        self.response.out.write(template.render(path, template_vals))
开发者ID:posborne,项目名称:discgolfhub.com,代码行数:27,代码来源:discgolfhub.py


示例20: addcourse

def addcourse(request):
    category = 'Course'
    if request.method == 'POST':
        form = CourseForm(request.POST)
        if form.is_valid():
            s = Course(name=form.cleaned_data["name"],
                       code=form.cleaned_data["code"],
                       classroom=form.cleaned_data["classroom"],
                       times=form.cleaned_data["times"]
                       )
            s.save()
            return HttpResponseRedirect('/all_courses/')
    else:
        form = CourseForm()

    return render_to_response('add.html', {'form': form, 'type': category}, RequestContext(request))
开发者ID:mrtbz,项目名称:homework4,代码行数:16,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Customer类代码示例发布时间:2022-05-27
下一篇:
Python models.Corporation类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap