| 22 | | #Add the ticket change so that it will appear |
|---|
| 23 | | #correctly in the history and notifications |
|---|
| 24 | | cursor.execute("INSERT INTO ticket_change " |
|---|
| 25 | | "(ticket,time,author,field,oldvalue,newvalue) " |
|---|
| 26 | | "VALUES (%s, %s, %s, %s, %s, %s)", |
|---|
| 27 | | (ticket.id, ticket.time_changed, author, 'pending', '1', '0')) |
|---|
| | 27 | cursor.execute("UPDATE ticket_custom SET value = %s " \ |
|---|
| | 28 | " WHERE ticket = %s AND name = %s ", |
|---|
| | 29 | ('0', ticket.id, 'pending')) |
|---|
| 29 | | db.commit(); |
|---|
| | 31 | #Add the ticket change so that it will appear |
|---|
| | 32 | #correctly in the history and notifications |
|---|
| | 33 | cursor.execute("INSERT INTO ticket_change " |
|---|
| | 34 | "(ticket,time,author,field,oldvalue,newvalue) " |
|---|
| | 35 | "VALUES (%s, %s, %s, %s, %s, %s)", |
|---|
| | 36 | (ticket.id, to_timestamp(time_changed), author, 'pending', '1', '0')) |
|---|
| | 37 | |
|---|
| | 38 | db.commit(); |
|---|
| | 43 | def attachment_added(self, attachment): |
|---|
| | 44 | # Check whether we're dealing with a ticket resource |
|---|
| | 45 | resource = attachment.resource |
|---|
| | 46 | while resource: |
|---|
| | 47 | if resource.realm == 'ticket': |
|---|
| | 48 | break |
|---|
| | 49 | resource = resource.parent |
|---|
| | 50 | |
|---|
| | 51 | if (resource and resource.realm == 'ticket' and resource.id is not None): |
|---|
| | 52 | db = attachment.env.get_db_cnx(); |
|---|
| | 53 | ticket = Ticket(attachment.env, resource.id, db) |
|---|
| | 54 | if (attachment.author == ticket['reporter'] and ticket['pending'] == '1'): |
|---|
| | 55 | self.env.log.info('Removing Pending status for ticket %s due to attachment' |
|---|
| | 56 | % (ticket.id)) |
|---|
| | 57 | |
|---|
| | 58 | comment = 'Attachment (%s) added by ticket reporter.' % (attachment.filename) |
|---|
| | 59 | ticket['pending'] = '0' |
|---|
| | 60 | |
|---|
| | 61 | # determine sequence number... |
|---|
| | 62 | cnum = 0 |
|---|
| | 63 | tm = TicketModule(self.env) |
|---|
| | 64 | for change in tm.grouped_changelog_entries(ticket, db): |
|---|
| | 65 | if change['permanent']: |
|---|
| | 66 | cnum += 1 |
|---|
| | 67 | |
|---|
| | 68 | #We can't just use attachment.date as it screws up event sequencing |
|---|
| | 69 | now = datetime.now(utc) |
|---|
| | 70 | |
|---|
| | 71 | ticket.save_changes(attachment.author, comment, now, db, cnum + 1) |
|---|
| | 72 | db.commit() |
|---|
| | 73 | |
|---|
| | 74 | #trigger notification since we've changed the ticket |
|---|
| | 75 | tn = TicketNotifyEmail(self.env) |
|---|
| | 76 | tn.notify(ticket, newticket=False, modtime=now) |
|---|
| | 77 | |
|---|
| | 78 | def attachment_deleted(self, attachment): |
|---|
| | 79 | pass |
|---|
| | 80 | |
|---|