def test_check_permissions_fails_with_nobody(self, browser): self.login(self.regular_user) url = ResolveOGUIDView.url_for( Oguid.for_object(self.task), get_current_admin_unit()) with browser.expect_unauthorized(): browser.open(url)
def dispatch_request(target_admin_unit_id, viewname, path='', data={}, headers={}): """ Sends a request to another zope instance Returns a response stream Authentication: In the request there is a attribute '__cortex_ac' which is set to the username of the current user. :target_admin_unit_id: id of the target AdminUnit :viewname: name of the view to call on the target :path: context path relative to site root :data: dict of additional data to send :headers: dict of additional headers to send """ if isinstance(viewname, unicode): viewname = viewname.encode('utf-8') if isinstance(path, unicode): path = path.encode('utf-8') if get_current_admin_unit().id() == target_admin_unit_id: return _local_request(viewname, path, data) else: return _remote_request(target_admin_unit_id, viewname, path, data, headers)
def base_query(self): admin_unit = get_current_admin_unit() return create_session().query(User) \ .filter(User.userid == groups_users.columns.userid) \ .filter(groups_users.columns.groupid == OrgUnit.users_group_id) \ .filter(OrgUnit.admin_unit_id == admin_unit.unit_id) \ .filter(OrgUnit.enabled == True) # noqa
def migrate(self): admin_unit_id = get_current_admin_unit().id() intids = getUtility(IIntIds) for proposal in self.objects( {'portal_type': 'opengever.meeting.proposal'}, 'Sync proposal title to SQL index'): intid = intids.getId(proposal) self.execute( proposals_table.update() .values(title=proposal.title) .where( proposals_table.c.admin_unit_id == admin_unit_id) .where( proposals_table.c.int_id == intid) ) for submitted_proposal in self.objects( {'portal_type': 'opengever.meeting.submittedproposal'}, 'Sync submitted proposal title to SQL index'): intid = intids.getId(submitted_proposal) self.execute( proposals_table.update() .values(submitted_title=submitted_proposal.title) .where( proposals_table.c.submitted_admin_unit_id == admin_unit_id) .where( proposals_table.c.submitted_int_id == intid) )
def setUp(self): super(TestAllUsersInboxesAndTeamsSourceForWorkspace, self).setUp() self.login(self.administrator) self.org_unit2 = create( Builder('org_unit').id('unit2').having( title=u'Finanzdirektion', admin_unit=get_current_admin_unit()).with_default_groups()) self.john = create( Builder('ogds_user').id('john').having( firstname=u'John', lastname=u'Doe').assign_to_org_units([get_current_org_unit()])) self.hugo = create( Builder('ogds_user').id('hugo').having( firstname=u'Hugo', lastname=u'Boss').assign_to_org_units([get_current_org_unit() ])) self.hans = create( Builder('ogds_user').id('hans').having( firstname=u'Hans', lastname=u'Peter').assign_to_org_units( [get_current_org_unit(), self.org_unit2])) self.reto = create( Builder('ogds_user').id('reto').having( firstname=u'Reto', lastname=u'Rageto').assign_to_org_units([self.org_unit2]))
def has_active_proposals(self): """Check if there are proposals inside the dossier, which are not in an end state. """ query = Proposal.query.active().by_container( self, get_current_admin_unit()) return bool(query.count())
def create_successor_task(self, dossier): # we need all task field values from the forwarding fielddata = {} for fieldname in ITask.names(): value = ITask.get(fieldname).get(self.context) fielddata[fieldname] = value # Reset issuer to the current inbox fielddata['issuer'] = get_current_org_unit().inbox().id() # Predefine the task_type to avoid tasks with an invalid task_type fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE # lets create a new task - the successor task task = createContentInContainer( dossier, 'opengever.task.task', **fielddata) # Add issuer and responsible to the watchers of the newly created task center = notification_center() center.add_task_responsible(task, task.responsible) center.add_task_issuer(task, task.issuer) # copy documents and map the intids intids_mapping = _copy_documents_from_forwarding(self.context, task) # copy the responses response_transporter = IResponseTransporter(task) response_transporter.get_responses( get_current_admin_unit().id(), '/'.join(self.context.getPhysicalPath()), intids_mapping=intids_mapping) return task
def client_voc_cachekey(method, self): """A cache key depending on the vocabulary name and the current client id. """ return '%s:%s:%s' % ( getattr(self, 'grokcore.component.directive.name'), get_current_admin_unit().id(), getUtility(ISyncStamp).get_sync_stamp())
def summary(self): actor = Actor.lookup(self.context.Creator()) msg = _('summary_disposition_added', u'New disposition added by ${user} on admin unit ${admin_unit}', mapping={'user': actor.get_label(with_principal=False), 'admin_unit': get_current_admin_unit().label()}) return self.translate_to_all_languages(msg)
def migrate(self): has_meeting_feature = api.portal.get_registry_record('opengever.meeting.interfaces.IMeetingSettings.is_feature_enabled') # noqa if not has_meeting_feature: return admin_unit_id = get_current_admin_unit().id() excerpts = self.execute( generateddocuments_table.select() .where(generateddocuments_table.c.admin_unit_id == admin_unit_id) .where(generateddocuments_table.c.generated_document_type == 'generated_excerpt') ).fetchall() if not excerpts: return intid_util = getUtility(IIntIds) dossiers = set( excerpt.get_parent_dossier() for excerpt in (intid_util.queryObject(excerpt.int_id) for excerpt in excerpts if excerpt.int_id) if excerpt ) journal_fixer = JournalMessageFixer(keys_to_fix=['title']) for dossier in dossiers: journal_fixer.fix_entries(dossier)
def _remote_request(target_admin_unit_id, viewname, path, data, headers): site = getSite() target_unit = ogds_service().fetch_admin_unit(target_admin_unit_id) if not target_unit: raise ClientNotFound() headers = headers.copy() data = data.copy() mtool = getToolByName(site, "portal_membership") member = mtool.getAuthenticatedMember() key = "X-OGDS-AC" if key not in headers.keys() and member: headers[key] = member.getId() headers["X-OGDS-AUID"] = get_current_admin_unit().id() handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(handler) viewname = viewname if viewname.startswith("@@") else "@@{}".format(viewname) if path: url = os.path.join(target_unit.site_url, path, viewname) else: url = os.path.join(target_unit.site_url, viewname) request = urllib2.Request(url, urllib.urlencode(data), headers) return opener.open(request)
def __call__(self): tasks = get_selected_items(self.context, self.request) tasks = [tt for tt in tasks] if not tasks: msg = _( u'error_no_items', default=u'You have not selected any items.') IStatusMessage(self.request).addStatusMessage(msg, type='error') if self.request.get('orig_template'): return self.request.RESPONSE.redirect( self.request.form['orig_template']) else: return self.request.RESPONSE.redirect( self.context.absolute_url()) reporter = XLSReporter( self.context.REQUEST, self.columns(), tasks, sheet_title=translate( _('label_tasks', default=u'Tasks'), context=self.request), footer='%s %s' % ( datetime.now().strftime('%d.%m.%Y %H:%M'), get_current_admin_unit().id()) ) return self.return_excel(reporter)
def migrate(self): has_meeting_feature = api.portal.get_registry_record( 'opengever.meeting.interfaces.IMeetingSettings.is_feature_enabled' ) # noqa if not has_meeting_feature: return admin_unit_id = get_current_admin_unit().id() excerpts = self.execute(generateddocuments_table.select().where( generateddocuments_table.c.admin_unit_id == admin_unit_id).where( generateddocuments_table.c.generated_document_type == 'generated_excerpt')).fetchall() if not excerpts: return intid_util = getUtility(IIntIds) dossiers = set(excerpt.get_parent_dossier() for excerpt in (intid_util.queryObject(excerpt.int_id) for excerpt in excerpts if excerpt.int_id) if excerpt) journal_fixer = JournalMessageFixer(keys_to_fix=['title']) for dossier in dossiers: journal_fixer.fix_entries(dossier)
def test_sql_task_is_updated_on_plone_object_update(self): self.task.responsible_client = 'asd' self.task.title = u'Gopf, iz mach mau' notify(ObjectModifiedEvent(self.task)) self.assertEqual(1, Session.query(Task).count()) task = Session.query(Task).one() self.assertEqual('asd', task.assigned_org_unit) self.assertEqual(u'dossier > subdossier > Gopf, iz mach mau', task.breadcrumb_title) self.assertEqual(u'Gopf, iz mach mau', task.title) self.assertEqual(get_current_org_unit().id(), task.issuing_org_unit) self.assertEqual(get_current_admin_unit().id(), task.admin_unit_id) self.assertEqual(self.user.userid, task.issuer) self.assertEqual(self.user.userid, task.responsible) self.assertEqual(u'task-state-open', task.review_state) self.assertEqual(u'dossier-1/dossier-2/task-1', task.physical_path) self.assertIsNotNone(task.icon) self.assertEqual(task.deadline, date(2010, 1, 1)) self.assertIsNotNone(task.modified) self.assertEqual('direct-execution', task.task_type) self.assertFalse(task.is_subtask) self.assertEqual(1, task.sequence_number) self.assertEqual('Client1 / 1.1', task.reference_number) self.assertEqual('dossier', task.containing_dossier) self.assertEqual('subdossier', task.containing_subdossier) self.assertEqual(2, task.dossier_sequence_number) self.assertEqual('Lorem ipsum dolor sit amet, consectetur', task.text) self.assertSequenceEqual([TEST_USER_ID], task.principals) self.assertIsNone(task.predecessor)
def get_css_class(self): """Returns css_class for the special task icons: - Forwarding - Regular Task - Subtask - Remotetask """ if self.is_forwarding: css_class = 'contenttype-opengever-inbox-forwarding' elif self.is_subtask and self.is_remote_task: if self.admin_unit_id == get_current_admin_unit().id(): css_class = 'icon-task-subtask' else: css_class = 'icon-task-remote-task' elif self.is_subtask: css_class = 'icon-task-subtask' elif self.is_remote_task: css_class = 'icon-task-remote-task' else: css_class = 'contenttype-opengever-task-task' return css_class
def test_check_permissions_fails_with_nobody(self, browser): self.login(self.regular_user) url = ResolveOGUIDView.url_for(Oguid.for_object(self.task), get_current_admin_unit()) with browser.expect_unauthorized(): browser.open(url)
def send_digests(self): logger.info('Sending digests...') for userid, notifications in self.get_notifications().items(): # skip when digest interval is not expired yet if not self.is_interval_expired(userid): continue today = api.portal.get_localized_time(date.today()) user = ogds_service().fetch_user(userid) subject = translate( _(u'subject_digest', default=u'Daily Digest for ${date}', mapping={'date': today}), context=self.request) title = translate( _(u'title_daily_digest', default=u'Daily Digest for ${username}', mapping={'username': user.fullname()}), context=self.request) msg = self.prepare_mail( subject=subject, to_userid=userid, data={'notifications': self.prepare_data(notifications), 'public_url': get_current_admin_unit().public_url, 'title': title, 'today': today}) self.send_mail(msg) self.mark_as_sent(notifications) self.record_digest(userid) logger.info(' Digest sent for %s (%s)' % (userid, user.email)) logger.info('Done sending digests.')
def has_active_proposals(self): """Check if there are proposals inside the dossier, which are not in an end state. """ query = Proposal.query.active().by_container(self, get_current_admin_unit()) return bool(query.count())
def dispatch_request(target_admin_unit_id, viewname, path='', data={}, headers={}): """ Sends a request to another zope instance Returns a response stream Authentication: In the request there is a attribute '__cortex_ac' which is set to the username of the current user. :target_admin_unit_id: id of the target AdminUnit :viewname: name of the view to call on the target :path: context path relative to site root :data: dict of additional data to send :headers: dict of additional headers to send """ if isinstance(viewname, unicode): viewname = viewname.encode('utf-8') if isinstance(path, unicode): path = path.encode('utf-8') if get_current_admin_unit().id() == target_admin_unit_id: return _local_request(viewname, path, data) else: return _remote_request(target_admin_unit_id, viewname, path, data, headers)
def setUp(self): super(TestAllUsersInboxesAndTeamsSourceForWorkspace, self).setUp() self.login(self.administrator) self.org_unit2 = create(Builder('org_unit') .id('unit2') .having(title=u'Finanzdirektion', admin_unit=get_current_admin_unit()) .with_default_groups()) self.john = create(Builder('ogds_user') .id('john') .having(firstname=u'John', lastname=u'Doe') .assign_to_org_units([get_current_org_unit()])) self.hugo = create(Builder('ogds_user') .id('hugo') .having(firstname=u'Hugo', lastname=u'Boss') .assign_to_org_units([get_current_org_unit()])) self.hans = create(Builder('ogds_user') .id('hans') .having(firstname=u'Hans', lastname=u'Peter') .assign_to_org_units([get_current_org_unit(), self.org_unit2])) self.reto = create(Builder('ogds_user') .id('reto') .having(firstname=u'Reto', lastname=u'Rageto') .assign_to_org_units([self.org_unit2]))
def tasks(self): if not self.context.has_task_support(): return [] return Task.query.by_container(self.context, get_current_admin_unit())\ .in_pending_state()\ .order_by(desc('modified')).limit(5).all()
def get_css_class(self): """Returns css_class for the special task icons: - Forwarding - Regular Task - Subtask - Remotetask """ if self.is_forwarding: css_class = 'contenttype-opengever-inbox-forwarding' elif self.is_subtask and self.is_remote_task: if self.admin_unit_id == get_current_admin_unit().id(): css_class = 'contenttype-opengever-task-sub-task' else: css_class = 'contenttype-opengever-task-remote-task' elif self.is_subtask: css_class = 'contenttype-opengever-task-sub-task' elif self.is_remote_task: css_class = 'contenttype-opengever-task-remote-task' else: css_class = 'contenttype-opengever-task-task' return css_class
def search_query(self): admin_unit = get_current_admin_unit() return create_session().query(User) \ .filter(User.userid == groups_users.columns.userid) \ .filter(groups_users.columns.groupid == OrgUnit.users_group_id) \ .filter(OrgUnit.admin_unit_id == admin_unit.unit_id) \ .filter(OrgUnit.enabled == True) # noqa
def setUp(self): super(TestHoldMeeting, self).setUp() self.repository_root = create(Builder('repository_root')) self.repository = create( Builder('repository').within(self.repository_root)) self.dossier = create(Builder('dossier').within(self.repository)) self.meeting_dossier = create( Builder('meeting_dossier').within(self.repository)) self.sablon_template = create( Builder('sablontemplate').with_asset_file('excerpt_template.docx')) container = create( Builder('committee_container').having( excerpt_template=self.sablon_template, protocol_template=self.sablon_template)) self.committee = create(Builder('committee').within(container)) self.proposal_a = create( Builder('proposal').titled(u'Proposal A').within( self.dossier).as_submitted().having( committee=self.committee.load_model())) self.proposal_b = create( Builder('proposal').titled(u'Proposal B').within( self.dossier).as_submitted().having( committee=self.committee.load_model())) self.meeting = create( Builder('meeting').having( committee=self.committee.load_model()).scheduled_proposals( [self.proposal_a, self.proposal_b]).link_with(self.meeting_dossier)) # set correct public url, used for generated meeting urls get_current_admin_unit().public_url = self.portal.absolute_url() transaction.commit()
def tasks(self): if not self.context.has_task_support(): return [] return Task.query.by_container(self.context, get_current_admin_unit())\ .in_pending_state()\ .order_by(desc('modified')).limit(5).all()
def get_transferring_office(self): """Returns the current adminunits label, followed by the current users fullname. """ # TODO: should use the fullname of the dispositiion creator rather # than current users fullname return '{}, {}'.format(get_current_admin_unit().label(), api.user.get_current().title_or_id())
def test_is_equal_to_public_url_for_single_admin_unit_setup(self): admin_unit = get_current_admin_unit() # For setups with a single admin units, the admin unit's ID is # usually omitted from the public_url admin_unit.public_url = 'http://lab.onegovgever.ch' # In this case, the cluster base URL is equivalent to public_url self.assertEquals('http://lab.onegovgever.ch/', get_cluster_base_url())
def sync_model(self, proposal_model=None): proposal_model = proposal_model or self.load_model() proposal_model.submitted_oguid = Oguid.for_object(self) proposal_model.submitted_physical_path = self.get_physical_path() proposal_model.submitted_admin_unit_id = get_current_admin_unit().id() proposal_model.submitted_title = self.title proposal_model.date_of_submission = self.date_of_submission
def sync_model(self, proposal_model=None): proposal_model = proposal_model or self.load_model() proposal_model.submitted_oguid = Oguid.for_object(self) proposal_model.submitted_physical_path = self.get_physical_path() proposal_model.submitted_admin_unit_id = get_current_admin_unit().id() proposal_model.submitted_title = self.title proposal_model.date_of_submission = self.date_of_submission
def test_redirect_if_correct_client(self, browser): self.login(self.regular_user, browser=browser) url = ResolveOGUIDView.url_for( Oguid.for_object(self.task), get_current_admin_unit()) browser.open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def tasks(self): return ( Task.query.by_container(self.context, get_current_admin_unit()) .in_pending_state() .order_by(desc("modified")) .limit(5) .all() )
def test_redirect_if_correct_client(self, browser): self.login(self.regular_user, browser=browser) url = ResolveOGUIDView.url_for(Oguid.for_object(self.task), get_current_admin_unit()) browser.open(url) self.assertEqual(self.task.absolute_url(), browser.url)
def get_transferring_office(self): """Returns the current adminunits label, followed by the current users fullname. """ # TODO: should use the fullname of the dispositiion creator rather # than current users fullname return '{}, {}'.format(get_current_admin_unit().label(), api.user.get_current().title_or_id())
def sync_with_submitted_proposal(self, submitted_proposal): """Sync self with a plone submitted proposal instance.""" self.submitted_oguid = Oguid.for_object(submitted_proposal) self.submitted_physical_path = submitted_proposal.get_physical_path() self.submitted_admin_unit_id = get_current_admin_unit().id() self.submitted_title = submitted_proposal.title self.submitted_description = submitted_proposal.description self.date_of_submission = submitted_proposal.date_of_submission
def test_is_different_from_public_url_for_multi_admin_unit_setup(self): admin_unit = get_current_admin_unit() # For setups with multiple admin units, an admin unit's public_url # ends with the admin unit ID admin_unit.public_url = 'http://dev.onegovgever.ch/{}'.format( admin_unit.unit_id) # Cluster base URL should NOT end with the admin unit ID. self.assertEquals('http://dev.onegovgever.ch/', get_cluster_base_url())
def create_mail(self, text='', objs=[], only_links=''): """Create the mail and attach the the files. For object without a file it include a Link to the Object in to the message. """ attachment_parts = [] msg = MIMEMultipart() msg['Date'] = formatdate(localtime=True) # iterate over object list (which can include documents and mails), # create attachement parts for them and prepare docs_links docs_links = '%s:\r\n' % (translate(_('label_documents', default=u'Attachments'), context=self.request)) for obj in objs: obj_file = obj.get_file() if only_links or not obj_file: # rewrite the url with current adminunit's public url url = '%s/%s' % (get_current_admin_unit().public_url, '/'.join( obj.getPhysicalPath()[2:])) docs_links = '%s\r\n - %s (%s)' % (docs_links, obj.title, url) continue docs_links = '%s\r\n - %s (%s)' % ( docs_links, obj.title, translate(_('label_see_attachment', default=u'see attachment'), context=self.request)) mimetype = obj_file.contentType if not mimetype: mimetype = 'application/octet-stream' maintype, subtype = obj_file.contentType.split('/', 1) part = MIMEBase(maintype, subtype) part.set_payload(obj_file.data) if mimetype != 'message/rfc822': Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % obj_file.filename) attachment_parts.append(part) # First, create the text part and attach it to the message ... text = '%s\r\n\r\n%s\r\n' % (text.encode( CHARSET, 'ignore'), docs_links.encode(CHARSET)) if not isinstance(text, unicode): text = text.decode('utf8') msg.attach(MIMEText(text, 'plain', CHARSET)) # ... then attach all the attachment parts for part in attachment_parts: msg.attach(part) return msg
def test_is_equal_to_public_url_for_single_admin_unit_setup(self): admin_unit = get_current_admin_unit() # For setups with a single admin units, the admin unit's ID is # usually omitted from the public_url admin_unit.public_url = 'http://lab.onegovgever.ch' # In this case, the cluster base URL is equivalent to public_url self.assertEquals( 'http://lab.onegovgever.ch/', get_cluster_base_url())
def test_issuer_is_prefixed_by_current_org_unit_on_a_multiclient_setup(self, browser): self.login(self.regular_user, browser=browser) create(Builder('org_unit').id('client2') .having(admin_unit=get_current_admin_unit())) browser.open(self.task, view='tabbedview_view-overview') self.assertEqual( u'Finanz\xe4mt / Ziegler Robert (robert.ziegler)', browser.css('.issuer').first.text)
def avoid_duplicates(self, query): """If a task has a successor task, list only one of them. List only the one which is assigned to this client. """ query = query.filter( or_(and_(Task.predecessor == None, Task.successors == None), Task.admin_unit_id == get_current_admin_unit().id())) return query
def get_link(self, with_state_icon=True, with_responsible_info=True): title = escape_html(self.title) admin_unit = self.get_admin_unit() if not admin_unit: return u'<span class="{}">{}</span>'.format( self.get_css_class(), title, ) url = self.absolute_url() breadcrumb_titles = u"[{}] > {}".format( admin_unit.title, escape_html(self.breadcrumb_title), ) responsible_info = u' <span class="discreet">({})</span>'.format( self.get_responsible_label(linked=False), ) link_content = u'<span class="{}">{}</span>'.format( self.get_css_class(), title, ) # If the target is on a different client we need to make a popup if self.admin_unit_id != get_current_admin_unit().id(): link_target = u' target="_blank"' else: link_target = u'' # Render the full link if we have acccess if self.has_access(api.user.get_current()): link = u'<a href="{}"{} title="{}">{}</a>'.format( url, link_target, breadcrumb_titles, link_content, ) else: link = link_content if with_responsible_info: link = u'{} {}'.format(link, responsible_info) # wrapped it into span tag if with_state_icon: link = self._task_state_wrapper(link) else: link = u'<span>%s</span>' % (link) return link
def get_link(self, with_state_icon=True, with_responsible_info=True): title = escape_html(self.title) admin_unit = self.get_admin_unit() if not admin_unit: return u'<span class="{}">{}</span>'.format( self.get_css_class(), title, ) url = self.absolute_url() breadcrumb_titles = u"[{}] > {}".format( admin_unit.title, escape_html(self.breadcrumb_title), ) responsible_info = u' <span class="discreet">({})</span>'.format( self.get_responsible_label(linked=False), ) link_content = u'<span class="{}">{}</span>'.format( self.get_css_class(), title, ) # If the target is on a different client we need to make a popup if self.admin_unit_id != get_current_admin_unit().id(): link_target = u' target="_blank"' else: link_target = u'' # Render the full link if we have acccess if self.has_access(api.user.get_current()): link = u'<a href="{}"{} title="{}">{}</a>'.format( url, link_target, breadcrumb_titles, link_content, ) else: link = link_content if with_responsible_info: link = u'{} {}'.format(link, responsible_info) # wrapped it into span tag if with_state_icon: link = self._task_state_wrapper(link) else: link = u'<span>%s</span>' % (link) return link
def url_for(cls, oguid, admin_unit=None, view_name=None): if not admin_unit: admin_unit = get_current_admin_unit() if view_name: return "{}/@@resolve_oguid/{}/{}".format(admin_unit.public_url, oguid, view_name) return "{}/@@resolve_oguid?oguid={}".format(admin_unit.public_url, oguid)
def summary(self): actor = Actor.lookup(self.context.Creator()) msg = _( 'summary_disposition_added', u'New disposition added by ${user} on admin unit ${admin_unit}', mapping={ 'user': actor.get_label(with_principal=False), 'admin_unit': get_current_admin_unit().label() }) return self.translate_to_all_languages(msg)
def test_is_different_from_public_url_for_multi_admin_unit_setup(self): admin_unit = get_current_admin_unit() # For setups with multiple admin units, an admin unit's public_url # ends with the admin unit ID admin_unit.public_url = 'http://dev.onegovgever.ch/{}'.format( admin_unit.unit_id) # Cluster base URL should NOT end with the admin unit ID. self.assertEquals( 'http://dev.onegovgever.ch/', get_cluster_base_url())
def avoid_duplicates(self, query): """If a task has a successor task, list only one of them. List only the one which is assigned to this client. """ query = query.filter( or_( and_(Task.predecessor == None, Task.successors == None), # noqa Task.admin_unit_id == get_current_admin_unit().id())) return query
def title_default(): """Returns title suggestion in the following format: `Disposition {admin unit abbreviation} {localized today's date}` """ return u'{} {} {}'.format( translate(_('label_disposition', default=u'Disposition'), context=getRequest()), get_current_admin_unit().abbreviation, api.portal.get_localized_time(date.today(), long_format=False))
def title_default(): """Returns title suggestion in the following format: `Disposition {admin unit abbreviation} {localized today's date}` """ return u'{} {} {}'.format( translate(_('label_disposition', default=u'Disposition'), context=getRequest()), get_current_admin_unit().abbreviation, api.portal.get_localized_time(date.today(), long_format=False))
def url_for(cls, oguid, admin_unit=None, view_name=None): if not admin_unit: admin_unit = get_current_admin_unit() if view_name: return "{}/@@resolve_oguid/{}/{}".format(admin_unit.public_url, oguid, view_name) return "{}/@@resolve_oguid?oguid={}".format(admin_unit.public_url, oguid)
def test_issuer_is_prefixed_by_current_org_unit_on_a_multiclient_setup( self, browser): # noqa self.login(self.regular_user, browser=browser) create( Builder('org_unit').id('client2').having( admin_unit=get_current_admin_unit())) browser.open(self.task, view='tabbedview_view-overview') self.assertEquals('Finanzamt / Ziegler Robert (robert.ziegler)', browser.css('.issuer').first.text)
def test_cannot_submit_new_document_versions_outside_proposals(self): self.login(self.regular_user) url_tool = api.portal.get_tool(name="portal_url") physical_path = '/'.join(url_tool.getRelativeContentPath(self.document)) with self.assertRaises(NoSubmittedDocument): Transporter().transport_to( self.document, get_current_admin_unit().id(), physical_path, view='update-submitted-document', )
def __init__(self, context, request, latex_view): self.context = context self.request = request self.latex_view = latex_view self.admin_unit = get_current_admin_unit() self.columns = self.update_column_dict( OrderedDict((each.id, each) for each in self.get_columns())) self.items = []
def get_data(self, notification): language = self.get_users_language() return { 'subject': self.get_subject(notification), 'title': notification.activity.translations[language].title, 'label': notification.activity.translations[language].label, 'summary': notification.activity.translations[language].summary, 'description': notification.activity.translations[language].description, 'link': resolve_notification_url(notification), 'public_url': get_current_admin_unit().public_url, }
def assign_forwarding_to_dossier( context, forwarding_oguid, dossier, response_text): forwarding = Task.query.by_oguid(forwarding_oguid) forwarding_obj = context.unrestrictedTraverse( forwarding.physical_path.encode('utf-8')) # we need all task field values from the forwarding fielddata = {} for fieldname in ITask.names(): value = ITask.get(fieldname).get(forwarding_obj) fielddata[fieldname] = value # Reset issuer to the current inbox fielddata['issuer'] = get_current_org_unit().inbox().id() # Predefine the task_type to avoid tasks with an invalid task_type fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE # lets create a new task - the successor task task = createContentInContainer( dossier, 'opengever.task.task', **fielddata) successor_tc_task = ISuccessorTaskController(task) # Add issuer and responsible to the watchers of the newly created task center = notification_center() center.add_task_responsible(task, task.responsible) center.add_task_issuer(task, task.issuer) # copy documents and map the intids intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task) # copy the responses response_transporter = IResponseTransporter(task) response_transporter.get_responses( get_current_admin_unit().id(), '/'.join(forwarding_obj.getPhysicalPath()), intids_mapping=intids_mapping) # close and store the forwarding in yearfolder change_task_workflow_state( forwarding_obj, 'forwarding-transition-assign-to-dossier', text=response_text, successor_oguid=successor_tc_task.get_oguid()) IYearfolderStorer(forwarding_obj).store_in_yearfolder() # successor successor_tc_task.set_predecessor(forwarding_oguid) return task
def __init__(self, obj, event): self.obj = obj self.event = event if not self.is_uninstalling_plone(): self.admin_unit_id = get_current_admin_unit().id() self.current_org_unit_id = get_current_org_unit().id() self.sequence_number = self.obj.get_sequence_number() self.assigned_org_unit = obj.responsible_client self.obj_id = self.get_object_id() self.task_query = Session.query(Task).filter_by( admin_unit_id=self.admin_unit_id, int_id=self.obj_id)
def create_ablieferung(self): ablieferung = arelda.ablieferungGeverSIP() ablieferung.ablieferungstyp = ABLIEFERUNGSTYP ablieferung.ablieferndeStelle = self.get_transferring_office() ablieferung.provenienz = arelda.provenienzGeverSIP() ablieferung.provenienz.aktenbildnerName = get_current_admin_unit().label() ablieferung.provenienz.registratur = self.get_repository_title() ablieferung.ordnungssystem = self.repo.binding() return ablieferung
def assign_forwarding_to_dossier(context, forwarding_oguid, dossier, response_text): forwarding = Task.query.by_oguid(forwarding_oguid) forwarding_obj = context.unrestrictedTraverse( forwarding.physical_path.encode('utf-8')) # we need all task field values from the forwarding fielddata = {} for fieldname in ITask.names(): value = ITask.get(fieldname).get(forwarding_obj) fielddata[fieldname] = value # Reset issuer to the current inbox fielddata['issuer'] = get_current_org_unit().inbox().id() # Predefine the task_type to avoid tasks with an invalid task_type fielddata['task_type'] = FORWARDING_SUCCESSOR_TYPE # lets create a new task - the successor task task = createContentInContainer(dossier, 'opengever.task.task', **fielddata) successor_tc_task = ISuccessorTaskController(task) # Add issuer and responsible to the watchers of the newly created task center = notification_center() center.add_task_responsible(task, task.responsible) center.add_task_issuer(task, task.issuer) # copy documents and map the intids intids_mapping = _copy_documents_from_forwarding(forwarding_obj, task) # copy the responses response_transporter = IResponseTransporter(task) response_transporter.get_responses(get_current_admin_unit().id(), '/'.join( forwarding_obj.getPhysicalPath()), intids_mapping=intids_mapping) # close and store the forwarding in yearfolder change_task_workflow_state(forwarding_obj, 'forwarding-transition-assign-to-dossier', text=response_text, successor_oguid=successor_tc_task.get_oguid()) IYearfolderStorer(forwarding_obj).store_in_yearfolder() # successor successor_tc_task.set_predecessor(forwarding_oguid) return task
def test_cannot_submit_new_document_versions_outside_proposals(self): self.login(self.regular_user) url_tool = api.portal.get_tool(name="portal_url") physical_path = '/'.join(url_tool.getRelativeContentPath( self.document)) with self.assertRaises(NoSubmittedDocument): Transporter().transport_to( self.document, get_current_admin_unit().id(), physical_path, view='update-submitted-document', )
def create_ablieferung(self): ablieferung = arelda.ablieferungGeverSIP() ablieferung.ablieferungstyp = ABLIEFERUNGSTYP ablieferung.ablieferndeStelle = self.get_transferring_office() ablieferung.provenienz = arelda.provenienzGeverSIP() ablieferung.provenienz.aktenbildnerName = get_current_admin_unit( ).label() ablieferung.provenienz.registratur = self.get_repository_title() ablieferung.ordnungssystem = self.repo.binding() return ablieferung