Skip to content

Commit

Permalink
add method for autocomplete grapelli feature and add fields for keep …
Browse files Browse the repository at this point in the history
…id and data for conversion
  • Loading branch information
simodalla committed May 25, 2015
1 parent bbebab1 commit 9107ac3
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 22 deletions.
24 changes: 24 additions & 0 deletions custom_email_user/migrations/0002_auto_20150525_1531.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('custom_email_user', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='emailuser',
name='id_for_conversion_1',
field=models.IntegerField(null=True, blank=True),
),
migrations.AddField(
model_name='emailuser',
name='id_for_conversion_2',
field=models.IntegerField(null=True, blank=True),
),
]
24 changes: 24 additions & 0 deletions custom_email_user/migrations/0003_auto_20150525_1535.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('custom_email_user', '0002_auto_20150525_1531'),
]

operations = [
migrations.AddField(
model_name='emailuser',
name='username_for_conversion_1',
field=models.CharField(blank=True, max_length=254),
),
migrations.AddField(
model_name='emailuser',
name='username_for_conversion_2',
field=models.CharField(blank=True, max_length=254),
),
]
13 changes: 12 additions & 1 deletion custom_email_user/models.py
Expand Up @@ -32,6 +32,10 @@ class EmailUser(AbstractBaseUser, PermissionsMixin):
help_text=_('Designates whether this user should be treated as '
'active. Unselect this instead of deleting accounts.'))
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
id_for_conversion_1 = models.IntegerField(blank=True, null=True)
username_for_conversion_1 = models.CharField(max_length=254, blank=True)
id_for_conversion_2 = models.IntegerField(blank=True, null=True)
username_for_conversion_2 = models.CharField(max_length=254, blank=True)

objects = EmailUserManager()

Expand All @@ -55,7 +59,7 @@ def get_full_name(self):
return full_name.strip()

def __str__(self):
return self.get_full_name()
return self.email

def get_short_name(self):
"""Returns the short name for the user."""
Expand All @@ -70,3 +74,10 @@ def email_user(self, subject, message, from_email=None):
Sends an email to this User.
"""
return send_mail(subject, message, from_email, [self.email])

@staticmethod
def autocomplete_search_fields():
"""
Grapelli autocomplete method.
"""
return ['id__iexact', 'email__icontains']
Empty file.
21 changes: 0 additions & 21 deletions custom_email_user/templates/custom_email_user/base.html

This file was deleted.

0 comments on commit 9107ac3

Please sign in to comment.