-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
email flows for reputation audits, also some admin QOL
- Loading branch information
1 parent
5aacbc7
commit c26103d
Showing
12 changed files
with
274 additions
and
35 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
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
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
64 changes: 64 additions & 0 deletions
64
pods/migrations/0027_alter_education_user_reputationaudit.py
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,64 @@ | ||
# Generated by Django 4.2.6 on 2023-12-31 21:06 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("pods", "0026_regioninfo_user"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="education", | ||
name="user", | ||
field=models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="education", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="ReputationAudit", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("performed_on", models.DateTimeField(auto_now_add=True)), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"latest_reputation", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="audits", | ||
to="pods.reputationdetails", | ||
), | ||
), | ||
( | ||
"performed_by", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="reputation_audits_performed", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="reputation_audits", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
36 changes: 36 additions & 0 deletions
36
pods/migrations/0028_alter_reputationdetails_options_and_more.py
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,36 @@ | ||
# Generated by Django 4.2.6 on 2023-12-31 21:38 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("pods", "0027_alter_education_user_reputationaudit"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="reputationdetails", | ||
options={"verbose_name_plural": "Reputation details"}, | ||
), | ||
migrations.AlterField( | ||
model_name="reputationaudit", | ||
name="performed_by", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="reputation_audits_performed", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="reputationaudit", | ||
name="performed_on", | ||
field=models.DateTimeField( | ||
blank=True, help_text="When the audit was performed", null=True | ||
), | ||
), | ||
] |
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,43 @@ | ||
import logging | ||
|
||
from pods.models import ReputationAudit, User | ||
|
||
|
||
from django.core.mail import EmailMultiAlternatives | ||
from django.conf import settings | ||
|
||
|
||
from django.template.loader import render_to_string | ||
from django.utils.html import strip_tags | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def notify_user_that_audit_is_complete( | ||
user: User, audit: ReputationAudit | ||
): | ||
profile_url = f"{settings.FRONTEND_URL}/members/{user.id}/" | ||
html_message = render_to_string( | ||
"reputation/audit_completion_notification.html", | ||
{ | ||
"user": user, | ||
"audit": audit, | ||
"profile_url": profile_url, | ||
}, | ||
) | ||
plain_message = strip_tags(html_message) | ||
from_email = "Open Insure <noreply@openinsure.app>" | ||
to = user.email | ||
subject = f"Audit Completed" | ||
|
||
message = EmailMultiAlternatives( | ||
subject, | ||
plain_message, | ||
to=[to], | ||
from_email=from_email, | ||
reply_to=[settings.ADMIN_EMAIL], | ||
) | ||
message.attach_alternative(html_message, "text/html") | ||
|
||
message.send() |
Oops, something went wrong.