| 1 | ################################################################################## |
|---|
| 2 | # Copyright (C) 2006-2007 Utah State University, All rights reserved. |
|---|
| 3 | # |
|---|
| 4 | # This program is free software; you can redistribute it and/or modify |
|---|
| 5 | # it under the terms of the GNU General Public License as published by |
|---|
| 6 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | # (at your option) any later version. |
|---|
| 8 | # |
|---|
| 9 | # This program is distributed in the hope that it will be useful, |
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | # GNU General Public License for more details. |
|---|
| 13 | # |
|---|
| 14 | # You should have received a copy of the GNU General Public License |
|---|
| 15 | # along with this program; if not, write to the Free Software |
|---|
| 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 | # |
|---|
| 18 | ################################################################################## |
|---|
| 19 | |
|---|
| 20 | __author__ = 'Brent Lambert, David Ray, Jon Thomas' |
|---|
| 21 | __docformat__ = 'restructuredtext' |
|---|
| 22 | __version__ = "$Revision: 1 $"[11:-2] |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | from OFS.SimpleItem import SimpleItem |
|---|
| 26 | from zope.interface import implements |
|---|
| 27 | from interfaces import IECUtility |
|---|
| 28 | from collective.contentlicensing.DublinCoreExtensions.interfaces import ILicensable, ILicense |
|---|
| 29 | from Acquisition import aq_parent |
|---|
| 30 | |
|---|
| 31 | class eduCommonsUtility(SimpleItem): |
|---|
| 32 | """ Content Licensing Utility """ |
|---|
| 33 | |
|---|
| 34 | implements(IECUtility) |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | def FindECParent(self, context): |
|---|
| 38 | """ return titles and ids for the supported licenses. """ |
|---|
| 39 | parent = getattr(context.aq_inner, 'getECParent', None) |
|---|
| 40 | if parent: |
|---|
| 41 | return parent() |
|---|
| 42 | else: |
|---|
| 43 | return context.portal_url |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | def getFullCourseTitle(self, brain): |
|---|
| 47 | """ Returns the Title with Term and ID information """ |
|---|
| 48 | full_title = '' |
|---|
| 49 | |
|---|
| 50 | id = brain.getCourseId |
|---|
| 51 | if id: |
|---|
| 52 | full_title = '%s - ' %id |
|---|
| 53 | full_title += brain.Title |
|---|
| 54 | term = brain.getTerm |
|---|
| 55 | if term: |
|---|
| 56 | full_title += ', %s' %term |
|---|
| 57 | |
|---|
| 58 | return full_title |
|---|
| 59 | |
|---|
| 60 | myECUtil = eduCommonsUtility() |
|---|