~schooltool-owners/schooltool/trunk

« back to all changes in this revision

Viewing changes to src/schooltool/course/browser/section.py

  • Committer: Douglas Cerna
  • Date: 2014-10-13 05:54:42 UTC
  • Revision ID: douglascerna@yahoo.com-20141013055442-12fsz45nibvl7erc
Changed Title to Name in pdf reports. Updated report descriptions and added locations subtitle to section reports

Show diffs side-by-side

added added

removed removed

Lines of Context:
1858
1858
    app_states_name = 'section-instruction'
1859
1859
 
1860
1860
 
1861
 
class SectionSignInOutPDFView(SignInOutPDFView):
 
1861
class SectionPDFViewBase(object):
 
1862
 
 
1863
    @property
 
1864
    def subtitles_left(self):
 
1865
        section = removeSecurityProxy(self.context)
 
1866
        instructors = '; '.join([person.title
 
1867
                                 for person in section.instructors])
 
1868
        locations =  '; '.join([r.title for r in self.context.resources
 
1869
                                if ILocation(r, None) is not None])
 
1870
        instructors_message = _('Instructors: ${instructors}',
 
1871
                                mapping={'instructors': instructors})
 
1872
        locations_message = _('Locations: ${locations}',
 
1873
                              mapping={'locations': locations})
 
1874
        subtitles = [
 
1875
            '%s (%s)' % (section.title, section.__name__),
 
1876
            instructors_message,
 
1877
            locations_message,
 
1878
            ]
 
1879
        return subtitles
 
1880
 
 
1881
    @property
 
1882
    def scope(self):
 
1883
        term = ITerm(self.context)
 
1884
        schoolyear = term.__parent__
 
1885
        return '%s | %s' % (term.title, schoolyear.title)
 
1886
 
 
1887
    @property
 
1888
    def title(self):
 
1889
        return ', '.join([course.title for course in self.context.courses])
 
1890
 
 
1891
 
 
1892
class SectionSignInOutPDFView(SectionPDFViewBase, SignInOutPDFView):
1862
1893
 
1863
1894
    @property
1864
1895
    def message_title(self):
1865
1896
        return _("section ${title} sign in & out",
1866
1897
                 mapping={'title': self.context.title})
1867
1898
 
1868
 
    def formatDate(self, date, format='mediumDate'):
1869
 
        if date is None:
1870
 
            return ''
1871
 
        formatter = getMultiAdapter((date, self.request), name=format)
1872
 
        return formatter()
1873
 
 
1874
 
    @property
1875
 
    def scope(self):
1876
 
        term = ITerm(self.context)
1877
 
        schoolyear = term.__parent__
1878
 
        return '%s | %s' % (term.title, schoolyear.title)
1879
 
 
1880
 
    @property
1881
 
    def subtitles_left(self):
1882
 
        section = removeSecurityProxy(self.context)
1883
 
        instructors = '; '.join([person.title
1884
 
                                 for person in section.instructors])
1885
 
        instructors_message = _('Instructors: ${instructors}',
1886
 
                                mapping={'instructors': instructors})
1887
 
        subtitles = [
1888
 
            '%s (%s)' % (section.title, section.__name__),
1889
 
            instructors_message,
1890
 
            ]
1891
 
        return subtitles
1892
 
 
1893
 
    @property
1894
 
    def title(self):
1895
 
        return ', '.join([course.title for course in self.context.courses])
1896
 
 
1897
1899
    @property
1898
1900
    def base_filename(self):
1899
1901
        courses = [c.__name__ for c in self.context.courses]
1905
1907
    report_builder = 'section_roster.pdf'
1906
1908
 
1907
1909
 
1908
 
class SectionRosterPDFView(flourish.report.PlainPDFPage):
 
1910
class SectionRosterPDFView(SectionPDFViewBase, flourish.report.PlainPDFPage):
1909
1911
 
1910
1912
    name = _('Section Roster')
1911
1913
 
1914
1916
        return _("section ${title} roster",
1915
1917
                 mapping={'title': self.context.title})
1916
1918
 
1917
 
    def formatDate(self, date, format='mediumDate'):
1918
 
        if date is None:
1919
 
            return ''
1920
 
        formatter = getMultiAdapter((date, self.request), name=format)
1921
 
        return formatter()
1922
 
 
1923
 
    @property
1924
 
    def scope(self):
1925
 
        term = ITerm(self.context)
1926
 
        schoolyear = term.__parent__
1927
 
        return '%s | %s' % (term.title, schoolyear.title)
1928
 
 
1929
 
    @property
1930
 
    def subtitles_left(self):
1931
 
        section = removeSecurityProxy(self.context)
1932
 
        instructors = '; '.join([person.title
1933
 
                                 for person in section.instructors])
1934
 
        instructors_message = _('Instructors: ${instructors}',
1935
 
                                mapping={'instructors': instructors})
1936
 
        subtitles = [
1937
 
            '%s (%s)' % (section.title, section.__name__),
1938
 
            instructors_message,
1939
 
            ]
1940
 
        return subtitles
1941
 
 
1942
 
    @property
1943
 
    def title(self):
1944
 
        return ', '.join([course.title for course in self.context.courses])
1945
 
 
1946
1919
    @property
1947
1920
    def base_filename(self):
1948
1921
        courses = [c.__name__ for c in self.context.courses]
1998
1971
            getter=lambda i, f: u']')
1999
1972
        title = table.column.LocaleAwareGetterColumn(
2000
1973
            name='title',
2001
 
            title=_(u'Title'),
 
1974
            title=_(u'Name'),
2002
1975
            getter=lambda i, f: i.title,
2003
1976
            subsort=True)
2004
1977
        level = zc.table.column.GetterColumn(
2017
1990
        return '5% 3% 3% 54% 35%'
2018
1991
 
2019
1992
 
2020
 
class SectionMailingLabelsPDFView(MailingLabelsPDFView):
 
1993
class SectionMailingLabelsPDFView(SectionPDFViewBase, MailingLabelsPDFView):
2021
1994
 
2022
1995
    @property
2023
1996
    def message_title(self):
2025
1998
                 mapping={'title': self.context.title})
2026
1999
 
2027
2000
    @property
2028
 
    def scope(self):
2029
 
        term = ITerm(self.context)
2030
 
        schoolyear = term.__parent__
2031
 
        return '%s | %s' % (term.title, schoolyear.title)
2032
 
 
2033
 
    @property
2034
 
    def subtitles_left(self):
2035
 
        section = removeSecurityProxy(self.context)
2036
 
        instructors = '; '.join([person.title
2037
 
                                 for person in section.instructors])
2038
 
        instructors_message = _('Instructors: ${instructors}',
2039
 
                                mapping={'instructors': instructors})
2040
 
        subtitles = [
2041
 
            '%s (%s)' % (section.title, section.__name__),
2042
 
            instructors_message,
2043
 
            ]
2044
 
        return subtitles
2045
 
 
2046
 
    @property
2047
 
    def title(self):
2048
 
        return ', '.join([course.title for course in self.context.courses])
2049
 
 
2050
 
    @property
2051
2001
    def base_filename(self):
2052
2002
        courses = [c.__name__ for c in self.context.courses]
2053
2003
        return 'section_mailing_labels_%s' % '_'.join(courses)