diff options
author | pnshiralkar | 2020-04-29 12:08:27 +0530 |
---|---|---|
committer | pnshiralkar | 2020-04-29 12:08:27 +0530 |
commit | 619865129ae688f41a2d8fcf5a8f592e59c48a09 (patch) | |
tree | c18864a7ced9daf872084cdbb6403d52773b7cf6 /workshop_app | |
parent | 1c2d985348f11d35c915c193f8b514a0445b6723 (diff) | |
download | workshop_booking-619865129ae688f41a2d8fcf5a8f592e59c48a09.tar.gz workshop_booking-619865129ae688f41a2d8fcf5a8f592e59c48a09.tar.bz2 workshop_booking-619865129ae688f41a2d8fcf5a8f592e59c48a09.zip |
Refractor models done, modified some views and forms
Diffstat (limited to 'workshop_app')
-rw-r--r-- | workshop_app/admin.py | 2 | ||||
-rw-r--r-- | workshop_app/models.py | 9 | ||||
-rw-r--r-- | workshop_app/templates/workshop_app/my_workshops.html | 6 | ||||
-rw-r--r-- | workshop_app/views.py | 6 |
4 files changed, 11 insertions, 12 deletions
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 %} <tbody> <tr> - {% if workshop.status == 'ACCEPTED' and workshop.title %} + {% if workshop.status == 1 and workshop.workshop_type %} {% if request.user.profile.position == 'instructor' %} <td><a href="{{ URL_ROOT }}/view_comment_profile/{{ workshop.coordinator.profile.user.id }}"> {{ workshop.coordinator.get_full_name }}</a></td> @@ -249,9 +249,9 @@ {% else %} <td>{{ workshop.date | date }}</td> {% endif %} - <td><span class = "label label-success">{{ workshop.status }}</span></td> + <td><span class = "label label-success">{{ workshop.get_status }}</span></td> {% endif %} - {% if workshop.status == 'ACCEPTED' and workshop.condition_one %} + {% if workshop.status == 1 and workshop.condition_one %} {% if request.user.profile.position == 'instructor' %} <td><a href="{{ URL_ROOT }}/view_comment_profile/{{ workshop.coordinator.profile.user.id }}"> {{ workshop.coordinator.get_full_name }}</a></td> diff --git a/workshop_app/views.py b/workshop_app/views.py index b2ce129..ac8fff3 100644 --- a/workshop_app/views.py +++ b/workshop_app/views.py @@ -445,7 +445,7 @@ def my_workshops(request): if action == 'accept' or action == 'approve': workshop_status = Workshop.objects.get(id=client_data.get('workshop_id')) # Change Status of the selected workshop - workshop_status.status = 'ACCEPTED' + workshop_status.status = 1 workshop_status.instructor = user workshop_status.save() ws = workshop_status @@ -455,7 +455,7 @@ def my_workshops(request): cnum = ws.coordinator.profile.phone_number cinstitute = ws.coordinator.profile.institute inum = request.user.profile.phone_number - wtitle = ws.title.name + wtitle = ws.workshop_type.name workshop_date = str(ws.date) # For Instructor @@ -512,7 +512,7 @@ def my_workshops(request): ).order_by('-date') proposed_workshop_pending = Workshop.objects.filter( - status='Pending' + status=0 ).order_by('-date') workshops = list(proposed_workshop) + list(proposed_workshop_pending) |