コード例 #1
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveStudent(self):

        name = F.addName("Some", "Student")
        name1 = F.addName("Some", "Faculty")
        faculty = F.addFaculty(name, ["*****@*****.**"], "Lecturer", "sfac")

        student = F.addStudent(name, ["*****@*****.**", "*****@*****.**"], "PhD Student", "stud", [faculty])

        self.assert_(student.username == "stud")
        self.assert_("*****@*****.**" in student.emails and "*****@*****.**" in student.emails)
        self.assert_(student.name.first == "Some")
        self.assert_(student.name.last == "Student")
        self.assert_(student.name.suffix is None)
        self.assert_(student.name.middle is None)
        self.assert_(faculty.key() in student.advisors)

        key = student.key()

        student = db.get(key)

        self.assert_(student.username == "stud")
        self.assert_("*****@*****.**" in student.emails and "*****@*****.**" in student.emails)
        self.assert_(student.name.first == "Some")
        self.assert_(student.name.last == "Student")
        self.assert_(student.name.suffix is None)
        self.assert_(student.name.middle is None)
        self.assert_(faculty.key() in student.advisors)
コード例 #2
0
        def put_websites(websites):
            """
			adds Website records to DB from a list of xml website tags
		
			Keyword arguments:
			websites -- list of website xml tags
		
			no return
			"""
            group_list = []
            website_list = []

            if websites is not None:
                for website in websites:

                    url = get_text(website.find('url'))
                    group = get_text(website.find('group'))
                    group = Faculty3.addResearchGroup(group)

                    group_list.append(group)
                    authors = website.findall('author')

                    author_list = put_names(authors)
                    website_list.append(
                        Faculty3.addWebsite(url, group, author_list))

            for g in group_list:
                db.put(g)

            return website_list
コード例 #3
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveWebsite(self):
        ra = F.addResearchGroup("Beer drinkers anonymous")
        db.put(ra)

        auth1 = F.addName("Author", "One")
        auth2 = F.addName("Author", "Two")

        auth1_key = db.put(auth1)
        auth2_key = db.put(auth2)

        auths = [auth1, auth2]

        w = F.addWebsite("http://beer.com", ra, auths)

        self.assert_(w.address == "http://beer.com")
        self.assert_(w.group.name == "Beer drinkers anonymous")
        # self.assert_(len(w.authors) == 2)
        self.assert_(auth1_key in w.authors and auth2_key in w.authors)

        w_key = db.put(w)

        w = db.get(w_key)

        self.assert_(w.address == "http://beer.com")
        self.assert_(w.group.name == "Beer drinkers anonymous")
        # self.assert_(len(w.authors) == 2)
        self.assert_(auth1_key in w.authors and auth2_key in w.authors)
コード例 #4
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addOfficeHour(self):
        b = F.addBuilding("Office Hour Test", "ET")
        l = F.addLocation(b, "2nd", "201")
        s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010")

        oh = F.addOfficeHour(s, l)

        self.assert_(oh.type == "Office Hours")
        self.assert_(oh.location.building.name == "Office Hour Test" and oh.location.building.abbreviation == "ET")
        self.assert_(oh.location.floor == "2nd" and oh.location.room == "201")
        self.assert_(oh.schedule.start_date == "1/1/2000" and oh.schedule.end_date == "1/1/2010")
        self.assert_(oh.schedule.start_time == "1pm" and oh.schedule.end_time == "2pm")
        self.assert_("Monday" in oh.schedule.days and "Tuesday" in oh.schedule.days)

        db.put(oh)

        key = oh.key()

        oh = db.get(key)

        self.assert_(oh.type == "Office Hours")
        self.assert_(oh.location.building.name == "Office Hour Test" and oh.location.building.abbreviation == "ET")
        self.assert_(oh.location.floor == "2nd" and oh.location.room == "201")
        self.assert_(oh.schedule.start_date == "1/1/2000" and oh.schedule.end_date == "1/1/2010")
        self.assert_(oh.schedule.start_time == "1pm" and oh.schedule.end_time == "2pm")
        self.assert_("Monday" in oh.schedule.days and "Tuesday" in oh.schedule.days)
コード例 #5
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_writings(person_handle, writings):
			"""
			makes DB Writing objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			writings -- list of writings to associate with person
		
			no return
			"""
			for writing in writings:
				title = get_text(writing.find('title'))
				w_type = get_text(writing.find('writing'))
		
				publish_info_list = []
				publish_infos = writing.findall('publish_info')
				for publish_info in publish_infos:
					if publish_info is not None: 
						publisher = get_text(publish_info.find('publisher'))
						publish_date = get_text(publish_info.find('publish_date'))
						article = publish_info.find('article')
						if article is not None:
							journal = get_text(article.find('journal'))
							edition = get_text(article.find('edition'))
							article = Faculty3.addArticle(journal, edition)
						isbn = publish_info.find('isbn')
						if isbn is not None:
							isbn = get_text(isbn)
						publish_info_list.append(Faculty3.addPublishInfo(publisher, publish_date, isbn, article))
				authors = writing.findall('author')
				author_list = put_names(authors)
		
				writing = Faculty3.addWriting(title, w_type, author_list, publish_info_list)
				Faculty3.associatePersonWithWriting(person_handle, writing)
コード例 #6
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_websites(websites):
			"""
			adds Website records to DB from a list of xml website tags
		
			Keyword arguments:
			websites -- list of website xml tags
		
			no return
			"""
			group_list = []
			website_list = []
			
			if websites is not None:
				for website in websites:
		
					url = get_text(website.find('url'))
					group = get_text(website.find('group'))
					group = Faculty3.addResearchGroup(group)
					
					group_list.append(group)
					authors = website.findall('author')
					
					author_list = put_names(authors)
					website_list.append(Faculty3.addWebsite(url, group, author_list))
			
			for g in group_list:
				db.put(g)
				
			return website_list
コード例 #7
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_person(person):
			"""
			pulls xml 'name',  'email', 'username', and 'title' or 'status'
			from 'person', makes DB Faculty or Student Object
		
			Keyword arguments:
			person -- xml person tag
		
			return reference to DB Faculty or Student object
			"""
		
			assert person.tag == 'faculty' or person.tag == 'student'
		
			name = put_name(person.find('name'))
		
			username = None
			if person.find('username') is not None:
				username = person.find('username').text
		
			emails = person.findall('email')
			emails = [email.text for email in emails]
		
			if person.tag == 'faculty':
				title = get_text(person.find('title'))
				person_handle = Faculty3.addFaculty(name, emails, title, username)
			elif person.tag == 'student':
				status = get_text(person.find('status'))
				person_handle = Faculty3.addStudent(name, emails, status, username)
		
			return person_handle
コード例 #8
0
        def put_person(person):
            """
			pulls xml 'name',  'email', 'username', and 'title' or 'status'
			from 'person', makes DB Faculty or Student Object
		
			Keyword arguments:
			person -- xml person tag
		
			return reference to DB Faculty or Student object
			"""

            assert person.tag == 'faculty' or person.tag == 'student'

            name = put_name(person.find('name'))

            username = None
            if person.find('username') is not None:
                username = person.find('username').text

            emails = person.findall('email')
            emails = [email.text for email in emails]

            if person.tag == 'faculty':
                title = get_text(person.find('title'))
                person_handle = Faculty3.addFaculty(name, emails, title,
                                                    username)
            elif person.tag == 'student':
                status = get_text(person.find('status'))
                person_handle = Faculty3.addStudent(name, emails, status,
                                                    username)

            return person_handle
コード例 #9
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addLocation(self):
        b = F.addBuilding("Location Test", "LT")

        l = F.addLocation(b, "2nd", "201")

        self.assert_(l.building.name == "Location Test" and l.building.abbreviation == "LT")
        self.assert_(l.floor == "2nd" and l.room == "201")

        key = l.key()

        l = db.get(key)

        self.assert_(l.building.name == "Location Test" and l.building.abbreviation == "LT")
        self.assert_(l.floor == "2nd" and l.room == "201")
コード例 #10
0
        def put_courses(courses):
            """
			makes DB Course objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			courses -- list of courses to associate with person
		
			no return
			"""

            l = []

            for course in courses:
                unique = get_text(course.find('unique_number'))
                course_name = get_text(course.find('name'))
                description = get_text(course.find('description'))

                course_number = course.find('course_number')

                field_of_study = get_text(course_number.find('field_of_study'))
                short_number = get_text(course_number.find('short_number'))

                semester = get_text(course.find('semester'))
                year = get_text(course.find('year'))

                staff_members = course.findall('staff')
                staff = []

                for person in staff_members:
                    name = put_name(person.find('person'))
                    hours = person.find('hours')
                    if hours is not None:
                        hours = put_event(hours)
                        db.put(hours)
                        staff.append(Faculty3.addStaffMember(name, hours))

                schedule = course.find('schedule')
                schedule = put_event(schedule)
                db.put(schedule)
                course_number = Faculty3.addCourseNumber(
                    field_of_study, short_number)
                db.put(course_number)
                l.append(
                    Faculty3.addCourse(unique, course_name, description,
                                       course_number, semester, year, staff,
                                       schedule))

            return l
コード例 #11
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrievePublishInfo(self):
        article = F.addArticle("Psychology in the Lab", "47000")
        db.put(article)

        publish = F.addPublishInfo("Borders", "1/1/2010", "ISBN1234", article)

        self.assert_(publish.publisher == "Borders" and publish.date == "1/1/2010" and publish.isbn == "ISBN1234")
        self.assert_(publish.article.journal == "Psychology in the Lab" and publish.article.edition == "47000")

        key = publish.key()

        publish = db.get(key)

        self.assert_(publish.publisher == "Borders" and publish.date == "1/1/2010" and publish.isbn == "ISBN1234")
        self.assert_(publish.article.journal == "Psychology in the Lab" and publish.article.edition == "47000")
コード例 #12
0
        def put_phone_numbers(phone_numbers):
            """
			add a list of phone_numbers to the database, associating them with
			a person
		
			Keyword arguments:
			phone_numbers -- list of phone number xml tags
		
			no return
			"""
            l = []
            if phone_numbers is not None:
                for phone_number in phone_numbers:

                    phone_t = get_text(phone_number.find('phone_t'))
                    number = get_text(phone_number.find('number'))

                    country_code = phone_number.find('country_code')
                    if country_code is not None:
                        country_code = country_code.text
                    else:
                        country_code = '01'

                    area_code = phone_number.find('area_code')
                    if area_code is not None:
                        area_code = area_code.text
                    else:
                        area_code = '512'

                    l.append(
                        Faculty3.addPhoneNumber(phone_t, number, country_code,
                                                area_code))

            return l
コード例 #13
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_phone_numbers(phone_numbers):
			"""
			add a list of phone_numbers to the database, associating them with
			a person
		
			Keyword arguments:
			phone_numbers -- list of phone number xml tags
		
			no return
			"""
			l = []
			if phone_numbers is not None:
				for phone_number in phone_numbers:
		
					phone_t = get_text(phone_number.find('phone_t'))
					number = get_text(phone_number.find('number'))
		
					country_code = phone_number.find('country_code')
					if country_code is not None:
						country_code = country_code.text
					else:
						country_code = '01'
		
					area_code = phone_number.find('area_code')
					if area_code is not None:
						area_code = area_code.text
					else:
						area_code = '512'
		
					l.append(Faculty3.addPhoneNumber(phone_t, number, country_code, area_code))
					
			return l
コード例 #14
0
        def put_name(name):
            """
			creates a name object in the database
		
			Keyword arguments:
			name -- the xml tag 'name' (of a person)
		
			return reference to Name class db object
			"""

            #cannot be None since required
            first_name = get_text(name.find('first_name'))
            last_name = get_text(name.find('last_name'))

            #can be None
            middle_name = name.find('middle_name')
            suffix = name.find('suffix')

            if middle_name is not None:
                middle_name = get_text(middle_name)
            if suffix is not None:
                suffix = get_text(suffix)

            assert first_name is not None and last_name is not None

            return Faculty3.addName(first_name, last_name, middle_name, suffix)
コード例 #15
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
 def test_addRetrieveArticle(self):
     article = F.addArticle("Psychology in the Lab", "47000")
     self.assert_(article.journal == "Psychology in the Lab" and article.edition == "47000")
     db.put(article)
     key = article.key()
     article = db.get(key)
     self.assert_(article.journal == "Psychology in the Lab" and article.edition == "47000")
コード例 #16
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_name(name):
			"""
			creates a name object in the database
		
			Keyword arguments:
			name -- the xml tag 'name' (of a person)
		
			return reference to Name class db object
			"""
		
			#cannot be None since required
			first_name = get_text(name.find('first_name'))
			last_name = get_text(name.find('last_name'))
		
			#can be None
			middle_name = name.find('middle_name')
			suffix = name.find('suffix')
		
			if middle_name is not None:
				middle_name = get_text(middle_name)
			if suffix is not None:
				suffix = get_text(suffix)
		
			assert first_name is not None and last_name is not None
		
			return Faculty3.addName(first_name, last_name, middle_name, suffix)	
コード例 #17
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_courses(courses):
			"""
			makes DB Course objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			courses -- list of courses to associate with person
		
			no return
			"""
		
			l = []
			
			for course in courses:
				unique = get_text(course.find('unique_number'))
				course_name = get_text(course.find('name'))
				description = get_text(course.find('description'))
		
				course_number = course.find('course_number')
		
				field_of_study = get_text(course_number.find('field_of_study'))
				short_number = get_text(course_number.find('short_number'))
		
				semester = get_text(course.find('semester'))
				year = get_text(course.find('year'))
		
				staff_members = course.findall('staff')
				staff = []
		
				for person in staff_members:
					name = put_name(person.find('person'))
					hours = person.find('hours')
					if hours is not None:
						hours = put_event(hours)
						db.put(hours)
						staff.append(Faculty3.addStaffMember(name, hours))
		
				schedule = course.find('schedule')
				schedule = put_event(schedule)
				db.put(schedule)
				course_number = Faculty3.addCourseNumber(field_of_study, short_number)
				db.put(course_number)
				l.append(Faculty3.addCourse(unique, course_name, description, course_number, semester, year, staff, schedule))
		
		
			return l
コード例 #18
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveOffice(self):
        b = F.addBuilding("Office Test", "ET")
        l = F.addLocation(b, "2nd", "201")

        o = F.addOffice(l)

        self.assert_(o.location.building.name == "Office Test" and o.location.building.abbreviation == "ET")
        self.assert_(o.location.floor == "2nd" and o.location.room == "201")

        db.put(o)

        key = o.key()

        o = db.get(key)

        self.assert_(o.location.building.name == "Office Test" and o.location.building.abbreviation == "ET")
        self.assert_(o.location.floor == "2nd" and o.location.room == "201")
コード例 #19
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveConference(self):
        c = F.addConference("My Conference", "4/1/2010", "Chicago")

        self.assert_(c.name == "My Conference" and c.date == "4/1/2010" and c.location == "Chicago")

        key = c.key()

        c = db.get(key)

        self.assert_(c.name == "My Conference" and c.date == "4/1/2010" and c.location == "Chicago")
コード例 #20
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveResearchGroup(self):
        ra = F.addResearchGroup("Beer drinkers anonymous")

        self.assert_(ra.name == "Beer drinkers anonymous")

        key = db.put(ra)

        ra = db.get(key)

        self.assert_(ra.name == "Beer drinkers anonymous")
コード例 #21
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveResearchArea(self):
        ra = F.addResearchArea("Beer quality")

        self.assert_(ra.name == "Beer quality")

        key = db.put(ra)

        ra = db.get(key)

        self.assert_(ra.name == "Beer quality")
コード例 #22
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_advisees(person_handle, advisees):
			for advisee in advisees:
				name = put_name(advisee.find('name'))
				email = get_text(advisee.find('email'))
				status = get_text(advisee.find('status'))
		
				username = advisee.find('username')
				if username is not None:
					username = get_text(username)
		
				advisee = Faculty3.addStudent(name, [email], status, username, advisors = person_handle)
コード例 #23
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveEvent(self):
        b = F.addBuilding("Event Test", "ET")
        l = F.addLocation(b, "2nd", "201")
        s = F.addSchedule("1/1/2000", "1pm", ["Monday", "Tuesday"], "2pm", "1/1/2010")

        e = F.addEvent("Meeting", s, l)

        self.assert_(e.type == "Meeting")
        self.assert_(e.location.building.name == "Event Test" and e.location.building.abbreviation == "ET")
        self.assert_(e.location.floor == "2nd" and e.location.room == "201")

        db.put(e)

        key = e.key()

        e = db.get(key)

        self.assert_(e.type == "Meeting")
        self.assert_(e.location.building.name == "Event Test" and e.location.building.abbreviation == "ET")
        self.assert_(e.location.floor == "2nd" and e.location.room == "201")
コード例 #24
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveCourseNumber(self):
        c = F.addCourseNumber("CS", "373W")

        self.assert_(c.department == "CS" and c.number == "373W")

        db.put(c)

        key = c.key()

        c = db.get(key)

        self.assert_(c.department == "CS" and c.number == "373W")
コード例 #25
0
        def put_offices(offices):
            """
			makes DB Office objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these offices
			offices -- list of offices to associate with person
		
			no return
			"""
            l = []
            for office in offices:
                building = put_building(office.find('building'))

                floor = get_text(office.find('floor'))
                room = get_text(office.find('room'))

                location = Faculty3.addLocation(building, floor, room)
                l.append(Faculty3.addOffice(location))

            return l
コード例 #26
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_offices(offices):
			"""
			makes DB Office objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these offices
			offices -- list of offices to associate with person
		
			no return
			"""	
			l = []
			for office in offices:
				building = put_building(office.find('building'))
		
				floor = get_text(office.find('floor'))
				room = get_text(office.find('room'))
		
				location = Faculty3.addLocation(building, floor, room)
				l.append(Faculty3.addOffice(location))
			
			return l
コード例 #27
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addBuilding(self):
        b = F.addBuilding("Deschutes Brewery", "DB")

        self.assert_(b.name == "Deschutes Brewery")
        self.assert_(b.abbreviation == "DB")

        key = b.key()

        b = db.get(key)

        self.assert_(b.name == "Deschutes Brewery")
        self.assert_(b.abbreviation == "DB")
コード例 #28
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_conferences(conferences):
			"""
			makes DB Conference objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			conferences -- list of courses to associate person with
		
			no return
			"""
			l = []
			for conference in conferences:
				conf = conference.find('conference')
				date = get_text(conf.find('date'))
				name = get_text(conf.find('name'))
				conf_location = get_text(conf.find('conf_location'))
				presentation_title = get_text(conference.find('presentation_title'))
				conference = Faculty3.addConference(name, date, conf_location)
				l.append(Faculty3.addPresentation(presentation_title, conference))
			
			return l
コード例 #29
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveAward(self):
        a = F.addAward("Worst Code Design", "2010")

        self.assert_(a.name == "Worst Code Design")
        self.assert_(a.year == "2010")

        key = db.put(a)

        a = db.get(key)

        self.assert_(a.name == "Worst Code Design")
        self.assert_(a.year == "2010")
コード例 #30
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveFaculty(self):
        name = F.addName("This", "Sucks", "Really", "Bad")

        faculty = F.addFaculty(name, ["*****@*****.**", "*****@*****.**"], "Lecturer", "tsucks")

        self.assert_(faculty.username == "tsucks")
        self.assert_("*****@*****.**" in faculty.emails and "*****@*****.**" in faculty.emails)
        self.assert_(faculty.name.first == "This")
        self.assert_(faculty.name.last == "Sucks")
        self.assert_(faculty.name.suffix == "Bad")
        self.assert_(faculty.name.middle == "Really")

        faculty_key = db.put(faculty)

        faculty = db.get(faculty_key)

        self.assert_(faculty.username == "tsucks")
        self.assert_("*****@*****.**" in faculty.emails and "*****@*****.**" in faculty.emails)
        self.assert_(faculty.name.first == "This")
        self.assert_(faculty.name.last == "Sucks")
        self.assert_(faculty.name.suffix == "Bad")
        self.assert_(faculty.name.middle == "Really")
コード例 #31
0
        def put_writings(person_handle, writings):
            """
			makes DB Writing objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			writings -- list of writings to associate with person
		
			no return
			"""
            for writing in writings:
                title = get_text(writing.find('title'))
                w_type = get_text(writing.find('writing'))

                publish_info_list = []
                publish_infos = writing.findall('publish_info')
                for publish_info in publish_infos:
                    if publish_info is not None:
                        publisher = get_text(publish_info.find('publisher'))
                        publish_date = get_text(
                            publish_info.find('publish_date'))
                        article = publish_info.find('article')
                        if article is not None:
                            journal = get_text(article.find('journal'))
                            edition = get_text(article.find('edition'))
                            article = Faculty3.addArticle(journal, edition)
                        isbn = publish_info.find('isbn')
                        if isbn is not None:
                            isbn = get_text(isbn)
                        publish_info_list.append(
                            Faculty3.addPublishInfo(publisher, publish_date,
                                                    isbn, article))
                authors = writing.findall('author')
                author_list = put_names(authors)

                writing = Faculty3.addWriting(title, w_type, author_list,
                                              publish_info_list)
                Faculty3.associatePersonWithWriting(person_handle, writing)
コード例 #32
0
        def put_conferences(conferences):
            """
			makes DB Conference objects, associating them with their person
		
			Keyword arguments:
			person_handle -- person that owns these courses
			conferences -- list of courses to associate person with
		
			no return
			"""
            l = []
            for conference in conferences:
                conf = conference.find('conference')
                date = get_text(conf.find('date'))
                name = get_text(conf.find('name'))
                conf_location = get_text(conf.find('conf_location'))
                presentation_title = get_text(
                    conference.find('presentation_title'))
                conference = Faculty3.addConference(name, date, conf_location)
                l.append(
                    Faculty3.addPresentation(presentation_title, conference))

            return l
コード例 #33
0
        def put_advisees(person_handle, advisees):
            for advisee in advisees:
                name = put_name(advisee.find('name'))
                email = get_text(advisee.find('email'))
                status = get_text(advisee.find('status'))

                username = advisee.find('username')
                if username is not None:
                    username = get_text(username)

                advisee = Faculty3.addStudent(name, [email],
                                              status,
                                              username,
                                              advisors=person_handle)
コード例 #34
0
        def put_research_areas(research_areas):
            """
			make DB ResearchArea objects, associate them with their person
		
			Keyword arguments:
			research_areas -- list of research_area xml tags
		
			Return:
			list of objects
			"""
            l = []
            if research_areas is not None:
                for research_area in research_areas:
                    l.append(Faculty3.addResearchArea(get_text(research_area)))
            return l
コード例 #35
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrievePresentation(self):
        c = F.addConference("My Presentation Conference", "4/1/2010", "Austin")

        p = F.addPresentation("Project 7", c)

        self.assert_(p.name == "Project 7")
        self.assert_(
            p.conference.name == "My Presentation Conference"
            and p.conference.date == "4/1/2010"
            and p.conference.location == "Austin"
        )

        db.put(p)

        key = p.key()

        p = db.get(key)

        self.assert_(p.name == "Project 7")
        self.assert_(
            p.conference.name == "My Presentation Conference"
            and p.conference.date == "4/1/2010"
            and p.conference.location == "Austin"
        )
コード例 #36
0
        def put_office_hour(event):
            """
			makes DB Event objects, associating them with their ... association
		
			Keyword arguments:
			association -- thing (person, staff, or class maybe?) to associate with
			event -- one event xml tag
		
			return event
			"""

            location = put_location(event.find('location'))
            schedule = put_schedule(event.find('schedule'))

            return Faculty3.addOfficeHour(schedule, location)
コード例 #37
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_research_areas(research_areas):
			"""
			make DB ResearchArea objects, associate them with their person
		
			Keyword arguments:
			research_areas -- list of research_area xml tags
		
			Return:
			list of objects
			"""
			l = []
			if research_areas is not None:
				for research_area in research_areas:
					l.append(Faculty3.addResearchArea(get_text(research_area)))
			return l
コード例 #38
0
ファイル: Import.py プロジェクト: saadfsti/class
		def put_office_hour(event):
			"""
			makes DB Event objects, associating them with their ... association
		
			Keyword arguments:
			association -- thing (person, staff, or class maybe?) to associate with
			event -- one event xml tag
		
			return event
			"""
		
			location = put_location(event.find('location'))
			schedule = put_schedule(event.find('schedule'))
		
			return Faculty3.addOfficeHour(schedule, location)
コード例 #39
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveName(self):
        name = F.addName("This", "Sucks", "Really", "Bad")

        self.assert_(name.first == "This")
        self.assert_(name.last == "Sucks")
        self.assert_(name.suffix == "Bad")
        self.assert_(name.middle == "Really")

        name_key = name.key()

        name = db.get(name_key)

        self.assert_(name.first == "This")
        self.assert_(name.last == "Sucks")
        self.assert_(name.suffix == "Bad")
        self.assert_(name.middle == "Really")
コード例 #40
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrievePhone(self):
        phone = F.addPhoneNumber("work", "1234567", "01", "512")

        self.assert_(phone.type == "work")
        self.assert_(phone.number == "1234567")
        self.assert_(phone.country_code == "01")
        self.assert_(phone.area_code == "512")

        p_key = db.put(phone)

        p = db.get(p_key)

        self.assert_(p.type == "work")
        self.assert_(p.number == "1234567")
        self.assert_(p.country_code == "01")
        self.assert_(p.area_code == "512")
コード例 #41
0
ファイル: TestFaculty.py プロジェクト: tfausak/class
    def test_addRetrieveDegree(self):
        d = F.addDegree("2000", "University of Texas", "Master's Degree", "Crappy Code")

        self.assert_(d.year == "2000")
        self.assert_(d.institution == "University of Texas")
        self.assert_(d.type == "Master's Degree")
        self.assert_(d.specialization == "Crappy Code")

        key = db.put(d)

        d = db.get(key)

        self.assert_(d.year == "2000")
        self.assert_(d.institution == "University of Texas")
        self.assert_(d.type == "Master's Degree")
        self.assert_(d.specialization == "Crappy Code")
コード例 #42
0
        def put_location(location):
            """
			pulls xml 'floor' and 'room' from xml tag 'location', makes 
			Building DB object via function, associates it all together 
			in a DB Location object
		
			Keyword arguments:
			location -- xml tag 'location'
		
			return reference to DB Location object
			"""

            building = put_building(location.find('building'))
            floor = get_text(location.find('floor'))
            room = get_text(location.find('room'))
            return Faculty3.addLocation(building, floor, room)
コード例 #43
0
        def put_event(event):
            """
			makes DB Event objects, associating them with their ... association
		
			Keyword arguments:
			association -- thing (person, staff, or class maybe?) to associate with
			event -- one event xml tag
		
			return event
			"""

            event_type = get_text(event.find('event_type'))
            location = put_location(event.find('location'))
            schedule = put_schedule(event.find('schedule'))

            return Faculty3.addEvent(event_type, schedule, location)
コード例 #44
0
        def put_building(building):
            """
			pulls xml 'building_name' and 'building_abbr' from 'building, makes 
			DB Building object
		
			Keyword arguments:
			building -- xml building tag
		
			return reference to DB Building object
			"""

            building_abbr = building.find('building_abbr')
            if building_abbr is not None:
                building_abbr = get_text(building_abbr)
            building_name = get_text(building.find('building_name'))

            return Faculty3.addBuilding(building_name, building_abbr)
コード例 #45
0
        def put_research_groups(research_groups):
            """
			makes DB ResearchGroup objects, associating them with their person
		
			Keyword arguments:
			research_groups -- list of research_area xml tags
		
			Return:
			list of objects
			"""
            l = []
            if research_groups is not None:
                for research_group in research_groups:
                    l.append(
                        Faculty3.addResearchGroup(get_text(research_group)))

            return l
コード例 #46
0
        def put_awards(awards):
            """
			makes DB Award objects, associating them with their person
		
			Keyword arguments:
			awards -- list of award xml tags
		
			Return:
			list of awards that have not been put
			"""

            l = []
            if awards is not None:
                for award in awards:
                    name = get_text(award.find('name'))
                    date_awarded = get_text(award.find('date_awarded'))

                    l.append(Faculty3.addAward(name, date_awarded))
            return l
コード例 #47
0
        def put_degrees(degrees):
            """
			makes DB Degree objects, associating them with their person
		
			Keyword arguments:
			degrees -- list of degree xml tags
		
			Return:
			list of degrees that have not been put
			"""

            l = []
            if degrees is not None:
                for degree in degrees:
                    date_awarded = get_text(degree.find('date_awarded'))
                    institution = get_text(degree.find('institution'))
                    degree_t = get_text(degree.find('degree_t'))
                    specialization = get_text(degree.find('specialization'))

                    l.append(
                        Faculty3.addDegree(date_awarded, institution, degree_t,
                                           specialization))
            return l
コード例 #48
0
        def put_schedule(schedule):
            """
			pulls xml schedule sub-things from schedule, makes DB Schedule object
		
			Keyword arguments:
			building -- xml schedule tag
		
			return reference to DB Schedule object
			"""
            start_time = get_text(schedule.find('start_time'))
            end_time = get_text(schedule.find('end_time'))

            days = schedule.findall('day')
            day_list = []
            for day in days:
                day_list.append(get_text(day))

            start_date = get_text(schedule.find('start_date'))
            end_date = schedule.find('end_date')
            if end_date is not None:
                end_date = get_text(end_date)

            return Faculty3.addSchedule(start_date, start_time, day_list,
                                        end_time, end_date)
コード例 #49
0
    def post(self):
        '''
		Put all the submitted data into the data store and redirect to the person's page.
		@param self
		'''
        # Get the person's key from the query string and make it a Key object
        key = self.request.get('key')
        key = db.Key(key)

        # Get the person from the database
        person = db.get(key)

        # NAME
        name = {
            'first': self.request.get('name.first'),
            'middle': self.request.get('name.middle'),
            'last': self.request.get('name.last'),
            'suffix': self.request.get('name.suffix')
        }
        person.name = Faculty3.addName(**name)

        # USERNAME
        person.username = self.request.get('username')

        # TITLE / STATUS
        if person.kind() == 'Faculty':
            person.title = self.request.get('title')
        else:
            assert person.kind() == 'Student'
            person.status = self.request.get('status')

        # EMAILS
        emails = []
        for argument in self.request.arguments():
            if argument.startswith('email-') and self.request.get(
                    argument + '-toggle') == 'on':
                email = self.request.get(argument)
                emails.append(db.Email(email))
        person.emails = emails

        # WEBSITES
        websites = set()
        for argument in self.request.arguments():
            if argument.startswith('website-') and self.request.get(
                    argument + '-toggle') == 'on':
                address = self.request.get(argument)
                group = self.request.get(argument + '-group')
                group = db.get(group)
                website = Faculty3.addWebsite(address, group, [person.name])
                website = db.put(website)
                websites.add(website)
        person.websites = list(websites)

        # RESEARCH AREAS
        research_areas = set()
        for argument in self.request.arguments():
            if argument.startswith('research_area-') and self.request.get(
                    argument + '-toggle') == 'on':
                research_area = self.request.get(argument)
                research_area = db.Key(research_area)
                research_areas.add(research_area)
        person.research_areas = list(research_areas)

        # RESEARCH GROUPS
        research_groups = set()
        for argument in self.request.arguments():
            if argument.startswith('research_group-') and self.request.get(
                    argument + '-toggle') == 'on':
                research_group = self.request.get(argument)
                research_group = db.Key(research_group)
                research_groups.add(research_group)
        person.research_groups = list(research_groups)

        # Commit all changes to the data store and redirect to the person's page
        db.put(person)
        self.redirect('/view/person?key=' + str(key))