def __call__(self): form = self.request.form if form.has_key('form.submitted'): # TODO validation projectname = form.get('projectname', '') company_uid = form.get('company', '') newcompany = form.get('newcompany','') enable = form.get('enable', []) portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) if not (company_uid or newcompany): company_uid = basecamp_org.getOwnerCompany().UID() elif not company_uid: c = basecamp_org.createCompany(newcompany) company_uid = c.UID() if projectname == '': #plone_utils = getUtility(IPloneTool) plone_utils = getToolByName(self.context, 'plone_utils') msg = _(u'Please input project name.') plone_utils.addPortalMessage(msg, 'error') return self.request.response.redirect(self.context.absolute_url()+'/create_project_form') project = self.createProject(projectname, company_uid, enable) return self.request.response.redirect(project.absolute_url()) else: return self.create_project_template()
def __call__(self): form = self.request.form if form.has_key('form.submitted'): # TODO validation projectname = form.get('projectname', '') company_uid = form.get('company', '') newcompany = form.get('newcompany', '') enable = form.get('enable', []) portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) if not (company_uid or newcompany): company_uid = basecamp_org.getOwnerCompany().UID() elif not company_uid: c = basecamp_org.createCompany(newcompany) company_uid = c.UID() if projectname == '': #plone_utils = getUtility(IPloneTool) plone_utils = getToolByName(self.context, 'plone_utils') msg = _(u'Please input project name.') plone_utils.addPortalMessage(msg, 'error') return self.request.response.redirect( self.context.absolute_url() + '/create_project_form') project = self.createProject(projectname, company_uid, enable) return self.request.response.redirect(project.absolute_url()) else: return self.create_project_template()
def site_add_new_company(self, company_name): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) company = basecamp_org.createCompany(company_name) content = self.macroContent( 'context/@@organizationunit_view/macros/company', company_and_people = [company,] ) ksscore = self.getCommandSet('core') ksscore.insertHTMLAsFirstChild('div#company_list', content) return self.render()
def _insert_company(self, company_name): # 内部使用函数,传入company_name参数用于插入一个公司块 portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) company = basecamp_org.getCompany(company_name) company_and_people = [(company, []), ] content = self.macroContent( 'context/@@teamfolder_view/macros/company_element', company_and_people=company_and_people) ksscore = self.getCommandSet('core') selector = ksscore.getParentNodeSelector('div.insert-company-after-stub') ksscore.insertHTMLAfter(selector, content)
def site_add_new_company(self, company_name): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) company = basecamp_org.createCompany(company_name) content = self.macroContent( 'context/@@organizationunit_view/macros/company', company_and_people=[ company, ]) ksscore = self.getCommandSet('core') ksscore.insertHTMLAsFirstChild('div#company_list', content) return self.render()
def createProject(self, title, company_uid, enable): # 以admin的身份创建项目 acl_users = self.context.getPhysicalRoot().acl_users admin = acl_users.getUserById('admin') if not hasattr(admin, 'aq_base'): admin = admin.__of__(acl_users) sm = getSecurityManager() newSecurityManager(None, admin) portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) id = basecamp_org.randomId() while self.context.has_key(id): id = basecamp_org.randomId() _createObjectByType('Project', self.context, id) project = getattr(self.context, id) project.setTitle(title) project.setCompany(company_uid) # notify project creation event notify(ProjectCreatedEvent(project)) # enable project features # for id in ['messages', 'todos', 'milestones',\ # 'writeboards','time','chatroom', 'files']: # exclude = id not in enable # obj = getattr(project.aq_base, id, None) # if obj is not None: # obj.setExcludeFromNav(exclude) project.reindexObject() setSecurityManager(sm) # 让当前用户进入admin组 userid = getToolByName( self.context, 'portal_membership').getAuthenticatedMember().getMemberId() results = getToolByName(self.context, 'portal_catalog').unrestrictedSearchResults( portal_type="Person", getId=userid) if results: person = results[0].getObject() project.teams.projectmanagers.setMembers([person.UID()]) return project
def _insert_company(self, company_name): # 内部使用函数,传入company_name参数用于插入一个公司块 portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) company = basecamp_org.getCompany(company_name) company_and_people = [ (company, []), ] content = self.macroContent( 'context/@@teamfolder_view/macros/company_element', company_and_people=company_and_people) ksscore = self.getCommandSet('core') selector = ksscore.getParentNodeSelector( 'div.insert-company-after-stub') ksscore.insertHTMLAfter(selector, content)
def createProject(self, title, company_uid, enable): # 以admin的身份创建项目 acl_users = self.context.getPhysicalRoot().acl_users admin = acl_users.getUserById('admin') if not hasattr(admin, 'aq_base'): admin = admin.__of__(acl_users) sm = getSecurityManager() newSecurityManager(None, admin) portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) id = basecamp_org.randomId() while self.context.has_key(id): id = basecamp_org.randomId() _createObjectByType('Project', self.context, id) project = getattr(self.context, id) project.setTitle(title) project.setCompany(company_uid) # notify project creation event notify(ProjectCreatedEvent(project)) # enable project features # for id in ['messages', 'todos', 'milestones',\ # 'writeboards','time','chatroom', 'files']: # exclude = id not in enable # obj = getattr(project.aq_base, id, None) # if obj is not None: # obj.setExcludeFromNav(exclude) project.reindexObject() setSecurityManager(sm) # 让当前用户进入admin组 userid = getToolByName(self.context, 'portal_membership').getAuthenticatedMember().getMemberId() results = getToolByName(self.context, 'portal_catalog').unrestrictedSearchResults(portal_type="Person", getId=userid) if results: person = results[0].getObject() project.teams.projectmanagers.setMembers([person.UID()]) return project
def add_new_company(self, company_name): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) c = basecamp_org.createCompany(company_name) core = self.getCommandSet('core') ksszopen = self.getCommandSet('zopen') ksszopen.clear(core.getSelector('css', '.add-new-company-name')) self._insert_company(c.getId()) selector = core.getSelector('css', '.selectCompanyArea') content = "<select name=\"select-add-company-name\" class=\"selectCompanyArea\">" for c in self.get_available_companies(): content += "<option value='" + c.getId() +"'>" + \ c.pretty_title_or_id() + "</option>" content += "</select>" content = force_unicode(content, 'utf-8') core.replaceHTML(selector, content)
def add_new_company(self, company_name): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) c = basecamp_org.createCompany(company_name) core = self.getCommandSet('core') ksszopen=self.getCommandSet('zopen') ksszopen.clear(core.getSelector('css', '.add-new-company-name')) self._insert_company(c.getId()) selector = core.getSelector('css', '.selectCompanyArea') content = "<select name=\"select-add-company-name\" class=\"selectCompanyArea\">" for c in self.get_available_companies(): content += "<option value='" + c.getId() +"'>" + \ c.pretty_title_or_id() + "</option>" content += "</select>" content = force_unicode(content, 'utf-8') core.replaceHTML(selector, content)
def get_team_of_person(self, person): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) return basecamp_org.get_team_of_person(person)
def getAvailableTeams(self): portal = getToolByName(self.context, 'portal_url').getPortalObject() basecamp_org = IOrgInstance(portal) return basecamp_org.getAvailableTeams()