Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coursework
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Борис Ким
coursework
Commits
33ec296f
Commit
33ec296f
authored
Nov 02, 2021
by
Борис Ким
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Сделал ссылки удобней, добавил вью для создания нового урока или недели в курсе
parent
bfb154c2
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
99 additions
and
27 deletions
+99
-27
urls.py
source/portal/urls.py
+3
-7
forms.py
source/webapp/forms.py
+8
-2
base.html
source/webapp/templates/base.html
+2
-2
create.html
source/webapp/templates/classes/create.html
+16
-0
delete.html
source/webapp/templates/classes/delete.html
+0
-0
detail.html
source/webapp/templates/classes/detail.html
+0
-0
edit.html
source/webapp/templates/classes/edit.html
+0
-0
courses_list.html
source/webapp/templates/courses/courses_list.html
+3
-3
create.html
source/webapp/templates/courses/create.html
+2
-2
delete.html
source/webapp/templates/courses/delete.html
+1
-1
detail.html
source/webapp/templates/courses/detail.html
+11
-6
edit.html
source/webapp/templates/courses/edit.html
+2
-2
create_form.html
source/webapp/templates/partial/create_form.html
+1
-1
urls.py
source/webapp/urls.py
+14
-0
__init__.py
source/webapp/views/__init__.py
+2
-0
classes_views.py
source/webapp/views/classes_views.py
+33
-0
courses_views.py
source/webapp/views/courses_views.py
+1
-1
No files found.
source/portal/urls.py
View file @
33ec296f
...
...
@@ -14,14 +14,10 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.contrib
import
admin
from
django.urls
import
path
from
webapp.views
import
courses_views
as
webapp_views
from
django.urls
import
path
,
include
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:pk>/delete/'
,
webapp_views
.
CourseDeleteView
.
as_view
(),
name
=
'course_delete'
),
path
(
'course/new/'
,
webapp_views
.
CourseCreateView
.
as_view
(),
name
=
'course_create'
),
path
(
'course/<int:pk>/edit/'
,
webapp_views
.
CourseEditView
.
as_view
(),
name
=
'course_edit'
)
path
(
''
,
include
(
'webapp.urls'
)),
]
source/webapp/forms.py
View file @
33ec296f
from
django
import
forms
from
.models
import
Course
from
.models
import
Course
,
Class
class
CourseForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Course
fields
=
[
'title'
,
'description'
,
'group'
,
'teacher'
,
'start_date'
]
\ No newline at end of file
fields
=
[
'title'
,
'description'
,
'group'
,
'teacher'
,
'start_date'
]
class
ClassForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Class
fields
=
[
'title'
,
'description'
,
'file'
]
\ No newline at end of file
source/webapp/templates/base.html
View file @
33ec296f
...
...
@@ -13,7 +13,7 @@
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-dark bg-dark"
>
<a
class=
"navbar-brand"
href=
"
#
"
>
Navbar
</a>
<a
class=
"navbar-brand"
href=
"
{% url 'webapp:courses_list' %}
"
>
Navbar
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarNav"
aria-controls=
"navbarNav"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
...
...
@@ -36,7 +36,7 @@
</nav>
<div
class=
"row d-flex"
>
<div
class=
"sidebar col-2"
>
<a
href=
"{% url 'course_create' %}"
>
Create new Course
</a>
<a
href=
"{% url '
webapp:
course_create' %}"
>
Create new Course
</a>
<a
href=
"#services"
>
Button 1
</a>
<a
href=
"#clients"
>
Button 2
</a>
<a
href=
"#contact"
>
Button 3
</a>
...
...
source/webapp/templates/classes/create.html
0 → 100644
View file @
33ec296f
{% extends "base.html" %}
{% block title %} Create new Class {% endblock %}
{% block content %}
<a
href=
"{% url "
courses_list
"
%}"
>
Return to the main page..
</a>
<hr>
<h1>
Create new Class
</h1>
<div
class=
'column-center'
>
<form
action=
"{% url "
class_create
"
%}"
method=
"POST"
>
{% include "partial/create_form.html" with button_text="Create new class" %}
</form>
</div>
<hr>
<a
href=
"{% url "
courses_list
"
%}"
>
Return to the main page..
</a>
{% endblock %}
\ No newline at end of file
source/webapp/templates/classes/delete.html
0 → 100644
View file @
33ec296f
source/webapp/templates/classes/detail.html
0 → 100644
View file @
33ec296f
source/webapp/templates/classes/edit.html
0 → 100644
View file @
33ec296f
source/webapp/templates/courses/courses_list.html
View file @
33ec296f
...
...
@@ -15,9 +15,9 @@
<p
class=
"card-text"
>
{{course.description}}
</p>
</div>
<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-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-primary"
href=
"{% url '
webapp:
course_detail' course.id %}"
>
See more
</a>
<a
class=
"btn btn-info"
href=
"{% url '
webapp:
course_edit' course.id %}"
>
Edit
</a>
<a
class=
"btn btn-danger"
href=
"{% url '
webapp:
course_delete' course.id %}"
>
Delete
</a>
</div>
</div>
</div>
...
...
source/webapp/templates/courses/create.html
View file @
33ec296f
...
...
@@ -3,11 +3,11 @@
{% block title %} Create new Course {% endblock %}
{% block content %}
<a
href=
"{% url "
courses_list
"
%}"
>
Return to the main page..
</a>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
Return to the main page..
</a>
<hr>
<h1>
Create new Course
</h1>
<div
class=
'column-center'
>
<form
action=
"{% url "
course_create
"
%}"
method=
"POST"
>
<form
action=
"{% url "
webapp:
course_create
"
%}"
method=
"POST"
>
{% include "partial/create_form.html" with button_text="Create new course" %}
</form>
</div>
...
...
source/webapp/templates/courses/delete.html
View file @
33ec296f
...
...
@@ -4,7 +4,7 @@
{% block content %}
<h2>
Are you sure you want to delete course - {{ course.title}} ?
</h2>
<a
href=
"{% url "
courses_list
"
%}"
>
Cancel
</a>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
Cancel
</a>
<form
action=
''
method=
"post"
>
{% csrf_token %}
<button>
Yes
</button>
...
...
source/webapp/templates/courses/detail.html
View file @
33ec296f
...
...
@@ -3,7 +3,7 @@
{% block title %} {{course.title}} {% endblock %}
{% block content %}
<a
href=
"{% url "
courses_list
"
%}"
>
<
<
Return
to
the
main
page
..</
a
>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
<
<
Return
to
the
main
page
..</
a
>
<hr>
<div
class=
'course-block-detail'
>
<div
class=
"card"
style=
"width: 100%; height: 400px;"
>
...
...
@@ -18,20 +18,25 @@
<footer
class=
"blockquote-footer"
>
Pr. {{course.teacher}}
</footer>
</blockquote>
</div>
<div
style=
"width: 100px; height: 50px;"
>
<a
href=
"{% url "
webapp:class_create
"
%}"
>
Create new week
</a>
</div>
</div>
</div>
{% for class in course.courses.all %}
<div
class=
"card border-dark mb-3"
style=
"max-width: 100%; height: 2
0
0px; margin: 15px auto;"
>
<div
class=
"card border-dark mb-3"
style=
"max-width: 100%; height: 2
4
0px; margin: 15px auto;"
>
<div
class=
"card-header"
>
<
p>
<b>
Created at:
</b>
{{ class.created_at }} -
<b>
by:
</b>
{{ course.teacher }}
</p>
<
h6
style=
"color: #3A63A7;"
>
Week #{{forloop.counter}}
</h6>
</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 }}
<p
class=
"card-text"
>
Description: {{ class.description|truncatewords:30 }}
</p>
{{ class.file }}
<hr>
<p>
<b>
Created at:
</b>
{{ class.created_at }} -
<b>
by:
</b>
{{ course.teacher }}
</p>
</div>
</div>
{% endfor %}
<hr>
<a
href=
"{% url "
courses_list
"
%}"
>
<
<
Return
to
the
main
page
..</
a
>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
<
<
Return
to
the
main
page
..</
a
>
{% endblock %}
\ No newline at end of file
source/webapp/templates/courses/edit.html
View file @
33ec296f
...
...
@@ -4,7 +4,7 @@
{% block title %} Edit Course {% endblock %}
{% block content %}
<a
href=
"{% url "
courses_list
"
%}"
>
Return to the main page..
</a>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
Return to the main page..
</a>
<hr>
<h1>
Edit course "{{ course.title }}"
</h1>
<div
class=
'column-center'
>
...
...
@@ -14,6 +14,6 @@
</form>
</div>
<hr>
<a
href=
"{% url "
courses_list
"
%}"
>
Return to the main page..
</a>
<a
href=
"{% url "
webapp:
courses_list
"
%}"
>
Return to the main page..
</a>
{% endblock %}
source/webapp/templates/partial/create_form.html
View file @
33ec296f
...
...
@@ -12,4 +12,4 @@
{% endfor %}
{% endfor %}
<p>
{{ form|crispy }}
</p>
<button>
{{ button_text }}
</button>
<button
class=
"btn btn-primary"
>
{{ button_text }}
</button>
source/webapp/urls.py
0 → 100644
View file @
33ec296f
from
django.urls
import
path
from
webapp
import
views
as
webapp_views
app_name
=
"webapp"
urlpatterns
=
[
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:pk>/delete/'
,
webapp_views
.
CourseDeleteView
.
as_view
(),
name
=
'course_delete'
),
path
(
'course/new/'
,
webapp_views
.
CourseCreateView
.
as_view
(),
name
=
'course_create'
),
path
(
'course/<int:pk>/edit/'
,
webapp_views
.
CourseEditView
.
as_view
(),
name
=
'course_edit'
),
path
(
'courses/class/new'
,
webapp_views
.
CreateClassView
.
as_view
(),
name
=
'class_create'
)
]
\ No newline at end of file
source/webapp/views/__init__.py
0 → 100644
View file @
33ec296f
from
.classes_views
import
*
from
.courses_views
import
*
\ No newline at end of file
source/webapp/views/classes_views.py
0 → 100644
View file @
33ec296f
from
django.shortcuts
import
get_object_or_404
,
redirect
from
django.urls.base
import
reverse
,
reverse_lazy
from
django.views.generic
import
CreateView
,
DetailView
,
DeleteView
from
django.views.generic
import
UpdateView
from
webapp.models
import
Class
,
Course
from
webapp.forms
import
ClassForm
class
CreateClassView
(
CreateView
):
model
=
Class
fields
=
[
'title'
,
'description'
,
'file'
]
template_name
=
'courses/create.html'
def
form_valid
(
self
,
form
):
course_pk
=
self
.
kwargs
.
get
(
'pk'
)
course
=
get_object_or_404
(
Course
,
pk
=
course_pk
)
classweek
=
form
.
save
(
commit
=
False
)
classweek
.
course
=
classweek
classweek
.
save
()
return
redirect
(
"webapp:course_detail"
,
course_pk
=
course
.
pk
)
def
get_success_url
(
self
):
return
reverse
(
"webapp:project_detail"
,
kwargs
=
{
'project_pk'
:
self
.
object
.
course
.
pk
})
class
EditClassView
(
UpdateView
):
pass
class
DeleteClassView
(
DeleteView
):
pass
\ No newline at end of file
source/webapp/views/courses_views.py
View file @
33ec296f
...
...
@@ -35,7 +35,7 @@ class CourseDetailView(DetailView):
class
CourseDeleteView
(
DeleteView
):
model
=
Course
template_name
=
'courses/delete.html'
success_url
=
reverse_lazy
(
'courses_list'
)
success_url
=
reverse_lazy
(
'
webapp:
courses_list'
)
class
CourseEditView
(
UpdateView
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment