diff options
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/__init__.py | 1 | ||||
-rw-r--r-- | users/models/invite.py | 30 | ||||
-rw-r--r-- | users/models/password_reset.py | 2 |
3 files changed, 32 insertions, 1 deletions
diff --git a/users/models/__init__.py b/users/models/__init__.py index e46860e..fc0d402 100644 --- a/users/models/__init__.py +++ b/users/models/__init__.py @@ -3,6 +3,7 @@ from .domain import Domain # noqa from .follow import Follow, FollowStates # noqa from .identity import Identity, IdentityStates # noqa from .inbox_message import InboxMessage, InboxMessageStates # noqa +from .invite import Invite # noqa from .password_reset import PasswordReset # noqa from .user import User # noqa from .user_event import UserEvent # noqa diff --git a/users/models/invite.py b/users/models/invite.py new file mode 100644 index 0000000..5d69b18 --- /dev/null +++ b/users/models/invite.py @@ -0,0 +1,30 @@ +import random + +from django.db import models + + +class Invite(models.Model): + """ + An invite token, good for one signup. + """ + + # Should always be lowercase + token = models.CharField(max_length=500, unique=True) + + # Is it limited to a specific email? + email = models.EmailField(null=True, blank=True) + + # Admin note about this code + note = models.TextField(null=True, blank=True) + + created = models.DateTimeField(auto_now_add=True) + updated = models.DateTimeField(auto_now=True) + + @classmethod + def create_random(cls, email=None): + return cls.objects.create( + token="".join( + random.choice("abcdefghkmnpqrstuvwxyz23456789") for i in range(20) + ), + email=email, + ) diff --git a/users/models/password_reset.py b/users/models/password_reset.py index 90062d3..628efa6 100644 --- a/users/models/password_reset.py +++ b/users/models/password_reset.py @@ -27,7 +27,7 @@ class PasswordResetStates(StateGraph): await sync_to_async(send_mail)( subject=f"{Config.system.site_name}: Confirm new account", message=render_to_string( - "emails/new_account.txt", + "emails/account_new.txt", { "reset": reset, "config": Config.system, |