Skip to content
Browse files

adding indexes

  • Loading branch information...
1 parent 0affe39 commit 3c2e9f4a4dfb63eb822efeca2d1766ed69531636 @philippWassibauer philippWassibauer committed Nov 16, 2012
Showing with 174 additions and 13 deletions.
  1. +46 −0 MANIFEST
  2. +1 −1 threaded_messages/__init__.py
  3. +2 −8 threaded_messages/admin.py
  4. +117 −0 threaded_messages/migrations/0004_auto.py
  5. +8 −4 threaded_messages/models.py
View
46 MANIFEST
@@ -0,0 +1,46 @@
+# file GENERATED by distutils, do NOT edit
+LICENSE.txt
+README.rst
+setup.py
+threaded_messages/__init__.py
+threaded_messages/admin.py
+threaded_messages/context_processors.py
+threaded_messages/fields.py
+threaded_messages/forms.py
+threaded_messages/listeners.py
+threaded_messages/management.py
+threaded_messages/models.py
+threaded_messages/search_indexes.py
+threaded_messages/settings.py
+threaded_messages/tests.py
+threaded_messages/urls.py
+threaded_messages/utils.py
+threaded_messages/views.py
+threaded_messages/locale/de/LC_MESSAGES/django.mo
+threaded_messages/locale/de/LC_MESSAGES/django.po
+threaded_messages/locale/en/LC_MESSAGES/django.po
+threaded_messages/locale/es/LC_MESSAGES/django.po
+threaded_messages/locale/fr/LC_MESSAGES/django.po
+threaded_messages/locale/it/LC_MESSAGES/django.po
+threaded_messages/migrations/0001_initial.py
+threaded_messages/migrations/0002_auto__add_field_thread_sender.py
+threaded_messages/migrations/0003_auto__add_field_thread_replied.py
+threaded_messages/migrations/__init__.py
+threaded_messages/static/css/token-input.css
+threaded_messages/static/js/jquery-1.5.2.min.js
+threaded_messages/static/js/jquery.form.js
+threaded_messages/static/js/jquery.tokeninput.js
+threaded_messages/templates/django_messages/base.html
+threaded_messages/templates/django_messages/compose.html
+threaded_messages/templates/django_messages/inbox.html
+threaded_messages/templates/django_messages/message_list_view.html
+threaded_messages/templates/django_messages/message_reply.html
+threaded_messages/templates/django_messages/modal_compose.html
+threaded_messages/templates/django_messages/new_message.html
+threaded_messages/templates/django_messages/outbox.html
+threaded_messages/templates/django_messages/search.html
+threaded_messages/templates/django_messages/trash.html
+threaded_messages/templates/django_messages/view.html
+threaded_messages/templatetags/__init__.py
+threaded_messages/templatetags/inbox.py
+threaded_messages/templatetags/truncchar_tag.py
View
2 threaded_messages/__init__.py
@@ -1,2 +1,2 @@
-VERSION = (0, 1, 32)
+VERSION = (0, 1, 34)
__version__ = '.'.join(map(str, VERSION))
View
10 threaded_messages/admin.py
@@ -1,19 +1,13 @@
-from django import forms
-from django.conf import settings
-from django.utils.translation import gettext_lazy as _
from django.contrib import admin
-from django.contrib.auth.models import User, Group
from threaded_messages.models import *
-
-
class MessageAdmin(admin.ModelAdmin):
- list_display = ('sender', 'sent_at','body')
+ list_display = ('sender', 'sent_at', 'body')
ordering = ('-sent_at',)
search_fields = ('body', 'sender__first_name',
'sender__last_name', 'sender__username')
- raw_id_fields = ('sender',)
+ raw_id_fields = ('sender', 'parent_msg')
readonly_fields = ('subject',)
def subject(self, msg):
View
117 threaded_messages/migrations/0004_auto.py
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding index on 'Participant', fields ['replied_at']
+ db.create_index('threaded_messages_participant', ['replied_at'])
+
+ # Adding index on 'Participant', fields ['read_at']
+ db.create_index('threaded_messages_participant', ['read_at'])
+
+ # Adding index on 'Participant', fields ['deleted_at']
+ db.create_index('threaded_messages_participant', ['deleted_at'])
+
+ # Adding index on 'Message', fields ['sent_at']
+ db.create_index('threaded_messages_message', ['sent_at'])
+
+
+ def backwards(self, orm):
+ # Removing index on 'Message', fields ['sent_at']
+ db.delete_index('threaded_messages_message', ['sent_at'])
+
+ # Removing index on 'Participant', fields ['deleted_at']
+ db.delete_index('threaded_messages_participant', ['deleted_at'])
+
+ # Removing index on 'Participant', fields ['read_at']
+ db.delete_index('threaded_messages_participant', ['read_at'])
+
+ # Removing index on 'Participant', fields ['replied_at']
+ db.delete_index('threaded_messages_participant', ['replied_at'])
+
+
+ models = {
+ 'actstream.action': {
+ 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Action'},
+ 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}),
+ 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actor'", 'to': "orm['contenttypes.ContentType']"}),
+ 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}),
+ 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'threaded_messages.message': {
+ 'Meta': {'ordering': "['-sent_at']", 'object_name': 'Message'},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'parent_msg': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'next_messages'", 'null': 'True', 'to': "orm['threaded_messages.Message']"}),
+ 'sender': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'sent_messages'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'sent_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'})
+ },
+ 'threaded_messages.participant': {
+ 'Meta': {'ordering': "['thread']", 'object_name': 'Participant'},
+ 'deleted_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'read_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+ 'replied_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
+ 'thread': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'participants'", 'to': "orm['threaded_messages.Thread']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'threads'", 'to': "orm['auth.User']"})
+ },
+ 'threaded_messages.thread': {
+ 'Meta': {'ordering': "['latest_msg']", 'object_name': 'Thread'},
+ 'all_msgs': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'thread'", 'symmetrical': 'False', 'to': "orm['threaded_messages.Message']"}),
+ 'creator': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'created_threads'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'latest_msg': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'thread_latest'", 'to': "orm['threaded_messages.Message']"}),
+ 'replied': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'subject': ('django.db.models.fields.CharField', [], {'max_length': '120'})
+ }
+ }
+
+ complete_apps = ['threaded_messages']
View
12 threaded_messages/models.py
@@ -67,7 +67,8 @@ class Message(models.Model):
body = models.TextField(_("body"))
sender = models.ForeignKey(User, related_name='sent_messages', blank=True, null=True, verbose_name=_("sender"))
parent_msg = models.ForeignKey('self', related_name='next_messages', blank=True, null=True, verbose_name=_("parent message"))
- sent_at = models.DateTimeField(_("sent at"), auto_now_add=True)
+ sent_at = models.DateTimeField(_("sent at"), auto_now_add=True,
+ db_index=True)
def __unicode__(self):
return "%s - %s" % (str(self.sender), self.sent_at)
@@ -114,9 +115,12 @@ class Participant(models.Model):
"""
thread = models.ForeignKey(Thread, related_name='participants', verbose_name=_("message thread"))
user = models.ForeignKey(User, related_name='threads', verbose_name=_("participant users"))
- read_at = models.DateTimeField(_("read at"), null=True, blank=True)
- replied_at = models.DateTimeField(_("replied at"), null=True, blank=True)
- deleted_at = models.DateTimeField(_("deleted at"), null=True, blank=True)
+ read_at = models.DateTimeField(_("read at"), null=True, blank=True,
+ db_index=True)
+ replied_at = models.DateTimeField(_("replied at"), null=True, blank=True,
+ db_index=True)
+ deleted_at = models.DateTimeField(_("deleted at"), null=True, blank=True,
+ db_index=True)
objects = MessageManager()

0 comments on commit 3c2e9f4

Please sign in to comment.
Something went wrong with that request. Please try again.