From 619865129ae688f41a2d8fcf5a8f592e59c48a09 Mon Sep 17 00:00:00 2001 From: pnshiralkar Date: Wed, 29 Apr 2020 12:08:27 +0530 Subject: Refractor models done, modified some views and forms --- workshop_app/admin.py | 2 +- workshop_app/models.py | 9 ++++----- workshop_app/templates/workshop_app/my_workshops.html | 6 +++--- workshop_app/views.py | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'workshop_app') diff --git a/workshop_app/admin.py b/workshop_app/admin.py index 8a0a8c5..4e3d333 100644 --- a/workshop_app/admin.py +++ b/workshop_app/admin.py @@ -83,7 +83,7 @@ class WorkshopTypeAdmin(admin.ModelAdmin): writer.writerow(['name', 'duration']) for q in queryset: - writer.writerow([q.name, q.workshoptype_duration]) + writer.writerow([q.name, q.duration]) openfile.seek(0) response.write(openfile.read()) diff --git a/workshop_app/models.py b/workshop_app/models.py index 04aabca..b35d9a7 100644 --- a/workshop_app/models.py +++ b/workshop_app/models.py @@ -162,12 +162,11 @@ class Workshop(models.Model): on_delete=models.CASCADE) workshop_type = models.ForeignKey(WorkshopType, on_delete=models.CASCADE, help_text='Select the type of workshop.') date = models.DateField() - # status = models.CharField(max_length=32, default="Pending") - status_choices = [(0, 'Pending'), + STATUS_CHOICES = [(0, 'Pending'), (1, 'Accepted'), (2, 'Deleted')] - status = models.IntegerField(choices=status_choices, default=0) + status = models.IntegerField(choices=STATUS_CHOICES, default=0) tnc_accepted = models.BooleanField(help_text="I accept the terms and conditions") def __str__(self): @@ -176,11 +175,11 @@ class Workshop(models.Model): self.workshop_type, self.coordinator, self.instructor, - self.status_choices[self.status][1] + self.STATUS_CHOICES[self.status][1] ) def get_status(self): - return str(self.status_choices[self.status][1]) + return str(self.STATUS_CHOICES[self.status][1]) class Testimonial(models.Model): diff --git a/workshop_app/templates/workshop_app/my_workshops.html b/workshop_app/templates/workshop_app/my_workshops.html index 735e6b5..ed79934 100644 --- a/workshop_app/templates/workshop_app/my_workshops.html +++ b/workshop_app/templates/workshop_app/my_workshops.html @@ -221,7 +221,7 @@ {% for workshop in workshops %}