def handleApply(self, action): data, errors = self.extractData() if errors: return agenda_items_to_include = [] for agenda_item in self.get_agenda_items(): if agenda_item.name in self.request: agenda_items_to_include.append(agenda_item) if not agenda_items_to_include: raise(ActionExecutionError( Invalid(_(u"Please select at least one agenda item.")))) operations = ManualExcerptOperations( agenda_items_to_include, data['title'], include_initial_position=data['include_initial_position'], include_legal_basis=data['include_legal_basis'], include_considerations=data['include_considerations'], include_proposed_action=data['include_proposed_action'], include_discussion=data['include_discussion'], include_decision=data['include_decision'], include_publish_in=data['include_publish_in'], include_disclose_to=data['include_disclose_to'], include_copy_for_attention=data['include_copy_for_attention']) command = CreateGeneratedDocumentCommand( data['dossier'], self.model, operations) command.execute() command.show_message() return self.redirect_to_meeting()
def generate_agenda_item_list(self, meeting): if isinstance(meeting, MeetingWrapper): meeting = meeting.model from opengever.meeting.command import AgendaItemListOperations from opengever.meeting.command import CreateGeneratedDocumentCommand command = CreateGeneratedDocumentCommand( meeting.get_dossier(), meeting, AgendaItemListOperations(), ) command.execute()
def update_protocol_document(self): """Update or create meeting's protocol.""" from opengever.meeting.command import CreateGeneratedDocumentCommand from opengever.meeting.command import MergeDocxProtocolCommand from opengever.meeting.command import ProtocolOperations from opengever.meeting.command import UpdateGeneratedDocumentCommand if self.has_protocol_document( ) and not self.protocol_document.is_locked(): # The protocol should never be changed when it is no longer locked: # the user probably has made changes manually. return operations = ProtocolOperations() if is_word_meeting_implementation_enabled(): command = MergeDocxProtocolCommand( self.get_dossier(), self, operations, lock_document_after_creation=True) else: if self.has_protocol_document(): command = UpdateGeneratedDocumentCommand( self.protocol_document, self, operations) else: command = CreateGeneratedDocumentCommand( self.get_dossier(), self, operations, lock_document_after_creation=True) command.execute()
def generate_excerpt(self, agenda_item): from opengever.meeting.command import CreateGeneratedDocumentCommand from opengever.meeting.command import ExcerptOperations proposal_obj = self.resolve_submitted_proposal() operations = ExcerptOperations(agenda_item) CreateGeneratedDocumentCommand( proposal_obj, agenda_item.meeting, operations).execute()
def render(self): meeting = self.get_meeting() command = CreateGeneratedDocumentCommand( self.context, meeting, self.operations, lock_document_after_creation=True) try: command.execute() command.show_message() except ProtocolAlreadyGenerated: msg = _(u'msg_error_protocol_already_generated', default=u'The protocol for meeting ${title} has already ' u'been generated.', mapping=dict(title=meeting.get_title())) api.portal.show_message(msg, self.request, type='error') return self.request.RESPONSE.redirect(meeting.get_url())
def get_protocol(self): if self.model.has_protocol_document(): protocol = self.model.protocol_document.resolve_document() protocol_modified = protocol.modified().asdatetime().astimezone( pytz.utc) if self.model.modified < protocol_modified: # Return current protocol return (u'{}.docx'.format(safe_unicode(protocol.Title())), protocol.file.open()) # Create new protocol operations = ProtocolOperations() command = CreateGeneratedDocumentCommand( self.context, self.model, operations, lock_document_after_creation=False) filename = u'{}.docx'.format(operations.get_title(self.model)) return (filename, StringIO(command.generate_file_data()))
def get_agendaitem_list(self): if self.model.has_agendaitem_list_document(): agendaitem_list = self.model.agendaitem_list_document.resolve_document() agendaitem_list_modified = agendaitem_list.modified().asdatetime().astimezone( pytz.utc) if self.model.modified < agendaitem_list_modified: # Return current protocol return (u'{}.docx'.format(safe_unicode(agendaitem_list.Title())), agendaitem_list.file.open()) # Create new protocol operations = AgendaItemListOperations() command = CreateGeneratedDocumentCommand( self.context, self.model, operations, ) filename = u'{}.docx'.format(operations.get_title(self.model)) return (filename, StringIO(command.generate_file_data()))
def __call__(self): meeting = self.get_meeting() command = CreateGeneratedDocumentCommand( self.context, meeting, self.operations, ) try: command.execute() command.show_message() except AgendaItemListMissingTemplate: msg = _( u'msg_error_agendaitem_list_missing_template', default=(u'There is no agendaitem list template configured, agendaitem list could not be generated.'), mapping=dict(title=meeting.get_title()), ) api.portal.show_message(msg, self.request, type='error') except AgendaItemListAlreadyGenerated: msg = _( u'msg_error_agendaitem_list_already_generated', default=(u'The agenda item list for meeting ${title} has already been generated.'), mapping=dict(title=meeting.get_title()), ) api.portal.show_message(msg, self.request, type='error') except SablonProcessingFailed: msg = _(u'Error while processing Sablon template') api.portal.show_message(msg, self.request, type='error') return self.request.RESPONSE.redirect(meeting.get_url())
def handleApply(self, action): data, errors = self.extractData() if errors: return agenda_items_to_include = [] for agenda_item in self.get_agenda_items(): if agenda_item.name in self.request: agenda_items_to_include.append(agenda_item) if not agenda_items_to_include: raise (ActionExecutionError( Invalid(_(u"Please select at least one agenda item.")))) operations = ManualExcerptOperations( agenda_items_to_include, data['title'], include_initial_position=data['include_initial_position'], include_legal_basis=data['include_legal_basis'], include_considerations=data['include_considerations'], include_proposed_action=data['include_proposed_action'], include_discussion=data['include_discussion'], include_decision=data['include_decision'], include_publish_in=data['include_publish_in'], include_disclose_to=data['include_disclose_to'], include_copy_for_attention=data['include_copy_for_attention']) command = CreateGeneratedDocumentCommand(data['dossier'], self.model, operations) command.execute() command.show_message() return self.redirect_to_meeting()
def update_protocol_document(self): """Update or create meeting's protocol.""" from opengever.meeting.command import CreateGeneratedDocumentCommand from opengever.meeting.command import ProtocolOperations from opengever.meeting.command import UpdateGeneratedDocumentCommand operations = ProtocolOperations() if self.has_protocol_document(): command = UpdateGeneratedDocumentCommand(self.protocol_document, self, operations) else: command = CreateGeneratedDocumentCommand( self.get_dossier(), self, operations, lock_document_after_creation=True) command.execute()
def __call__(self): meeting = self.get_meeting() command = CreateGeneratedDocumentCommand( self.context, meeting, self.operations, lock_document_after_creation=True) try: command.execute() command.show_message() except ProtocolAlreadyGenerated: msg = _(u'msg_error_protocol_already_generated', default=u'The protocol for meeting ${title} has already ' u'been generated.', mapping=dict(title=meeting.get_title())) api.portal.show_message(msg, self.request, type='error') return self.request.RESPONSE.redirect(meeting.get_url())