|
| 1 | +from django.urls import reverse_lazy |
| 2 | +from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView |
| 3 | +from profiles.models.sport_doctors import SportDoctor |
| 4 | +from profiles.forms.sport_doctors import SportDoctorForm |
| 5 | + |
| 6 | + |
| 7 | +class SportDoctorListView(ListView): |
| 8 | + """View for listing all sport doctors.""" |
| 9 | + model = SportDoctor |
| 10 | + template_name = "profiles/sport_doctor_list.html" |
| 11 | + context_object_name = "sport_doctor_list" |
| 12 | + |
| 13 | + |
| 14 | +class SportDoctorDetailView(DetailView): |
| 15 | + """View for displaying a single sport doctor.""" |
| 16 | + model = SportDoctor |
| 17 | + template_name = "profiles/sport_doctor_detail.html" |
| 18 | + context_object_name = "sport_doctor_detail" |
| 19 | + |
| 20 | + |
| 21 | +class SportDoctorCreateView(CreateView): |
| 22 | + """View for creating a new sport doctor.""" |
| 23 | + model = SportDoctor |
| 24 | + form_class = SportDoctorForm |
| 25 | + template_name = "profiles/sport_doctor_form.html" |
| 26 | + success_url = reverse_lazy("sport_doctor_list") |
| 27 | + |
| 28 | + |
| 29 | +class SportDoctorUpdateView(UpdateView): |
| 30 | + """View for updating a sport doctor.""" |
| 31 | + model = SportDoctor |
| 32 | + form_class = SportDoctorForm |
| 33 | + template_name = "profiles/sport_doctor_form.html" |
| 34 | + |
| 35 | + def get_success_url(self): |
| 36 | + return reverse_lazy("sport_doctor_detail", kwargs={"pk": self.object.pk}) |
| 37 | + |
| 38 | + |
| 39 | +class SportDoctorDeleteView(DeleteView): |
| 40 | + """View for deleting a sport doctor.""" |
| 41 | + model = SportDoctor |
| 42 | + template_name = "profiles/sport_doctor_confirm_delete.html" |
| 43 | + success_url = reverse_lazy("sport_doctor_list") |
0 commit comments