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
7a0e6b0e
Commit
7a0e6b0e
authored
Nov 04, 2021
by
Борис Ким
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Убрал ошибку с нахождением pk в форме создания урока. Доработал работу с файлом
parent
2dbf564e
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
24 additions
and
16 deletions
+24
-16
urls.py
source/portal/urls.py
+4
-1
forms.py
source/webapp/forms.py
+1
-1
models.py
source/webapp/models.py
+3
-0
create.html
source/webapp/templates/classes/create.html
+1
-1
courses_list.html
source/webapp/templates/courses/courses_list.html
+2
-1
create.html
source/webapp/templates/courses/create.html
+1
-0
detail.html
source/webapp/templates/courses/detail.html
+3
-3
urls.py
source/webapp/urls.py
+1
-1
classes_views.py
source/webapp/views/classes_views.py
+7
-7
courses_views.py
source/webapp/views/courses_views.py
+1
-1
No files found.
source/portal/urls.py
View file @
7a0e6b0e
from
django.contrib
import
admin
from
django.urls
import
path
,
include
from
django.conf
import
settings
from
django.conf.urls.static
import
static
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
include
(
'webapp.urls'
)),
path
(
'accounts/'
,
include
(
'accounts.urls'
))
]
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
\ No newline at end of file
source/webapp/forms.py
View file @
7a0e6b0e
source/webapp/models.py
View file @
7a0e6b0e
...
...
@@ -38,6 +38,9 @@ class Class(models.Model):
def
__str__
(
self
):
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
"webapp:course_detail"
,
args
=
[
str
(
self
.
id
)])
class
Meta
:
verbose_name
=
"Class"
verbose_name_plural
=
"Classes"
...
...
source/webapp/templates/classes/create.html
View file @
7a0e6b0e
...
...
@@ -7,7 +7,7 @@
<hr>
<h1>
Create new Class
</h1>
<div
class=
'column-center'
>
<form
action=
"{% url "
webapp:class_create
"
%}"
method=
"POST
"
>
<form
action=
"{% url "
webapp:class_create
"
course_pk
%}"
method=
"POST"
enctype=
"multipart/form-data
"
>
{% include "partial/create_form.html" with button_text="Create new class" %}
</form>
</div>
...
...
source/webapp/templates/courses/courses_list.html
View file @
7a0e6b0e
...
...
@@ -13,8 +13,9 @@
<a
class=
"p-2"
href=
"{% url 'webapp:course_delete' course.id %}"
>
<i
class=
"fas fa-trash-alt"
></i>
</a>
</div>
<div
class=
"card-body"
style=
"height: 200px;"
>
<div
class=
'topic-name'
style=
"height: 50px;"
>
<a
class=
"card-title"
href=
"{% url 'webapp:course_detail' course.id %}"
>
<h5>
{{course.title}}
</h5>
</a>
<p
class=
"card-text"
>
{{ course.description|truncatewords:30 }}
</p>
</div>
<p
class=
"card-text"
>
<b>
Teacher:
</b>
{{course.teacher}}
</p>
<p
class=
"card-text"
>
<b>
Groups(s):
</b>
{% for group in course.group.all %} {{group}} {% endfor %}
...
...
source/webapp/templates/courses/create.html
View file @
7a0e6b0e
...
...
@@ -6,6 +6,7 @@
<a
href=
"{% url "
webapp:courses_list
"
%}"
>
Return to the main page..
</a>
<hr>
<h1>
Create new Course
</h1>
{{course}}
<div
class=
'column-center'
>
<form
action=
"{% url "
webapp:course_create
"
%}"
method=
"POST"
>
{% include "partial/create_form.html" with button_text="Create new course" %}
...
...
source/webapp/templates/courses/detail.html
View file @
7a0e6b0e
...
...
@@ -19,19 +19,19 @@
</blockquote>
</div>
<div
style=
"width: 150px; height: 70px; margin: 20px;"
>
<a
class=
'btn btn-primary'
href=
"{% url "
webapp:class_create
"
%}"
>
Create new week
</a>
<a
class=
'btn btn-primary'
href=
"{% url "
webapp:class_create
"
course
.
id
%}"
>
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
4
0px; margin: 15px auto;"
>
<div
class=
"card border-dark mb-3"
style=
"max-width: 100%; height: 2
6
0px; margin: 15px auto;"
>
<div
class=
"card-header"
>
<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 }}
</p>
{{ class.file }}
<a
href=
"{{ class.file.url }}"
>
See the lecture
</a>
<hr>
<p>
<b>
Created at:
</b>
{{ class.created_at }} -
<b>
by:
</b>
{{ course.teacher }}
</p>
</div>
...
...
source/webapp/urls.py
View file @
7a0e6b0e
...
...
@@ -10,5 +10,5 @@ urlpatterns = [
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
(
'course
s
/class/new'
,
webapp_views
.
CreateClassView
.
as_view
(),
name
=
'class_create'
)
path
(
'course
/<int:course_pk>
/class/new'
,
webapp_views
.
CreateClassView
.
as_view
(),
name
=
'class_create'
)
]
\ No newline at end of file
source/webapp/views/classes_views.py
View file @
7a0e6b0e
...
...
@@ -13,17 +13,17 @@ class CreateClassView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
template_name
=
'classes/create.html'
permission_required
=
'webapp.add_class'
def
get_context_data
(
self
,
**
kwargs
):
kwargs
[
'course_pk'
]
=
self
.
kwargs
.
get
(
'course_pk'
)
return
super
()
.
get_context_data
(
**
kwargs
)
def
form_valid
(
self
,
form
):
course_pk
=
self
.
kwargs
.
get
(
'pk'
)
course_pk
=
self
.
kwargs
.
get
(
'
course_
pk'
)
course
=
get_object_or_404
(
Course
,
pk
=
course_pk
)
classweek
=
form
.
save
(
commit
=
False
)
classweek
.
course
=
classweek
classweek
.
save
()
classweek
=
form
.
save
()
course
.
courses
.
add
(
classweek
)
return
redirect
(
"webapp:course_detail"
,
course_pk
=
course
.
pk
)
def
get_success_url
(
self
):
return
reverse
(
"webapp:course_detail"
,
kwargs
=
{
'project_pk'
:
self
.
object
.
course
.
pk
})
class
EditClassView
(
UpdateView
):
pass
...
...
source/webapp/views/courses_views.py
View file @
7a0e6b0e
...
...
@@ -13,7 +13,7 @@ class CourseCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
template_name
=
'courses/create.html'
form_class
=
CourseForm
model
=
Course
pk_url_kwarg
=
'
project
_pk'
pk_url_kwarg
=
'
course
_pk'
permission_required
=
'webapp.add_course'
def
get_form
(
self
,
form_class
=
None
):
...
...
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