summaryrefslogtreecommitdiffstats
path: root/users/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-18 00:09:04 -0700
committerAndrew Godwin2022-11-18 00:09:04 -0700
commit1b44a253316a84f40070264ea8134c86d1223441 (patch)
tree2caa56d54a8e81f14649b826f9f3ef5a7c1326ae /users/models
parentb3072c81ba73a16381366960841b6c294cc1fa6e (diff)
downloadtakahe-1b44a253316a84f40070264ea8134c86d1223441.tar.gz
takahe-1b44a253316a84f40070264ea8134c86d1223441.tar.bz2
takahe-1b44a253316a84f40070264ea8134c86d1223441.zip
Signup and invite tweaks
Diffstat (limited to 'users/models')
-rw-r--r--users/models/__init__.py1
-rw-r--r--users/models/invite.py30
-rw-r--r--users/models/password_reset.py2
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,