forked from extern/django-helpdesk
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:
parent
705c32908a
commit
e37609de6e
18
UPGRADE
18
UPGRADE
@ -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';
|
||||
|
@ -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):
|
||||
|
25
models.py
25
models.py
@ -129,7 +129,7 @@ class Queue(models.Model):
|
||||
help_text=_('Whether to use SSL for IMAP or POP3 - the default ports '
|
||||
'when using SSL are 993 for IMAP and 995 for POP3.'),
|
||||
)
|
||||
|
||||
|
||||
email_box_user = models.CharField(
|
||||
_('E-Mail Username'),
|
||||
max_length=200,
|
||||
@ -847,7 +847,7 @@ class SavedSearch(models.Model):
|
||||
null=True,
|
||||
help_text=_('Should other users see this query?'),
|
||||
)
|
||||
|
||||
|
||||
query = models.TextField(
|
||||
_('Search Query'),
|
||||
help_text=_('Pickled query object. Be wary changing this.'),
|
||||
@ -867,7 +867,7 @@ class UserSettings(models.Model):
|
||||
|
||||
We should always refer to user.usersettings.settings['setting_name'].
|
||||
"""
|
||||
|
||||
|
||||
user = models.OneToOneField(User)
|
||||
|
||||
settings_pickled = models.TextField(
|
||||
@ -882,7 +882,7 @@ class UserSettings(models.Model):
|
||||
import cPickle
|
||||
from helpdesk.lib import b64encode
|
||||
self.settings_pickled = b64encode(cPickle.dumps(data))
|
||||
|
||||
|
||||
def _get_settings(self):
|
||||
# return a python dictionary representing the pickled data.
|
||||
import cPickle
|
||||
@ -896,7 +896,7 @@ class UserSettings(models.Model):
|
||||
|
||||
def __unicode__(self):
|
||||
return u'Preferences for %s' % self.user
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'User Settings'
|
||||
verbose_name_plural = 'User Settings'
|
||||
@ -949,7 +949,7 @@ class IgnoreEmail(models.Model):
|
||||
_('Name'),
|
||||
max_length=100,
|
||||
)
|
||||
|
||||
|
||||
date = models.DateField(
|
||||
_('Date'),
|
||||
help_text=_('Date on which this e-mail address was added'),
|
||||
@ -964,9 +964,18 @@ 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
|
||||
|
||||
|
||||
def save(self):
|
||||
if not self.date:
|
||||
self.date = datetime.now()
|
||||
@ -983,7 +992,7 @@ class IgnoreEmail(models.Model):
|
||||
|
||||
1-4 return True, 5 returns False.
|
||||
"""
|
||||
|
||||
|
||||
own_parts = self.email_address.split("@")
|
||||
email_parts = email.split("@")
|
||||
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user