Merge lp:~aelkner/schooltool/term_linkage into lp:schooltool/1.7

Proposed by Justas Sadzevičius
Status: Merged
Merged at revision: 2771
Proposed branch: lp:~aelkner/schooltool/term_linkage
Merge into: lp:schooltool/1.7
Diff against target: 88 lines (+58/-2)
3 files modified
src/schooltool/schoolyear/browser/ftests/first_last_crash.txt (+48/-0)
src/schooltool/schoolyear/browser/schoolyear.py (+8/-0)
src/schooltool/schoolyear/browser/templates/schoolyear.pt (+2/-2)
To merge this branch: bzr merge lp:~aelkner/schooltool/term_linkage
Reviewer Review Type Date Requested Status
Gediminas Paulauskas Pending
Review via email: mp+55867@code.launchpad.net

Description of the change

Fix for annoying bug when terms can't be named 'first' or 'last'.

To post a comment you must log in.
Revision history for this message
Justas Sadzevičius (justas.sadzevicius) wrote :

I completely forgot that Alan is going to work on this branch further... Please merge only rev 2770.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/schooltool/schoolyear/browser/ftests/first_last_crash.txt'
2--- src/schooltool/schoolyear/browser/ftests/first_last_crash.txt 1970-01-01 00:00:00 +0000
3+++ src/schooltool/schoolyear/browser/ftests/first_last_crash.txt 2011-04-01 05:43:28 +0000
4@@ -0,0 +1,48 @@
5+Adding terms named first or last
6+================================
7+
8+Originally, when the schoolyear index.html view was coded, if the user
9+chose either 'First' or 'Last' (any case) for the name of a term, the
10+schoolyear view would no longer work, crashing becuase it traversed to
11+the term (first or last) before applying the @@mediumDate adapter. To
12+fix this, the view class now has first and last properties that return
13+the actual attributes rather than traversing to the term. To test this,
14+we will add two terms to a schoolyear, one named 'First' and one named
15+'Last'.
16+
17+A manager logs in
18+
19+ >>> manager = Browser('manager', 'schooltool')
20+
21+And create a new school year:
22+
23+ >>> manager.getLink('Manage').click()
24+ >>> manager.getLink('School Years').click()
25+ >>> manager.getLink('New School Year').click()
26+ >>> manager.getControl('Title').value = '2010'
27+ >>> manager.getControl('First day').value = '2010-01-01'
28+ >>> manager.getControl('Last day').value = '2010-12-31'
29+ >>> manager.getControl('Add').click()
30+
31+Now we'll add the two woefully-titled terms to see that it doesn't crash.
32+
33+ >>> manager.getLink('Add a new term').click()
34+ >>> manager.getControl('Title').value = 'First'
35+ >>> manager.getControl('Start date').value = '2010-01-01'
36+ >>> manager.getControl('End date').value = '2010-06-30'
37+ >>> manager.getControl('Next').click()
38+ >>> manager.getControl('Add term').click()
39+
40+ >>> manager.getLink('Add a new term').click()
41+ >>> manager.getControl('Title').value = 'Last'
42+ >>> manager.getControl('Start date').value = '2010-07-01'
43+ >>> manager.getControl('End date').value = '2010-12-31'
44+ >>> manager.getControl('Next').click()
45+ >>> manager.getControl('Add term').click()
46+
47+Also, we see that the terms are in fact there.
48+
49+ >>> manager.printQuery("id('content-body')//input[@type='checkbox']")
50+ <input type="checkbox" name="delete.first" id="delete.first" />
51+ <input type="checkbox" name="delete.last" id="delete.last" />
52+
53
54=== modified file 'src/schooltool/schoolyear/browser/schoolyear.py'
55--- src/schooltool/schoolyear/browser/schoolyear.py 2010-09-15 13:52:08 +0000
56+++ src/schooltool/schoolyear/browser/schoolyear.py 2011-04-01 05:43:28 +0000
57@@ -458,6 +458,14 @@
58 def sorted_terms(self):
59 return sorted(self.context.values(), key=lambda t: t.last)
60
61+ @property
62+ def first(self):
63+ return self.context.first
64+
65+ @property
66+ def last(self):
67+ return self.context.last
68+
69 def update(self):
70 if 'CONFIRM' in self.request:
71 for key in self.listIdsForDeletion():
72
73=== modified file 'src/schooltool/schoolyear/browser/templates/schoolyear.pt'
74--- src/schooltool/schoolyear/browser/templates/schoolyear.pt 2009-11-28 07:47:57 +0000
75+++ src/schooltool/schoolyear/browser/templates/schoolyear.pt 2011-04-01 05:43:28 +0000
76@@ -15,10 +15,10 @@
77 <h1 metal:fill-slot="content-header" i18n:translate="">
78 <tal:block tal:content="view/context/title"
79 i18n:name="schoolyear_title">School Year Title</tal:block>
80- (<tal:block tal:content="view/context/first/@@mediumDate"
81+ (<tal:block tal:content="view/first/@@mediumDate"
82 i18n:name="start_date"/>
83 &mdash;
84- <tal:block tal:content="view/context/last/@@mediumDate"
85+ <tal:block tal:content="view/last/@@mediumDate"
86 i18n:name="end_date"/>)
87 </h1>
88 <metal:block metal:fill-slot="body"

Subscribers

People subscribed via source and target branches