Ignore:
Timestamp:
30 May 2011, 07:41:18 (14 years ago)
Author:
Henrik Bettermann
Message:

Use and raise DuplicationError? for Courses too.

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

Legend:

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

    r6229 r6245  
    337337  >>> print browser.contents
    338338  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    339   ...<li class="message">Course exists already in...</li>
     339  ...<li class="message">A course with same code already exists:...</li>
    340340  ...
    341341
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6243 r6245  
    12921292        course = createObject(u'waeup.Course')
    12931293        self.applyData(course, **data)
    1294         message = self.context.courses.addCourse(course)
     1294        try:
     1295            self.context.courses.addCourse(course)
     1296        except DuplicationError, error:
     1297            # signals duplication error
     1298            entries = error.entries
     1299            for entry in entries:
     1300                # do not use error.msg but render a more detailed message instead
     1301                # and show links to all certs with same code
     1302                message = 'A course with same code already exists: '
     1303                message += '<a href="%s">%s</a>' % (
     1304                    self.url(entry), getattr(entry, '__name__', u'Unnamed'))
     1305                self.flash(message)
     1306            self.redirect(self.url(self.context, u'@@addcourse'))
     1307            return
     1308        message = u'Course %s successfully created.' % (course.code)
    12951309        self.flash(message)
    12961310        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
Note: See TracChangeset for help on using the changeset viewer.