diff --git a/colab/solrutils.py b/colab/solrutils.py
index 8466e7d..b61df7c 100644
--- a/colab/solrutils.py
+++ b/colab/solrutils.py
@@ -76,7 +76,9 @@ def get_document_from_addr(doc):
"""
- username = doc.get('Creator')
+ username = doc.get('last_author')
+ if not username:
+ username = doc.get('Creator')
from_addresses = EmailAddress.objects.filter(user__username=username)
if username and from_addresses:
doc.update({'from_address': from_addresses[0]})
diff --git a/colab/super_archives/management/commands/import_emails.py b/colab/super_archives/management/commands/import_emails.py
index 9c68096..ebeddb2 100644
--- a/colab/super_archives/management/commands/import_emails.py
+++ b/colab/super_archives/management/commands/import_emails.py
@@ -11,7 +11,6 @@ from optparse import make_option
from django.db import transaction
from django.template.defaultfilters import slugify
-from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand, CommandError
from colab.super_archives.models import MailingList, Message, \
@@ -154,13 +153,16 @@ class Command(BaseCommand, object):
mailinglist = MailingList.objects.get_or_create(name=list_name)[0]
mailinglist.last_imported_index = index
- try:
- # If the message is already at the database don't do anything
- message = Message.objects.get(
- message_id=email_msg.get('Message-ID'))
- if message.thread.mailinglist.name != mailinglist.name:
- raise ObjectDoesNotExist
- except ObjectDoesNotExist:
+ # If the message is already at the database don't do anything
+ messages = Message.objects.filter(
+ message_id=email_msg.get('Message-ID'))
+ create = False
+ if not messages:
+ create = True
+ elif messages[0].thread.mailinglist.name != mailinglist.name:
+ create = True
+
+ if create:
self.create_email(mailinglist, email_msg)
mailinglist.save()
diff --git a/colab/super_archives/queries.py b/colab/super_archives/queries.py
index 75bae64..2ef00ff 100644
--- a/colab/super_archives/queries.py
+++ b/colab/super_archives/queries.py
@@ -1,4 +1,5 @@
+from django.core.exceptions import ObjectDoesNotExist
from colab.super_archives.models import Thread, Vote, Message, PageHit
@@ -29,7 +30,10 @@ def get_messages_by_voted():
def get_first_message_in_thread(mailinglist, thread_token):
query = get_messages_by_date()
query = query.filter(thread__mailinglist__name=mailinglist)
- query = query.filter(thread__subject_token=thread_token)[0]
+ try:
+ query = query.filter(thread__subject_token=thread_token)[0]
+ except IndexError:
+ raise ObjectDoesNotExist
return query
diff --git a/colab/super_archives/templates/message-preview.html b/colab/super_archives/templates/message-preview.html
index a992ef6..a7bbbdd 100644
--- a/colab/super_archives/templates/message-preview.html
+++ b/colab/super_archives/templates/message-preview.html
@@ -5,6 +5,9 @@
{% if doc.Type %}
+ {% else %}
+
{% endif %}
{% if doc.mailinglist %}
@@ -29,13 +32,13 @@