Skip to content

Commit

Permalink
Removed ticket mail log from ticket model
Browse files Browse the repository at this point in the history
  • Loading branch information
Suryansh5545 committed Aug 5, 2023
1 parent 999bf0b commit 3d5ffd8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
9 changes: 8 additions & 1 deletion apps/ticket/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ def get_list_display(self, request):

admin.site.register(Ticket, TicketAdmin)
admin.site.register(CheckIn)
admin.site.register(TicketEmailLog)


class TicketEmailLogAdmin(ImportExportModelAdmin):
list_display = ('id', 'ticket', 'email_sent_time',)
search_fields = ('id', 'ticket')


admin.site.register(TicketEmailLog, TicketEmailLogAdmin)
17 changes: 17 additions & 0 deletions apps/ticket/migrations/0003_remove_ticket_ticket_mail_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.3 on 2023-08-05 10:37

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('ticket', '0002_ticket_referral'),
]

operations = [
migrations.RemoveField(
model_name='ticket',
name='ticket_mail_log',
),
]
1 change: 0 additions & 1 deletion apps/ticket/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Ticket(models.Model):
ticket_image_generated = models.BooleanField(default=False)
ticket_image_location = models.TextField(default="", null=True, blank=True)
order_id = models.CharField(max_length=100, default="", unique=True, null=True)
ticket_mail_log = models.ManyToManyField('TicketEmailLog', related_name='tickets', blank=True)
transaction_id = models.OneToOneField(Transaction, on_delete=models.CASCADE, null=True, blank=True, unique=True)
referral = models.CharField(max_length=100, null=True, blank=True)

Expand Down
3 changes: 1 addition & 2 deletions apps/ticket/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def send_ticket(ticket_id):

# Send the email
email.send()
ticket_send_log = TicketEmailLog.objects.create(ticket=ticket, email_sent_time=timezone.now())
ticket.ticket_mail_log.set([ticket_send_log])
TicketEmailLog.objects.create(ticket=ticket, email_sent_time=timezone.now())
ticket.save()
return True

Expand Down

0 comments on commit 3d5ffd8

Please sign in to comment.