Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from plone.app.textfield import RichText
- from plone.autoform import directives
- from plone.dexterity.content import Container
- from plone.namedfile import field as namedfile
- from plone.supermodel import model
- from plone.supermodel.directives import fieldset
- from z3c.form.browser.radio import RadioFieldWidget
- from zope import schema
- from zope.interface import implementer
- from yc.courseschedule import _
- from AccessControl import ClassSecurityInfo
- from plone import api
- # needed for vocabulary in Choice
- from z3c.form.browser.radio import RadioFieldWidget
- from zope.schema.vocabulary import SimpleVocabulary
- from zope.schema.vocabulary import SimpleTerm
- sessionVocabulary = SimpleVocabulary(
- [SimpleTerm(value=u'F', title=_(u'Fall')),
- SimpleTerm(value=u'S', title=_(u'Spring')),
- SimpleTerm(value=u'4w1', title=_(u'4 weeks summer session 1')),
- SimpleTerm(value=u'4w2', title=_(u'4 weeks summer session 2')),
- SimpleTerm(value=u'7w1', title=_(u'7 weeks summer session 1')),
- SimpleTerm(value=u'7w2', title=_(u'7 weeks summer session 2')),
- SimpleTerm(value=u'Win', title=_(u'Winter'))]
- )
- class ICsDepartment(model.Schema):
- """ Marker interface and Dexterity Python Schema for CsDepartment
- """
- directives.read_permission(school='cmf.ManagePortal')
- directives.write_permission(school='cmf.ManagePortal')
- school = schema.TextLine(
- title=_(u'School'),
- )
- directives.read_permission(croACAD_ORG='cmf.ManagePortal')
- directives.write_permission(croACAD_ORG='cmf.ManagePortal')
- croACAD_ORG = schema.TextLine(
- title=_(u'Academic Organization'),
- description=_(u'eg. EARTH-YRK'),
- )
- directives.read_permission(cssSTRM='cmf.ManagePortal')
- directives.write_permission(cssSTRM='cmf.ManagePortal')
- cssSTRM = schema.TextLine(
- title=_(u'Semester Code'),
- description=_(u'eg. 1189, 1186, 1182'),
- )
- directives.read_permission(cssSession='cmf.ManagePortal')
- directives.write_permission(cssSession='cmf.ManagePortal')
- directives.widget(cssSession=RadioFieldWidget)
- cssSession = schema.Choice(
- title=_(u'Session'),
- vocabulary=sessionVocabulary,
- required=True
- )
- @implementer(ICsDepartment)
- class CsDepartment(Container):
- # Create Title based on Fields
- def setTitle(self,value,**kwargs):
- self.title = self.computeFullname()
- def Title(self):
- return self.computeFullname()
- def computeFullname(self):
- return str(self.croACAD_ORG.split('-', 1)[0]) + ' - ' + str(self.cssSTRM) + ' - ' + str(self.cssSession)
- # Create Description based on Fields
- def setDescription(self,value,**kwargs):
- self.description = self.computeDescription()
- def Description(self):
- return self.computeDescription()
- def computeDescription(self):
- return str(self.school) + ', ' + str(self.croACAD_ORG) + ' ( '+ str(self.cssSTRM) + ' - ' + str(self.cssSession) + ' )'
- # permissions
- def setManagers(self,value,**kwargs):
- deptGroup = 'cs-'+ str(self.croACAD_ORG) + '-grp'
- # self.manage_setLocalRoles('deptGroup', ['Contributor','Reader'])
- api.group.grant_roles(groupname='deptGroup',roles=['Contributor', 'Editor'], obj=self)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement