class TransferJob(base.ATCTContent): """Content type for a Transfer Position""" implements(ITransferJob) meta_type = "TransferJob" schema = TransferJobSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- positiondescription = atapi.ATFieldProperty('positiondescription') postdate = atapi.ATFieldProperty('postdate') department = atapi.ATFieldProperty('department') schedule = atapi.ATFieldProperty('schedule') qualifications = atapi.ATFieldProperty('qualifications') payrange = atapi.ATFieldProperty('payrange') deadline = atapi.ATFieldProperty('deadline') howtoapply = atapi.ATFieldProperty('howtoapply')
class NavigationPage(atapi.BaseFolder): """A page composed of content selected manually.""" # Add INonStructuralFolder to tell Plone that even though # this type is technically a folder, it should be treated as a standard # content type. This ensures the user doesn't perceive a Navigation Page # as a folder. implements((INavigationPage, INonStructuralFolder)) security = ClassSecurityInfo() portal_type = 'Navigation Page' schema = schema _at_rename_after_creation = True title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # monkeypatched actions? actions = packcomposite.actions def SearchableText(self): """Return text for indexing""" # Want title, description, and all Title and fragment content. # Fragments are converted from HTML to plain text. texts = [self.Title(), self.Description()] if getattr(aq_base(self.cp_container), 'titles', None) is not None: titles = self.cp_container.titles.objectValues() for o in titles: if hasattr(o, 'ContainerSearchableText'): texts.append(o.ContainerSearchableText()) return " ".join(texts)
class GroupLocation(base.ATCTContent): """ @author: David Hietpas @version: 1.1 """ implements(IGroupLocation) meta_type = "GroupLocation" schema = GroupLocationSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') def groupLocation(self): """ Used for one-stop cataloging. - To translate, use util.translate_GroupLocation(arg) """ return tuple([ self.getBuilding(), self.getExtraNotes(), self.getKeyRequired(), self.getMaxGroups(), self.getCapacity(), self.getRoomContents(), self.getDirections(), self.getDirectionsFull() ]) def getDirectionsFull(self): return self.getField('directions_full').get(self)
class PFGCorrectAnswersAdapter(FormActionAdapter): """Calculate the percentage of correct answers.""" implements(IPFGCorrectAnswersAdapter) meta_type = "PFGCorrectAnswersAdapter" schema = PFGCorrectAnswersAdapterSchema security = ClassSecurityInfo() title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') security.declareProtected(View, 'onSuccess') def onSuccess(self, fields, REQUEST=None): """The essential method of a PloneFormGen Adapter.""" max_points = 0 points = 0 # iterate through FormSelectionFields and count correct answers for field in fields: if field.portal_type != 'FormSelectionField': continue max_points += 1 if (REQUEST.form.get(field.id) and field.correct_answer.strip() == REQUEST.form[field.id]): points += 1 if max_points > 0: result = round(float(points) / float(max_points) * 100) api.portal.show_message(request=REQUEST, type='info', message="Your score is: %i%%" % result)
class WebServiceClient(document.ATCTContent): """Viewing of a web service result""" implements(IWebServiceClient) meta_type = "WebServiceClient" schema = WebServiceClientSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- security = ClassSecurityInfo() # Web service result _v_result = '' security.declarePrivate('_call_service') def _call_service(self): try: client = Client(self.getService_url()) s = getattr(client.service, self.getService_name()) except: return pars = [] for p in self.getService_pars(): pars.append(eval(p, {"__builtins__": None}, {'self': self})) self._v_result = s(*pars) security.declarePrivate('getResult') def getResult(self): return self._v_result
class Vinheta(base.ATCTContent): """ """ implements(IVinheta) meta_type = "Vinheta" schema = VinhetaSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- video = atapi.ATFieldProperty('video') def getAutomator(self): novoProjeto = DateTime().strftime( "%Y%m%d%H%M%S") + '_' + self.meta_type aux = 'var ext_cliente = "origine";\n' aux = aux + 'var ext_novoProjeto = "%s";\n' % novoProjeto aux = aux + 'var ext_telas = [{\n' aux = aux + 'name: "vinheta",\n' aux = aux + 'texto: "%s",\n' % self.Title() aux = aux + 'video: "%s",\n' % self.getVideo() aux = aux + '}]; \n' return aux
class Step(folder.ATFolder): """A contenttype named step for managing processes.""" implements(IStep) meta_type = "Step" schema = StepSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description')
class FormToPDFAdapter(FormActionAdapter): """Description of the Example Type""" implements(IFormToPDFAdapter) portal_type = meta_type = "FormToPDFAdapter" schema = FormToPDFAdapterSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') security = ClassSecurityInfo() security.declarePrivate('getPDFBodyDefault') def getPDFBodyDefault(self): # noqa """ Get default pdf template """ return '' security.declarePrivate('onSuccess') def onSuccess(self, fields, REQUEST=None): # noqa """ redirect to pdf download view """ request = REQUEST or self.REQUEST data = {} for k, v in request.form.iteritems(): data[k] = v request.set('pdf_data', data) request.set('pdf_adapter_path', self.absolute_url_path()) request.set('pdf_adapter_url', self.absolute_url()) request.set('download_timeout', self.getField('download_timeout').get(self))
class Issue(folder.ATFolder): """An issue of a journal""" implements(IIssue) meta_type = "Issue" schema = IssueSchema # title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- volume = atapi.ATFieldProperty('volume') number = atapi.ATFieldProperty('number') date = atapi.ATFieldProperty('date') def _compute_title(self): """Compute title from vol and number""" title = [] # TODO: let user configure this if (self.volume is not None) and len(self.volume) > 0: title.append("Volume %s" % self.volume) if (self.number is not None) and len(self.number) > 0: title.append("Number %s" % self.number) title.append("%s" % self.date) return ', '.join(title)
class Servico(base.ATCTContent): """Description of the Example Type""" implements(IServico) meta_type = "Servico" schema = ServicoSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') def getDataMinima(self): """ """ now = datetime.datetime.now() delta = datetime.timedelta(hours=2) DT = dt2DT(now+delta) return DT def getListaInfografistas(self): """ Retorna a lista de membros presentes no grupo """ pg = getToolByName(self, 'portal_groups') group = pg.getGroupById('infografistas') members = group.getGroupMembers() list = DisplayList() for member in members: memberId = member.getMemberId() fullname = member.getProperty('fullname', memberId) list.add(memberId, fullname) return list
class CollaborationsFolder(folder.ATFolder): '''A folder for Collaborative Groups''' implements(ICollaborationsFolder) schema = CollaborationsFolderSchema portal_type = 'Collaborations Folder' description = atapi.ATFieldProperty('description') title = atapi.ATFieldProperty('title')
class ElementalBiomarker(Biomarker): '''Elemental biomarker.''' implements(IElementalBiomarker) schema = ElementalBiomarkerSchema portal_type = 'Elemental Biomarker' biomarkerType = atapi.ATFieldProperty('biomarkerType') qaState = atapi.ATFieldProperty('qaState')
class Person(base.ATCTContent): implements(IPerson) portal_type = 'Person' schema = PersonSchema title = atapi.ATFieldProperty('title') email = atapi.ATFieldProperty('email') phone = atapi.ATFieldProperty('phone') department = atapi.ATFieldProperty('department') classification = atapi.ATFieldProperty('classification') def getReviewState(self): portal_workflow = getToolByName(self, 'portal_workflow') return portal_workflow.getInfoFor(self, 'review_state') def getReviewStateTitle(self): reviewState = self.getReviewState() return self.portal_workflow.getTitleForStateOnType( reviewState, 'Person') def getExtraInfo(self): extraInfo = [] if self.phone != '': extraInfo.append('Phone: ' + self.phone) if self.classification != '': extraInfo.append('Class: ' + self.classification) if self.department != '': extraInfo.append('Dept: ' + self.department) return ', '.join(extraInfo)
class Coluna(base.ATCTContent): """ """ implements(IColuna) meta_type = "Coluna" schema = ColunaSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- foto = atapi.ATFieldProperty('foto') autor = atapi.ATFieldProperty('autor') def getAutomator(self): novoProjeto = DateTime().strftime("%Y%m%d%H%M%S") + '_' + self.meta_type aux = 'var ext_cliente = "origine";\n' aux = aux + 'var ext_novoProjeto = "%s";\n' % novoProjeto aux = aux + 'var ext_telas = [{\n' aux = aux + 'name: "coluna",\n' aux = aux + 'tempo: 15,\n' aux = aux + 'titulo: "%s",\n' % self.Title() aux = aux + 'autor: "%s",\n' % self.getAutor() aux = aux + 'foto: "%s",\n' % self.getFoto() aux = aux + '}]; \n' return aux
class templateproject(folder.ATFolder): """A template project for LibreOffice""" implements(Itemplateproject) meta_type = "templateproject" schema = templateprojectSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- security = ClassSecurityInfo() security.declareProtected(permissions.View, 'getCategoriesVocab') def getCategoriesVocab(self): """Get categories vocabulary from parent project area via acquisition. """ return self.getAvailableCategoriesAsDisplayList() security.declareProtected(permissions.View, 'getSelfCertificationCriteriaVocab') def getSelfCertificationCriteriaVocab(self): """Get self-certification criteria vocabulary from parent project area via acquisition. """ return self.getAvailableSelfCertificationCriteriaAsDisplayList()
class RoleRequest(base.ATCTContent): """Description of the Example Type""" implements(IRoleRequest) meta_type = "RoleRequest" schema = RoleRequestSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') def getSelectableUsers(self): return [(str(user.getId()), "%s (%s)" % (user.getProperty('fullname'), user.getProperty('email'))) for user in plone.api.user.get_users()] def getSelectableUsersDefault(self): current_user = plone.api.user.get_current() return str(current_user.getId()) def getSelectableRoles(self): disfavoured_roles = {'Anonymous', 'Authenticated', 'Contributor', 'Editor', 'Manager', 'Member', 'Reader', 'Site Administrator'} all_roles = set(self.valid_roles()) return ['Select...'] + list(all_roles - disfavoured_roles) def validate_role(self, value): return 'Select a role!' if value == 'Select...' else None
class Marcacao(base.ATCTContent): """''""" implements(IMarcacao) meta_type = "Marcação" schema = MarcacaoSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description') # -*- Your ATSchema to Python Property Bridges Here ... -*- def getListaReporteres(self): """ Retorna a lista de membros presentes no grupo """ pg = getToolByName(self, 'portal_groups') group = pg.getGroupById('Reporteres') members = group.getGroupMembers() list = [] for member in members: memberId = member.getMemberId() fullname = member.getProperty('fullname', memberId) list.append((memberId, fullname)) return DisplayList(list) def getListaCinegrafistas(self): """ Retorna a lista de membros presentes no grupo """ pg = getToolByName(self, 'portal_groups') group = pg.getGroupById('Cinegrafistas') members = group.getGroupMembers() list = [] for member in members: memberId = member.getMemberId() fullname = member.getProperty('fullname', memberId) list.append((memberId, fullname)) return DisplayList(list) def getReporteresString(self): """ Retorna os reporteres selecionados em uma string """ string = '' selecionados = self.getReporter() listacompleta = self.getListaReporteres() for selecionado in selecionados: string = string + listacompleta.getValue(selecionado) + ', ' return string def getCinegrafistasString(self): """ Retorna os reporteres selecionados em uma string """ string = '' selecionados = self.getCinegrafista() listacompleta = self.getListaCinegrafistas() for selecionado in selecionados: string = string + listacompleta.getValue(selecionado) + ', ' return string
class FundingFolder(folder.ATFolder): '''Funding folder which contains funding opportunities.''' implements(IFundingFolder) portal_type = 'Funding Folder' _at_rename_after_creation = True schema = FundingFolderSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description')
class EDRNHome(document.ATDocument): '''EDRN Home.''' implements(IEDRNHome) portal_type = 'EDRN Home' _at_rename_after_creation = True schema = EDRNHomeSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description')
class RDFFolder(folder.ATFolder): '''RDF Folder.''' implements(IRDFFolder) portal_type = 'RDF Folder' _at_rename_after_creation = True schema = RDFFolderSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description')
class BodySystem(base.Source): '''Body system.''' implements(IBodySystem) portal_type = 'Body System' _at_rename_after_creation = True schema = BodySystemSchema titleURI = atapi.ATFieldProperty('titleURI') descURI = atapi.ATFieldProperty('descURI')
class InternshipFolder(folder.ATBTreeFolder): implements(interfaces.IInternshipFolder,) portal_type = 'InternshipFolder' schema = InternshipFolderSchema title = atapi.ATFieldProperty('title') description = atapi.ATFieldProperty('description')