Ignore:
Timestamp:
27 Apr 2011, 07:43:49 (14 years ago)
Author:
Henrik Bettermann
Message:

Implement title_prefix vocabulary. Remove redundant getName method and replace by the longtitle property.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/breadcrumbs.py

    r5864 r5988  
    121121    @property
    122122    def title(self):
    123         prefix = self.context.title_prefix
    124         prefix = prefix[0].upper() + prefix[1:]
    125         return '%s of %s' % (prefix, self.context.title)
     123        return self.context.longtitle()
    126124
    127125class DepartmentBreadcrumb(FacultyBreadcrumb):
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r5987 r5988  
    4141    IWAeUPXMLImporter, IWAeUPXMLExporter, IBatchProcessor)
    4242from waeup.sirp.university.catalog import search
    43 from waeup.sirp.utils.helpers import getName
    4443from waeup.sirp.widgets.interfaces import ITableProvider
    4544
     
    905904    grok.name('index')
    906905    pnav = 1
     906
    907907    @property
    908908    def title(self):
    909         return "%s (%s)" % (getName(self.context), self.context.code)
     909        return self.context.longtitle()
    910910
    911911    #def update(self, code=None, edit=None, delete=None):
     
    995995    grok.name('index')
    996996    pnav = 1
     997    #title = 'xxx'
    997998
    998999    @property
    9991000    def title(self):
    1000         return "%s (%s)" % (getName(self.context), self.context.code)
     1001        #import pdb; pdb.set_trace()
     1002        return self.context.longtitle()
    10011003   
    10021004    def update(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultycontainerpage.pt

    r5942 r5988  
    1515    <tr tal:repeat="value context/values">
    1616      <td> <a tal:attributes="href value/__name__"> <span tal:content="value/code">Name</span></a></td>
    17       <td tal:content="value/title">Title</td>
     17      <td tal:content="value/longtitle">Title</td>
    1818    </tr>
    1919  </tbody>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultypage.pt

    r5942 r5988  
    1515    <tr tal:repeat="value context/values">
    1616      <td> <a tal:attributes="href value/__name__"> <span tal:content="value/code">Name</span></a></td>
    17       <td tal:content="value/title">Title</td>
     17      <td tal:content="value/longtitle">Title</td>
    1818      <td class="text-right">
    1919      </td>
  • main/waeup.sirp/trunk/src/waeup/sirp/tables.py

    r5915 r5988  
    66from waeup.sirp.widgets.table import YUITable as Table
    77from waeup.sirp.widgets.table import Col
    8 from waeup.sirp.utils.helpers import getName
    98
    109class CodeAndTitleTableProvider(grok.Adapter):
     
    4241            Col(
    4342                header='Title', sortable=True,
    44                 data = tuple([getName(data[x]) for x in data])),
     43                data = tuple([data[x] for x in data])),
    4544            )
    4645        self.table = Table(self.title, cols=cols)
  • main/waeup.sirp/trunk/src/waeup/sirp/university/department.py

    r5953 r5988  
    66from zope.interface import implementedBy
    77from waeup.sirp.university.interfaces import IDepartment, IDepartmentAdd
     8from waeup.sirp.university.vocabularies import inst_types
    89
    910class Department(grok.Container):
     
    4041        return None
    4142       
     43    def longtitle(self):
     44        return "%s %s (%s)" % (inst_types.getTerm(self.title_prefix).title,
     45                                                  self.title,
     46                                                  self.code)
     47       
    4248
    4349class DepartmentFactory(grok.GlobalUtility):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py

    r5953 r5988  
    77from waeup.sirp.university.interfaces import (
    88    IFaculty, IFacultyAdd, IDepartment)
     9from waeup.sirp.university.vocabularies import inst_types   
    910
    1011class Faculty(grok.Container):
     
    3637            del self[key]
    3738
    38     #def getName(self, key):
    39     #    """Get complete department name.
    40     #    """
    41     #    if key in self.keys():
    42     #        dept = self[key]
    43     #        prefix = dept.title_prefix
    44     #        prefix = prefix[0].upper() + prefix[1:]
    45     #        return '%s of %s' % (prefix, dept.title)
    46 
     39    def longtitle(self):
     40        return "%s %s (%s)" % (inst_types.getTerm(self.title_prefix).title,
     41                                                  self.title,
     42                                                  self.code)
    4743       
    4844class FacultyFactory(grok.GlobalUtility):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/facultycontainer.py

    r5915 r5988  
    2222            del self[key]
    2323
    24     #def getName(self, key):
    25     #    if key in self.keys():
    26     #        fac = self[key]
    27     #        prefix = fac.title_prefix
    28     #        prefix = prefix[0].upper() + prefix[1:]
    29     #        return '%s of %s' % (prefix, fac.title)
    30            
    3124class FacultyContainerFactory(grok.GlobalUtility):
    3225    """A factory for faculty containers.
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r5986 r5988  
    99                                                application_category,
    1010                                                study_mode,
     11                                                inst_types,
    1112                                                CourseSource)                                   
    1213
     
    2829        )
    2930
    30     title_prefix = schema.TextLine(
     31    title_prefix = schema.Choice(
    3132        title = u'Title prefix',
    3233        default = u'faculty',
    33         required = True,
    34         )
     34        vocabulary = inst_types,
     35        required = True,
     36        )
     37       
     38    def longtitle():
     39        """
     40        Returns the long title of a faculty.
     41        """       
    3542       
    3643class IFacultyAdd(IFaculty):
     
    7279        )
    7380
    74     title_prefix = schema.TextLine(
     81    title_prefix = schema.Choice(
    7582        title = u'Title prefix',
     83        vocabulary = inst_types,
    7684        default = u'department',
    7785        required = True,
     
    8088    courses = Attribute("A container for courses.")
    8189    certificates = Attribute("A container for certificates.")
    82 
     90   
     91    def longtitle():
     92        """
     93        Returns the long title of a department.
     94        """
     95       
    8396class IDepartmentAdd(IDepartment):
    8497    """Representation of a university department.
  • main/waeup.sirp/trunk/src/waeup/sirp/university/vocabularies.py

    r5986 r5988  
    1010    from zope.app.catalog.interfaces import ICatalog
    1111from zope.component import getUtility
     12
     13inst_types = SimpleWAeUPVocabulary(
     14             ('Faculty of','faculty'),
     15             ('Department of','department'),
     16             ('School of','school_of'),
     17             ('School for','school_for'),
     18             ('Institute of','institute'),
     19             ('Office for','office'),
     20             ('Centre for','centre'),
     21             ('College','college'),
     22             )
    1223                                   
    1324course_levels = SimpleWAeUPVocabulary(
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py

    r5876 r5988  
    118118            pass
    119119    return html_code
    120 
    121 def getName(context):
    122     """Construct a name out of an object with prefix and title.
    123 
    124     The `context` has to provide `title_prefix` and `title`
    125     attributes.
    126 
    127         >>> from waeup.sirp.utils.helpers import getName
    128         >>> class FakeObject(object):
    129         ...     title_prefix = 'department'
    130         ...     title = 'Strange Things'
    131         >>> getName(FakeObject())
    132         'Department of Strange Things'
    133 
    134     As we can see in the result the `title_prefix` is rendered
    135     uppercase.
    136        
    137     """
    138     prefix = context.title_prefix
    139     prefix = prefix[0].upper() + prefix[1:]
    140     return '%s of %s' % (prefix, context.title)
    141120
    142121class FactoryBase(grok.GlobalUtility):
Note: See TracChangeset for help on using the changeset viewer.