def commit(self): VersionedArtifact.commit(self) monitoring_email = self.app.config.options.get('TicketMonitoringEmail') if self.version > 1: hist = TicketHistory.query.get(artifact_id=self._id, version=self.version-1) old = hist.data changes = ['Ticket %s has been modified: %s' % ( self.ticket_num, self.summary), 'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username)] fields = [ ('Summary', old.summary, self.summary), ('Status', old.status, self.status) ] if old.status != self.status and self.status in c.app.globals.set_of_closed_status_names: h.log_action(log, 'closed').info('') g.statsUpdater.ticketEvent("closed", self, self.project, self.assigned_to) for key in self.custom_fields: fields.append((key, old.custom_fields.get(key, ''), self.custom_fields[key])) for title, o, n in fields: if o != n: changes.append('%s updated: %r => %r' % ( title, o, n)) o = hist.assigned_to n = self.assigned_to if o != n: changes.append('Owner updated: %r => %r' % ( o and o.username, n and n.username)) self.subscribe(user=n) g.statsUpdater.ticketEvent("assigned", self, self.project, n) if o: g.statsUpdater.ticketEvent("revoked", self, self.project, o) if old.description != self.description: changes.append('Description updated:') changes.append('\n'.join( difflib.unified_diff( a=old.description.split('\n'), b=self.description.split('\n'), fromfile='description-old', tofile='description-new'))) description = '\n'.join(changes) else: self.subscribe() if self.assigned_to_id: user = User.query.get(_id=self.assigned_to_id) g.statsUpdater.ticketEvent("assigned", self, self.project, user) self.subscribe(user=user) description = '' subject = self.email_subject Thread.new(discussion_id=self.app_config.discussion_id, ref_id=self.index_id()) n = Notification.post(artifact=self, topic='metadata', text=description, subject=subject) if monitoring_email and n and (not self.private or self.app.config.options.get('TicketMonitoringType') in ( 'NewTicketsOnly', 'AllTicketChanges')): n.send_simple(monitoring_email) Feed.post( self, title=self.summary, description=description if description else self.description, author=self.reported_by, pubdate=self.created_date)
def commit(self): VersionedArtifact.commit(self) session(self).flush() if self.version > 1: v1 = self.get_version(self.version - 1) v2 = self la = [line + '\n' for line in v1.text.splitlines()] lb = [line + '\n' for line in v2.text.splitlines()] diff = ''.join( difflib.unified_diff(la, lb, 'v%d' % v1.version, 'v%d' % v2.version)) description = '<pre>' + diff + '</pre>' if v1.title != v2.title: subject = '%s renamed page %s to %s' % (context.user.username, v1.title, v2.title) else: subject = '%s modified page %s' % (context.user.username, self.title) else: description = self.text subject = '%s created page %s' % (context.user.username, self.title) Feed.post(self, title=None, description=description) Notification.post(artifact=self, topic='metadata', text=description, subject=subject)
def commit(self): VersionedArtifact.commit(self) monitoring_email = self.app.config.options.get('TicketMonitoringEmail') if self.version > 1: hist = TicketHistory.query.get(artifact_id=self._id, version=self.version - 1) old = hist.data changes = [ 'Ticket %s has been modified: %s' % (self.ticket_num, self.summary), 'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username) ] fields = [('Summary', old.summary, self.summary), ('Status', old.status, self.status)] if old.status != self.status and self.status in c.app.globals.set_of_closed_status_names: h.log_action(log, 'closed').info('') for key in self.custom_fields: fields.append( (key, old.custom_fields.get(key, ''), self.custom_fields[key])) for title, o, n in fields: if o != n: changes.append('%s updated: %r => %r' % (title, o, n)) o = hist.assigned_to n = self.assigned_to if o != n: changes.append('Owner updated: %r => %r' % (o and o.username, n and n.username)) self.subscribe(user=n) if old.description != self.description: changes.append('Description updated:') changes.append('\n'.join( difflib.unified_diff(a=old.description.split('\n'), b=self.description.split('\n'), fromfile='description-old', tofile='description-new'))) description = '\n'.join(changes) else: self.subscribe() if self.assigned_to_id: self.subscribe(user=User.query.get(_id=self.assigned_to_id)) description = '' subject = self.email_subject Thread(discussion_id=self.app_config.discussion_id, ref_id=self.index_id()) n = Notification.post(artifact=self, topic='metadata', text=description, subject=subject) if monitoring_email and n: n.send_simple(monitoring_email) Feed.post(self, description)
def commit(self): ss = VersionedArtifact.commit(self) session(self).flush() if self.version > 1: v1 = self.get_version(self.version - 1) v2 = self la = [line + '\n' for line in v1.text.splitlines()] lb = [line + '\n' for line in v2.text.splitlines()] diff = ''.join(difflib.unified_diff( la, lb, 'v%d' % v1.version, 'v%d' % v2.version)) description = '<pre>' + diff + '</pre>' if v1.title != v2.title: subject = '%s renamed page %s to %s' % ( context.user.username, v1.title, v2.title) else: subject = '%s modified page %s' % ( context.user.username, self.title) else: description = self.text subject = '%s created page %s' % ( context.user.username, self.title) Feed.post(self, title=None, description=description) Notification.post( artifact=self, topic='metadata', text=description, subject=subject) return ss
def index(self): result = VersionedArtifact.index(self) result.update(title=self.title, version_i=self.version, type_s='WikiPage', text=self.text) return result
def index(self): result = VersionedArtifact.index(self) result.update( title=self.title, version_i=self.version, type_s='WikiPage', text=self.text) return result
def index(self): result = VersionedArtifact.index(self) result.update(title_s='Ticket %s' % self.ticket_num, version_i=self.version, type_s=self.type_s, ticket_num_i=self.ticket_num, summary_t=self.summary, milestone_s=self.milestone, status_s=self.status, text=self.description, snippet_s=self.summary, votes_up_i=self.votes_up, votes_down_i=self.votes_down, votes_total_i=(self.votes_up - self.votes_down)) for k, v in self.custom_fields.iteritems(): result[k + '_s'] = unicode(v) if self.reported_by: result['reported_by_s'] = self.reported_by.username if self.assigned_to: result['assigned_to_s'] = self.assigned_to.username return result
def index(self): result = VersionedArtifact.index(self) result.update( title='Ticket %s' % self.ticket_num, version_i=self.version, type_s=self.type_s, created_date_dt=self.created_date, ticket_num_i=self.ticket_num, summary_t=self.summary, milestone_s=self.milestone, status_s=self.status, text=self.description, snippet_s=self.summary, private_b=self.private, votes_up_i=self.votes_up, votes_down_i=self.votes_down, votes_total_i=(self.votes_up - self.votes_down), import_id_s=ImportIdConverter.get().simplify(self.import_id) ) for k, v in self.custom_fields.iteritems(): # Pre solr-4.2.1 code expects all custom fields to be indexed # as strings. if not config.get_bool('new_solr'): result[k + '_s'] = unicode(v) # Now let's also index with proper Solr types. solr_type = self.app.globals.get_custom_field_solr_type(k) if solr_type: result[k + solr_type] = (v or get_default_for_solr_type(solr_type)) if self.reported_by: result['reported_by_s'] = self.reported_by.username if self.assigned_to: result['assigned_to_s'] = self.assigned_to.username # Tracker uses search with default solr parser. It would match only on # `text`, so we're appending all other field values into `text`, to # match on it too. result['text'] += pformat(result.values()) return result
def index(self): result = VersionedArtifact.index(self) result.update(title='Ticket %s' % self.ticket_num, version_i=self.version, type_s=self.type_s, created_date_dt=self.created_date, ticket_num_i=self.ticket_num, summary_t=self.summary, milestone_s=self.milestone, status_s=self.status, text=self.description, snippet_s=self.summary, private_b=self.private, votes_up_i=self.votes_up, votes_down_i=self.votes_down, votes_total_i=(self.votes_up - self.votes_down), import_id_s=ImportIdConverter.get().simplify( self.import_id)) for k, v in self.custom_fields.iteritems(): # Pre solr-4.2.1 code expects all custom fields to be indexed # as strings. if not config.get_bool('new_solr'): result[k + '_s'] = unicode(v) # Now let's also index with proper Solr types. solr_type = self.app.globals.get_custom_field_solr_type(k) if solr_type: result[k + solr_type] = (v or get_default_for_solr_type(solr_type)) if self.reported_by: result['reported_by_s'] = self.reported_by.username if self.assigned_to: result['assigned_to_s'] = self.assigned_to.username # Tracker uses search with default solr parser. It would match only on # `text`, so we're appending all other field values into `text`, to # match on it too. result['text'] += pformat(result.values()) return result
def index(self): result = VersionedArtifact.index(self) result.update( title_s='Ticket %s' % self.ticket_num, version_i=self.version, type_s=self.type_s, ticket_num_i=self.ticket_num, summary_t=self.summary, milestone_s=self.milestone, status_s=self.status, text=self.description, snippet_s=self.summary, votes_up_i=self.votes_up, votes_down_i=self.votes_down, votes_total_i=(self.votes_up-self.votes_down) ) for k,v in self.custom_fields.iteritems(): result[k + '_s'] = unicode(v) if self.reported_by: result['reported_by_s'] = self.reported_by.username if self.assigned_to: result['assigned_to_s'] = self.assigned_to.username return result
def commit(self): VersionedArtifact.commit(self) monitoring_email = self.app.config.options.get('TicketMonitoringEmail') if self.version > 1: hist = TicketHistory.query.get(artifact_id=self._id, version=self.version - 1) old = hist.data changes = [ 'Ticket %s has been modified: %s' % (self.ticket_num, self.summary), 'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username) ] fields = [('Summary', old.summary, self.summary), ('Status', old.status, self.status)] if old.status != self.status and self.status in c.app.globals.set_of_closed_status_names: h.log_action(log, 'closed').info('') g.statsUpdater.ticketEvent("closed", self, self.project, self.assigned_to) for key in self.custom_fields: fields.append( (key, old.custom_fields.get(key, ''), self.custom_fields[key])) for title, o, n in fields: if o != n: changes.append('%s updated: %r => %r' % (title, o, n)) o = hist.assigned_to n = self.assigned_to if o != n: changes.append('Owner updated: %r => %r' % (o and o.username, n and n.username)) self.subscribe(user=n) g.statsUpdater.ticketEvent("assigned", self, self.project, n) if o: g.statsUpdater.ticketEvent("revoked", self, self.project, o) if old.description != self.description: changes.append('Description updated:') changes.append('\n'.join( difflib.unified_diff(a=old.description.split('\n'), b=self.description.split('\n'), fromfile='description-old', tofile='description-new'))) description = '\n'.join(changes) else: self.subscribe() if self.assigned_to_id: user = User.query.get(_id=self.assigned_to_id) g.statsUpdater.ticketEvent("assigned", self, self.project, user) self.subscribe(user=user) description = '' subject = self.email_subject Thread.new(discussion_id=self.app_config.discussion_id, ref_id=self.index_id()) # First ticket notification. Use persistend Message-ID (self.message_id()). # Thus we can group notification emails in one thread later. n = Notification.post(message_id=self.message_id(), artifact=self, topic='metadata', text=description, subject=subject) if monitoring_email and n and ( not self.private or self.app.config.options.get('TicketMonitoringType') in ('NewTicketsOnly', 'AllTicketChanges')): n.send_simple(monitoring_email) Feed.post(self, title=self.summary, description=description if description else self.description, author=self.reported_by, pubdate=self.created_date)
def commit(self, **kwargs): VersionedArtifact.commit(self) monitoring_email = self.app.config.options.get("TicketMonitoringEmail") if self.version > 1: hist = TicketHistory.query.get(artifact_id=self._id, version=self.version - 1) old = hist.data changes = [ "Ticket %s has been modified: %s" % (self.ticket_num, self.summary), "Edited By: %s (%s)" % (c.user.get_pref("display_name"), c.user.username), ] fields = [("Summary", old.summary, self.summary), ("Status", old.status, self.status)] if old.status != self.status and self.status in c.app.globals.set_of_closed_status_names: h.log_action(log, "closed").info("") g.statsUpdater.ticketEvent("closed", self, self.project, self.assigned_to) for key in self.custom_fields: fields.append((key, old.custom_fields.get(key, ""), self.custom_fields[key])) for title, o, n in fields: if o != n: changes.append("%s updated: %r => %r" % (title, o, n)) o = hist.assigned_to n = self.assigned_to if o != n: changes.append("Owner updated: %r => %r" % (o and o.username, n and n.username)) self.subscribe(user=n) g.statsUpdater.ticketEvent("assigned", self, self.project, n) if o: g.statsUpdater.ticketEvent("revoked", self, self.project, o) if old.description != self.description: changes.append("Description updated:") changes.append( "\n".join( difflib.unified_diff( a=old.description.split("\n"), b=self.description.split("\n"), fromfile="description-old", tofile="description-new", ) ) ) description = "\n".join(changes) else: self.subscribe() if self.assigned_to_id: user = User.query.get(_id=self.assigned_to_id) g.statsUpdater.ticketEvent("assigned", self, self.project, user) self.subscribe(user=user) description = "" subject = self.email_subject Thread.new(discussion_id=self.app_config.discussion_id, ref_id=self.index_id()) # First ticket notification. Use persistend Message-ID (self.message_id()). # Thus we can group notification emails in one thread later. n = Notification.post( message_id=self.message_id(), artifact=self, topic="metadata", text=description, subject=subject ) if ( monitoring_email and n and ( not self.private or self.app.config.options.get("TicketMonitoringType") in ("NewTicketsOnly", "AllTicketChanges") ) ): n.send_simple(monitoring_email) Feed.post( self, title=self.summary, description=description if description else self.description, author=self.reported_by, pubdate=self.created_date, )