## $Id: course.py 7195 2011-11-25 07:34:07Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """Courses. """ import grok from zope.interface import implementedBy from zope.component.interfaces import IFactory from waeup.sirp.university.interfaces import ICourse, ICourseAdd class Course(grok.Model): """A university course. """ grok.implements(ICourse, ICourseAdd) def __init__(self, title=u'Unnamed Course', code=u'NA', credits=0, passmark=40, semester=1, **kw): super(Course, self).__init__(**kw) self.title = title self.code = code self.credits = credits self.passmark = passmark self.semester = semester def longtitle(self): return "%s (%s)" % (self.title,self.code) class CourseFactory(grok.GlobalUtility): """A factory for courses. """ grok.implements(IFactory) grok.name(u'waeup.Course') title = u"Create a new course.", description = u"This factory instantiates new course instances." def __call__(self, *args, **kw): return Course(*args, **kw) def getInterfaces(self): return implementedBy(Course)