Commit 0c285252 authored by Борис Ким's avatar Борис Ким

Добавил вью для удаления курса

parent 84c0bc89
...@@ -20,5 +20,6 @@ from webapp.views import courses_views as webapp_views ...@@ -20,5 +20,6 @@ from webapp.views import courses_views as webapp_views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', webapp_views.CoursesListView.as_view(), name='courses_list'), path('', webapp_views.CoursesListView.as_view(), name='courses_list'),
path('course/<int:course_pk>/', webapp_views.CourseDetailView.as_view(), name='course_detail') path('course/<int:course_pk>/', webapp_views.CourseDetailView.as_view(), name='course_detail'),
path('course/<int:pk>/delete', webapp_views.CourseDeleteView.as_view(), name='course_delete')
] ]
...@@ -57,4 +57,4 @@ body { ...@@ -57,4 +57,4 @@ body {
background-color: white; background-color: white;
width: 310px; width: 310px;
height: 300px; height: 300px;
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<h5 class="card-title"> {{course.title}} </h5> <h5 class="card-title"> {{course.title}} </h5>
<p class="card-text"> {{course.description}} </p> <p class="card-text"> {{course.description}} </p>
<a class="btn btn-primary" href="{% url 'course_detail' course.id %}"> See more </a> <a class="btn btn-primary" href="{% url 'course_detail' course.id %}"> See more </a>
<a class="btn btn-danger" href="{% url 'course_delete' course.id %}"> Delete </a>
</div> </div>
</div> </div>
</div> </div>
......
{% extends "base.html" %}
{% block title %}Delete {{ course.title }}{% endblock %}
{% block content %}
<h2>Are you sure you want to delete course - {{ course.title}} ?</h2>
<a href="{% url "courses_list" %}">Cancel</a>
<form action='' method="post">
{% csrf_token %}
<button>Yes</button>
</form>
{% endblock %}
...@@ -6,12 +6,15 @@ ...@@ -6,12 +6,15 @@
<div class='course-block-detail'> <div class='course-block-detail'>
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
{{course.title}} <h4>{{course.title}}</h4>
</div> </div>
<div class="card-body"> <div class="card-body">
<blockquote class="blockquote mb-0"> <blockquote class="blockquote mb-0">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p> <p>Gain the job-ready skills you need to launch your career in IT Support, Data Analytics, UX Design or Project Management. Prepare for an entry-level job as a data analyst.
<footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer> In this program, you’ll learn how to collect, transform, and organize data in order to help draw new insights and make informed business decisions.
This is for you if you enjoy working with numbers, uncovering trends, and visualizations.
</p>
<footer class="blockquote-footer"> Pr. {{course.teacher}} </footer>
</blockquote> </blockquote>
</div> </div>
</div> </div>
......
from typing import List from typing import List
from django.shortcuts import render from django.shortcuts import render
from django.views.generic import ListView, CreateView, DeleteView, UpdateView, DetailView from django.urls.base import reverse_lazy
from django.views.generic import ListView, CreateView, UpdateView, DetailView, DeleteView
from webapp.models import Course from webapp.models import Course
...@@ -15,4 +17,12 @@ class CoursesListView(ListView): ...@@ -15,4 +17,12 @@ class CoursesListView(ListView):
class CourseDetailView(DetailView): class CourseDetailView(DetailView):
model = Course model = Course
template_name = 'courses/detail.html' template_name = 'courses/detail.html'
pk_url_kwarg = 'course_pk' pk_url_kwarg = 'course_pk'
\ No newline at end of file
class CourseDeleteView(DeleteView):
model = Course
template_name = 'courses/delete.html'
success_url = reverse_lazy('courses_list')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment