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

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

parent 84c0bc89
......@@ -20,5 +20,6 @@ from webapp.views import courses_views as webapp_views
urlpatterns = [
path('admin/', admin.site.urls),
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')
]
......@@ -14,6 +14,7 @@
<h5 class="card-title"> {{course.title}} </h5>
<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-danger" href="{% url 'course_delete' course.id %}"> Delete </a>
</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 @@
<div class='course-block-detail'>
<div class="card">
<div class="card-header">
{{course.title}}
<h4>{{course.title}}</h4>
</div>
<div class="card-body">
<blockquote class="blockquote mb-0">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer>
<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.
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>
</div>
</div>
......
from typing import List
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
......@@ -16,3 +18,11 @@ class CourseDetailView(DetailView):
model = Course
template_name = 'courses/detail.html'
pk_url_kwarg = 'course_pk'
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