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

Сделал вывод уроков в курсах

parent dd71938d
...@@ -22,5 +22,6 @@ urlpatterns = [ ...@@ -22,5 +22,6 @@ urlpatterns = [
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'), path('course/<int:pk>/delete/', webapp_views.CourseDeleteView.as_view(), name='course_delete'),
path('course/new/', webapp_views.CourseCreateView.as_view(), name='course_create') path('course/new/', webapp_views.CourseCreateView.as_view(), name='course_create'),
path('course/<int:pk>/edit/', webapp_views.CourseEditView.as_view(), name='course_edit')
] ]
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</div> </div>
<div class="card-buttons" style="text-align: center;"> <div class="card-buttons" style="text-align: center;">
<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-info" href="#"> Edit </a> <a class="btn btn-info" href="{% url 'course_edit' course.id %}"> Edit </a>
<a class="btn btn-danger" href="{% url 'course_delete' course.id %}"> Delete </a> <a class="btn btn-danger" href="{% url 'course_delete' course.id %}"> Delete </a>
</div> </div>
</div> </div>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<a href="{% url "courses_list" %}"> << Return to the main page..</a> <a href="{% url "courses_list" %}"> << Return to the main page..</a>
<hr> <hr>
<div class='course-block-detail'> <div class='course-block-detail'>
<div class="card"> <div class="card" style="width: 100%; height: 400px;">
<div class="card-header"> <div class="card-header">
<h4>{{course.title}}</h4> <h4>{{course.title}}</h4>
</div> </div>
...@@ -20,6 +20,18 @@ ...@@ -20,6 +20,18 @@
</div> </div>
</div> </div>
</div> </div>
{% for class in course.courses.all %}
<div class="card border-dark mb-3" style="max-width: 100%; height: 200px; margin: 15px auto;">
<div class="card-header">
<p> <b>Created at:</b> {{ class.created_at }} - <b>by:</b> {{ course.teacher }}</p>
</div>
<div class="card-body text-dark">
<h5 class="card-title">Topic: {{ class.title }} </h5>
<p class="card-text"> Description: {{ class.description|truncatewords:5 }} </p>
{{ class.file }}
</div>
</div>
{% endfor %}
<hr> <hr>
<a href="{% url "courses_list" %}"> << Return to the main page..</a> <a href="{% url "courses_list" %}"> << Return to the main page..</a>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% load crispy_forms_filters %}
{% block title %} Edit Course {% endblock %}
{% block content %}
<a href="{% url "courses_list" %}">Return to the main page..</a>
<hr>
<h1>Edit course "{{ course.title }}"</h1>
<div class='column-center'>
<form method="POST">
{% csrf_token %}
{{ form|crispy }}
</form>
</div>
<hr>
<a href="{% url "courses_list" %}">Return to the main page..</a>
{% endblock %}
from typing import List from django.shortcuts import get_object_or_404, render
from django.shortcuts import render from django.urls.base import reverse, reverse_lazy
from django.urls.base import reverse_lazy from django.views.generic import ListView, CreateView, DetailView, DeleteView
from django.views.generic import ListView, CreateView, UpdateView, DetailView, DeleteView from django.views.generic import UpdateView
from webapp.models import Course from webapp.models import Course
...@@ -39,4 +39,7 @@ class CourseDeleteView(DeleteView): ...@@ -39,4 +39,7 @@ class CourseDeleteView(DeleteView):
class CourseEditView(UpdateView): class CourseEditView(UpdateView):
pass model = Course
\ No newline at end of file fields = ['title', 'description', 'start_date']
template_name = 'courses/edit.html'
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