Add option to the EmailIgnore model to allow emails from an ignored address to be deleted (previous behaviour was to keep them all, so the mailbox could potentially become quite large - and every message was downloaded again every time the mailbox was checked). Upgrade instructions provided to both add the new database field and automatically switch to the old behaviour.

This commit is contained in:
Ross Poulton 2009-01-23 10:36:41 +00:00
parent 705c32908a
commit e37609de6e
4 changed files with 45 additions and 13 deletions

18
UPGRADE
View File

@ -9,4 +9,20 @@ all commands listed _after_ that checkout.
#########################
0. Table of Contents
#########################
No items yet.
1. 2009-01-23 (Changes added after SVN r99)
#########################
1. 2009-01-23 (Changes added after SVN r99)
#########################
A new flag was added to the 'IgnoreEmail' model to allow emails from ignored
addresses to be either kept in the mailbox (for manual checking) or deleted.
A new column called 'keep_in_mailbox' (type boolean, not required) is to be
added to the 'helpdesk_ignoreemail' table. The 'UPDATE' command will set all
ignore list entries to 'Keep mail from ignored address', which is the previous
behaviour.
ALTER TABLE helpdesk_ignoreemail ADD "keep_in_mailbox" boolean;
UPDATE helpdesk_ignoreemail SET keep_in_mailbox='t';

View File

@ -137,7 +137,11 @@ def ticket_from_message(message, queue):
for ignore in IgnoreEmail.objects.filter(Q(queues=queue) | Q(queues__isnull=True)):
if ignore.test(sender_email):
return False
if ignore.keep_in_mailbox:
# By returning 'False' the message will be kept in the mailbox,
# and the 'True' will cause the message to be deleted.
return False
return True
regex = re.compile("^\[[A-Za-z0-9]+-\d+\]")
if regex.match(subject):

View File

@ -964,6 +964,15 @@ class IgnoreEmail(models.Model):
'wildcards, eg *@domain.com or postmaster@*.'),
)
keep_in_mailbox = models.BooleanField(
_('Save Emails in Mailbox?'),
blank=True,
null=True,
help_text=_('Do you want to save emails from this address in the '
'mailbox? If this is unticked, emails from this address will '
'be deleted.'),
)
def __unicode__(self):
return u'%s' % self.name

View File

@ -10,7 +10,7 @@
<table width='100%'>
<thead>
<tr class='row_tablehead'><td colspan='5'>{% trans "Ignored E-Mail Addresses" %}</td></tr>
<tr class='row_columnheads'><th>{% trans "Name" %}</th><th>{% trans "E-Mail Address" %}</th><th>{% trans "Date Added" %}</th><th>{% trans "Queues" %}</th><th>{% trans "Delete" %}</th></tr>
<tr class='row_columnheads'><th>{% trans "Name" %}</th><th>{% trans "E-Mail Address" %}</th><th>{% trans "Date Added" %}</th><th>{% trans "Queues" %}</th><th>{% trans "Keep in mailbox?" %}</th><th>{% trans "Delete" %}</th></tr>
</thead>
<tbody>
{% for ignore in ignore_list %}
@ -18,11 +18,14 @@
<td>{{ ignore.name }}</td>
<td>{{ ignore.email_address }}</td>
<td>{{ ignore.date }}</td>
<td>{% for queue in ignore.queues.all %}{{ queue.slug }}{% if not forloop.last %}, {% endif %}{% endfor %}{% if not ignore.queues.all %}All{% endif %}</td>
<td><a href='{% url helpdesk_email_ignore_del ignore.id %}'>Delete</a></td>
<td>{% for queue in ignore.queues.all %}{{ queue.slug }}{% if not forloop.last %}, {% endif %}{% endfor %}{% if not ignore.queues.all %}{% trans "All" %}{% endif %}</td>
<td>{% if ignore.keep_in_mailbox %}{% trans "Keep" %}{% endif %}</td>
<td><a href='{% url helpdesk_email_ignore_del ignore.id %}'>{% trans "Delete" %}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
<p>{% trans "<strong>Note:</strong> If the 'Keep' option is not selected, emails sent from that address will be deleted permanently." %}</p>
{% endblock %}