Ignore:
Timestamp:
28 May 2011, 10:56:27 (14 years ago)
Author:
Henrik Bettermann
Message:

Certificate codes must be unique. Check catalog when certificate are added. Flash the place if certificates exist.

To do: The certificate importer must also check for existing cerificate codes.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/university
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/university/catalog.py

    r6208 r6210  
    2828    """
    2929    grok.site(IUniversity)
    30     grok.name('certifcates_catalog')
     30    grok.name('certificates_catalog')
    3131    grok.context(ICertificate)
    3232
    3333    code = grok.index.Field(attribute='code')
    34     title = grok.index.Field(attribute='application_category')
     34    application_category = grok.index.Field(attribute='application_category')
    3535
    3636class CertificateCoursesIndexes(grok.Indexes):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificatecontainer.py

    r5005 r6210  
    55    ICertificateContainer, ICertificate)
    66from zope.component.interfaces import IFactory
     7from zope.catalog.interfaces import ICatalog
     8from zope.component import getUtility
    79from zope.interface import implementedBy
    810
     
    1719            raise TypeError('CertificateContainers contain only '
    1820                            'ICertificate instances')
     21        cat = getUtility(ICatalog, name='certificates_catalog')
     22        results = list(cat.searchResults(code=(certificate.code,certificate.code)))
     23        if results:
     24            dep = results[0].__parent__.__parent__.longtitle()
     25            fac = results[0].__parent__.__parent__.__parent__.longtitle()
     26            return 'Certificate exists in %s / %s.' % (fac,dep)
    1927        self[certificate.code] = certificate
    20         return
     28        return 'Certificate added.'
    2129
    2230    def clear(self):
Note: See TracChangeset for help on using the changeset viewer.