~sielibre/schooltool.isli/2.10_packaging

« back to all changes in this revision

Viewing changes to src/schooltool/isli/browser/assessment.py

  • Committer: Douglas Cerna
  • Date: 2015-06-21 07:25:28 UTC
  • Revision ID: douglascerna@yahoo.com-20150621072528-di9y1eetfhcacc85
Added note reports

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
ISLI assessment.
20
20
"""
21
21
 
 
22
from zope.interface import implements
 
23
from zope.schema.interfaces import IContextSourceBinder
 
24
from zope.schema.vocabulary import SimpleVocabulary
22
25
from zope.traversing.browser.absoluteurl import absoluteURL
23
26
 
24
27
from schooltool.app.browser.app import ActiveSchoolYearContentMixin
32
35
    def report_link(self):
33
36
        url = absoluteURL(self.schoolyear, self.request)
34
37
        return '%s/%s' % (url, self.link)
 
38
 
 
39
 
 
40
class YearTermsVocabulary(SimpleVocabulary):
 
41
 
 
42
    implements(IContextSourceBinder)
 
43
 
 
44
    def __init__(self, context):
 
45
        self.context = context
 
46
        terms = self.createTerms()
 
47
        SimpleVocabulary.__init__(self, terms)
 
48
 
 
49
    def createTerms(self):
 
50
        result = []
 
51
        schoolyear = self.context['schoolyear']
 
52
        for term in sorted(schoolyear.values(), key=lambda t: t.first):
 
53
            result.append(self.createTerm(term, term.__name__, term.title))
 
54
        return result
 
55
 
 
56
 
 
57
def YearTermsVocabularyFactory():
 
58
    return YearTermsVocabulary