-
Notifications
You must be signed in to change notification settings - Fork 9
React ts - Mailer models #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: react-ts
Are you sure you want to change the base?
React ts - Mailer models #212
Conversation
| status = models.CharField( | ||
| max_length=20, | ||
| choices=[ | ||
| ('pending'), | ||
| ('sent',), | ||
| ('failed',), | ||
| ], | ||
| default='pending' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define choices in tuple, and then use it in choices.
STATUS_CHOICES = [
('pending', 'Pending'),
('sent', 'Sent'),
('failed', 'Failed'),
]
| Stores individual email addresses and their sending status. | ||
| Each row corresponds to one email address from the uploaded CSV file. | ||
| """ | ||
| email_address = models.EmailField(unique=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unique constrained as multiple mails can be sent to the same email
| related_name='email_contents' | ||
| ) | ||
| created_at = models.DateTimeField(auto_now_add=True) | ||
| user_id = models.ForeignKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field name should be user, not user_id. Django automatically creates _id in the database column.
| ) | ||
| created_at = models.DateTimeField(auto_now_add=True) | ||
| user_id = models.ForeignKey( | ||
| 'auth.User', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import explicitly
from django.contrib.auth.models import User
and then user User as fk
| Stores individual email addresses and their sending status. | ||
| Each row corresponds to one email address from the uploaded CSV file. | ||
| """ | ||
| email_address = models.EmailField(unique=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding for faster lookups by email.:
class Meta:
indexes = [models.Index(fields=['email_address'])]
…ployer-Recommendation-System into react-ts Updating changes
Added two models in the mailer app. The structure of the models are listed below:
EmailRecord:
id = auto generated
email_address = charater
created_at = DateTimeField(auto_now_add=True)
status = CharField(max_length=20, choices=[('pending'), ('sent',), ('failed',), ], default='pending') # status of the mail
sent_at = DateTimeField(null=True, blank=True)
error_message = extField(null=True, blank=True) # optional for better error handling
EmailContent:
id = auto generated
subject = CharField(max_length=255)
mail_body = TextField()
email_records = ManyToManyField( EmailRecord,) #Foreign key for EmailRecord table
created_at = DateTimeField(auto_now_add=True)
user_id = ForeignKey( 'auth.User', on_delete=models.CASCADE,) #Foreign key for auth users