-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add records to db when email is sent
- Loading branch information
1 parent
46d1fd1
commit 4d07471
Showing
4 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 5.1.1 on 2024-09-21 20:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0043_delete_cachedboard"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="EmailLogRecord", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("subject", models.CharField(max_length=128)), | ||
("email", models.CharField(max_length=128)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from fbsurvivor import settings | ||
from fbsurvivor.core.models import Player | ||
from fbsurvivor.core.utils.emails import send_email | ||
|
||
|
||
class PlayerService: | ||
@staticmethod | ||
def create(username: str, email: str): | ||
player, created = Player.objects.get_or_create(username=username, email=email) | ||
|
||
if created: | ||
ps = f"If you didn't sign up, please email Dan at {settings.CONTACT}" | ||
login = f"{settings.DOMAIN}" | ||
subject = "Survivor User Account" | ||
recipients = [email] | ||
message = f"You can login here:\n\n{login}\n\n{ps}" | ||
|
||
send_email(subject, recipients, message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters