Merge lp:~replaceafill/schooltool/schooltool_1.4 into lp:schooltool/1.4

Proposed by Douglas Cerna
Status: Rejected
Rejected by: Gediminas Paulauskas
Proposed branch: lp:~replaceafill/schooltool/schooltool_1.4
Merge into: lp:schooltool/1.4
Diff against target: 287 lines (+191/-8)
8 files modified
CHANGES.txt (+2/-1)
src/schooltool/course/browser/ftests/new_schoolyear.txt (+35/-1)
src/schooltool/course/browser/ftests/sections_and_courses.txt (+2/-2)
src/schooltool/course/interfaces.py (+1/-1)
src/schooltool/generations/__init__.py (+2/-2)
src/schooltool/generations/evolve35.py (+39/-0)
src/schooltool/generations/tests/test_evolve35.py (+106/-0)
src/schooltool/schoolyear/browser/schoolyear.py (+4/-1)
To merge this branch: bzr merge lp:~replaceafill/schooltool/schooltool_1.4
Reviewer Review Type Date Requested Status
SchoolTool Owners Pending
Review via email: mp+73629@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gediminas Paulauskas (menesis) wrote :

I have merged schooltool_1.5 branch into 1.4, too

Unmerged revisions

2726. By Douglas Cerna

Updated schema manager

2725. By Douglas Cerna

Allowed non-integer values for course credits (https://bugs.launchpad.net/bugs/488376)
Add School Year copies all course attributes (https://bugs.launchpad.net/bugs/785994)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES.txt'
2--- CHANGES.txt 2010-11-30 19:32:38 +0000
3+++ CHANGES.txt 2011-09-01 04:44:43 +0000
4@@ -5,7 +5,8 @@
5 1.4.4 (unreleased)
6 ------------------
7
8-- Nothing changed yet.
9+- Allowed non-integer values for course credits (https://bugs.launchpad.net/bugs/488376)
10+- Add School Year copies all course attributes (https://bugs.launchpad.net/bugs/785994)
11
12
13 1.4.3 (2010-11-23)
14
15=== modified file 'src/schooltool/course/browser/ftests/new_schoolyear.txt'
16--- src/schooltool/course/browser/ftests/new_schoolyear.txt 2010-05-26 12:35:03 +0000
17+++ src/schooltool/course/browser/ftests/new_schoolyear.txt 2011-09-01 04:44:43 +0000
18@@ -32,11 +32,15 @@
19 >>> manager.getLink('New Course').click()
20 >>> manager.getControl('Title').value = 'History 5'
21 >>> manager.getControl('Description').value = 'History course for fifth-graders'
22+ >>> manager.getControl('Course ID').value = 'history-local'
23+ >>> manager.getControl('Government ID').value = 'history-gov'
24+ >>> manager.getControl('Credits').value = '5'
25 >>> manager.getControl('Add').click()
26
27 >>> manager.getLink('New Course').click()
28 >>> manager.getControl('Title').value = 'English 6'
29- >>> manager.getControl('Description').value = 'History course for sixth-graders'
30+ >>> manager.getControl('Description').value = 'English course for sixth-graders'
31+ >>> manager.getControl('Credits').value = '0.5'
32 >>> manager.getControl('Add').click()
33
34 The couses are there now:
35@@ -73,3 +77,33 @@
36 <div class="course">
37 <input type="checkbox" name="delete.history-5" /><a href="http://localhost/schoolyears/2006-2007/courses/history-5">History 5</a>
38 </div>
39+
40+Let's check that all the course attributes were copied:
41+
42+ >>> manager.getLink('History 5').click()
43+ >>> manager.printQuery('id("course-view")/p[@class="description"]/text()')
44+ History course for fifth-graders
45+ >>> manager.printQuery('id("course-view")/div[@class="info-block"][1]/p')
46+ <p>
47+ Course ID:
48+ history-local
49+ </p>
50+ <p>
51+ Government ID:
52+ history-gov
53+ </p>
54+ <p>
55+ Credits:
56+ 5
57+ </p>
58+
59+ >>> manager.getLink('2006-2007').click()
60+ >>> manager.getLink('Courses').click()
61+ >>> manager.getLink('English 6').click()
62+ >>> manager.printQuery('id("course-view")/p[@class="description"]/text()')
63+ English course for sixth-graders
64+ >>> manager.printQuery('id("course-view")/div[@class="info-block"][1]/p')
65+ <p>
66+ Credits:
67+ 0.5
68+ </p>
69
70=== modified file 'src/schooltool/course/browser/ftests/sections_and_courses.txt'
71--- src/schooltool/course/browser/ftests/sections_and_courses.txt 2010-04-08 06:59:12 +0000
72+++ src/schooltool/course/browser/ftests/sections_and_courses.txt 2011-09-01 04:44:43 +0000
73@@ -69,7 +69,7 @@
74 >>> manager.getControl('Description').value = "English course description"
75 >>> manager.getControl('Course ID').value = "english"
76 >>> manager.getControl('Government ID').value = "english101"
77- >>> manager.getControl('Credits').value = "4"
78+ >>> manager.getControl('Credits').value = "4.5"
79 >>> manager.getControl('Add').click()
80
81 Now let's add some sections for our courses:
82@@ -92,7 +92,7 @@
83 </p>
84 <p>
85 Credits:
86- 4
87+ 4.5
88 </p>
89
90 >>> manager.getLink('New Section').click()
91
92=== modified file 'src/schooltool/course/interfaces.py'
93--- src/schooltool/course/interfaces.py 2010-01-19 12:09:22 +0000
94+++ src/schooltool/course/interfaces.py 2011-09-01 04:44:43 +0000
95@@ -55,7 +55,7 @@
96 required=False,
97 description=_("Course identifier used by the government."))
98
99- credits = zope.schema.Int(
100+ credits = zope.schema.Decimal(
101 title=_("Credits"),
102 required=False,
103 description=_("Amount of credits for this course."))
104
105=== modified file 'src/schooltool/generations/__init__.py'
106--- src/schooltool/generations/__init__.py 2010-11-15 16:44:54 +0000
107+++ src/schooltool/generations/__init__.py 2011-09-01 04:44:43 +0000
108@@ -25,6 +25,6 @@
109 from zope.app.generations.generations import SchemaManager
110
111 schemaManager = SchemaManager(
112- minimum_generation=34,
113- generation=34,
114+ minimum_generation=35,
115+ generation=35,
116 package_name='schooltool.generations')
117
118=== added file 'src/schooltool/generations/evolve35.py'
119--- src/schooltool/generations/evolve35.py 1970-01-01 00:00:00 +0000
120+++ src/schooltool/generations/evolve35.py 2011-09-01 04:44:43 +0000
121@@ -0,0 +1,39 @@
122+#
123+# SchoolTool - common information systems platform for school administration
124+# Copyright (c) 2011 Shuttleworth Foundation
125+#
126+# This program is free software; you can redistribute it and/or modify
127+# it under the terms of the GNU General Public License as published by
128+# the Free Software Foundation; either version 2 of the License, or
129+# (at your option) any later version.
130+#
131+# This program is distributed in the hope that it will be useful,
132+# but WITHOUT ANY WARRANTY; without even the implied warranty of
133+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134+# GNU General Public License for more details.
135+#
136+# You should have received a copy of the GNU General Public License
137+# along with this program; if not, write to the Free Software
138+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
139+#
140+"""
141+Upgrade SchoolTool to generation 35.
142+
143+Changes course credits attribute from integer to decimal values.
144+"""
145+
146+from decimal import Decimal
147+
148+from zope.app.generations.utility import findObjectsProviding
149+from zope.app.publication.zopepublication import ZopePublication
150+
151+from schooltool.course.interfaces import ICourse
152+
153+
154+def evolve(context):
155+ root = context.connection.root().get(ZopePublication.root_name, None)
156+
157+ courses = findObjectsProviding(root, ICourse)
158+ for course in courses:
159+ if getattr(course, 'credits', None) is not None:
160+ course.credits = Decimal(course.credits)
161
162=== added file 'src/schooltool/generations/tests/test_evolve35.py'
163--- src/schooltool/generations/tests/test_evolve35.py 1970-01-01 00:00:00 +0000
164+++ src/schooltool/generations/tests/test_evolve35.py 2011-09-01 04:44:43 +0000
165@@ -0,0 +1,106 @@
166+#
167+# SchoolTool - common information systems platform for school administration
168+# Copyright (c) 2008 Shuttleworth Foundation
169+#
170+# This program is free software; you can redistribute it and/or modify
171+# it under the terms of the GNU General Public License as published by
172+# the Free Software Foundation; either version 2 of the License, or
173+# (at your option) any later version.
174+#
175+# This program is distributed in the hope that it will be useful,
176+# but WITHOUT ANY WARRANTY; without even the implied warranty of
177+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
178+# GNU General Public License for more details.
179+#
180+# You should have received a copy of the GNU General Public License
181+# along with this program; if not, write to the Free Software
182+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
183+#
184+"""
185+Unit tests for schooltool.generations.evolve35
186+"""
187+import unittest
188+import doctest
189+
190+from zope.app.testing import setup
191+from zope.interface import implements
192+from zope.container.contained import Contained
193+from zope.container.btree import BTreeContainer
194+
195+from schooltool.relationship.tests import setUpRelationships
196+from schooltool.generations.tests import ContextStub
197+from schooltool.app.interfaces import ISchoolToolApplication
198+from schooltool.course.interfaces import ICourse
199+
200+
201+class AppStub(BTreeContainer):
202+ implements(ISchoolToolApplication)
203+
204+
205+class CourseStub(Contained):
206+ implements(ICourse)
207+ credits = None
208+
209+ def __repr__(self):
210+ return '<CourseStub(__name__="%s", credits="%r")>' % (
211+ self.__name__, self.credits)
212+
213+
214+def doctest_evolve35():
215+ """Evolution to generation 35.
216+
217+ >>> context = ContextStub()
218+ >>> context.root_folder['app'] = app = AppStub()
219+
220+ Set up courses with integer credits:
221+
222+ >>> courses = app['courses'] = BTreeContainer()
223+ >>> courses['c1'] = CourseStub()
224+ >>> courses['c1'].credits = 5
225+ >>> courses['c2'] = CourseStub()
226+ >>> courses['c3'] = CourseStub()
227+ >>> courses['c3'].credits = 10
228+ >>> courses['c4'] = CourseStub()
229+ >>> courses['c4'].credits = 0
230+ >>> list(courses.values())
231+ [<CourseStub(__name__="c1", credits="5")>,
232+ <CourseStub(__name__="c2", credits="None")>,
233+ <CourseStub(__name__="c3", credits="10")>,
234+ <CourseStub(__name__="c4", credits="0")>]
235+
236+ Let's evolve now.
237+
238+ >>> from schooltool.generations.evolve35 import evolve
239+ >>> evolve(context)
240+
241+ Course credits are now updated to Decimal values.
242+
243+ >>> list(courses.values())
244+ [<CourseStub(__name__="c1", credits="Decimal('5')")>,
245+ <CourseStub(__name__="c2", credits="None")>,
246+ <CourseStub(__name__="c3", credits="Decimal('10')")>,
247+ <CourseStub(__name__="c4", credits="Decimal('0')")>]
248+
249+ """
250+
251+
252+def setUp(test):
253+ setup.placelessSetUp()
254+ setup.setUpAnnotations()
255+ setUpRelationships()
256+
257+
258+def tearDown(test):
259+ setup.placelessTearDown()
260+
261+
262+def test_suite():
263+ optionflags = (doctest.ELLIPSIS |
264+ doctest.NORMALIZE_WHITESPACE |
265+ doctest.REPORT_ONLY_FIRST_FAILURE)
266+ return doctest.DocTestSuite(setUp=setUp, tearDown=tearDown,
267+ optionflags=optionflags)
268+
269+
270+if __name__ == '__main__':
271+ unittest.main(defaultTest='test_suite')
272
273=== modified file 'src/schooltool/schoolyear/browser/schoolyear.py'
274--- src/schooltool/schoolyear/browser/schoolyear.py 2010-09-15 13:52:08 +0000
275+++ src/schooltool/schoolyear/browser/schoolyear.py 2011-09-01 04:44:43 +0000
276@@ -223,7 +223,10 @@
277 oldCourses = ICourseContainer(self.activeSchoolyear)
278 newCourses = ICourseContainer(self.newSchoolyear)
279 for id, course in oldCourses.items():
280- newCourses[course.__name__] = Course(course.title, course.description)
281+ newCourses[course.__name__] = new_course = Course(course.title, course.description)
282+ new_course.course_id = course.course_id
283+ new_course.government_id = course.government_id
284+ new_course.credits = course.credits
285
286 def importAllTimetables(self):
287 if not self.shouldImportAllTimetables():

Subscribers

People subscribed via source and target branches