Skip to content

Commit

Permalink
Merge pull request #53 from nephila/hotfix/email_max_length
Browse files Browse the repository at this point in the history
Hotfix/email max length
  • Loading branch information
bee-keeper committed Nov 10, 2016
2 parents afe583a + ad9b4ed commit 86d78c5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ Bulk invites are supported via JSON. Post a list of comma separated emails to t

Used for custom integrations. Set this to `ACCOUNT_ADAPTER` if using django-allauth.

* `INVITATIONS_EMAIL_MAX_LENGTH` (default=`254`)

If set to `None` (the default), invitation email max length will be set up to 254. Set this to an integer value to set up a custome email max length value.

* `INVITATIONS_EMAIL_SUBJECT_PREFIX` (default=`None`)

If set to `None` (the default), invitation email subjects will be prefixed with the name of the current Site in brackets (such as `[example.com]`). Set this to a string to for a custom email subject prefix, or an empty string for no prefix.
Expand Down
7 changes: 7 additions & 0 deletions invitations/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def ADAPTER(self):
return self._setting(
'ADAPTER', 'invitations.adapters.BaseInvitationsAdapter')

@property
def EMAIL_MAX_LENGTH(self):
"""
Adjust max_length of e-mail addresses
"""
return self._setting("EMAIL_MAX_LENGTH", 254)

@property
def EMAIL_SUBJECT_PREFIX(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion invitations/migrations/0002_auto_20151126_0426.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from django.db import models, migrations
from django.conf import settings

EMAIL_MAX_LENGTH = getattr(settings, 'INVITATIONS_EMAIL_MAX_LENGTH', 254)



class Migration(migrations.Migration):

Expand All @@ -21,6 +24,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='invitation',
name='email',
field=models.EmailField(unique=True, max_length=254, verbose_name='e-mail address'),
field=models.EmailField(unique=True, max_length=EMAIL_MAX_LENGTH, verbose_name='e-mail address'),
),
]
3 changes: 2 additions & 1 deletion invitations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
@python_2_unicode_compatible
class Invitation(models.Model):

email = models.EmailField(unique=True, verbose_name=_('e-mail address'))
email = models.EmailField(unique=True, verbose_name=_('e-mail address'),
max_length=app_settings.EMAIL_MAX_LENGTH)
accepted = models.BooleanField(verbose_name=_('accepted'), default=False)
created = models.DateTimeField(verbose_name=_('created'),
default=timezone.now)
Expand Down

0 comments on commit 86d78c5

Please sign in to comment.