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
Hide 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.contrib
import
admin
from
django.urls
import
path
,
include
from
django.urls
import
path
,
include
from
django.conf
import
settings
from
django.conf.urls.static
import
static
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
include
(
'webapp.urls'
)),
path
(
''
,
include
(
'webapp.urls'
)),
path
(
'accounts/'
,
include
(
'accounts.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
...
@@ -11,4 +11,4 @@ class CourseForm(forms.ModelForm):
...
@@ -11,4 +11,4 @@ class CourseForm(forms.ModelForm):
class
ClassForm
(
forms
.
ModelForm
):
class
ClassForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Class
model
=
Class
fields
=
[
'title'
,
'description'
,
'file'
]
fields
=
[
'title'
,
'description'
,
'file'
]
\ No newline at end of file
source/webapp/models.py
View file @
7a0e6b0e
...
@@ -38,6 +38,9 @@ class Class(models.Model):
...
@@ -38,6 +38,9 @@ class Class(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
"webapp:course_detail"
,
args
=
[
str
(
self
.
id
)])
class
Meta
:
class
Meta
:
verbose_name
=
"Class"
verbose_name
=
"Class"
verbose_name_plural
=
"Classes"
verbose_name_plural
=
"Classes"
...
...
source/webapp/templates/classes/create.html
View file @
7a0e6b0e
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<hr>
<hr>
<h1>
Create new Class
</h1>
<h1>
Create new Class
</h1>
<div
class=
'column-center'
>
<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" %}
{% include "partial/create_form.html" with button_text="Create new class" %}
</form>
</form>
</div>
</div>
...
...
source/webapp/templates/courses/courses_list.html
View file @
7a0e6b0e
...
@@ -13,8 +13,9 @@
...
@@ -13,8 +13,9 @@
<a
class=
"p-2"
href=
"{% url 'webapp:course_delete' course.id %}"
>
<i
class=
"fas fa-trash-alt"
></i>
</a>
<a
class=
"p-2"
href=
"{% url 'webapp:course_delete' course.id %}"
>
<i
class=
"fas fa-trash-alt"
></i>
</a>
</div>
</div>
<div
class=
"card-body"
style=
"height: 200px;"
>
<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>
<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>
Teacher:
</b>
{{course.teacher}}
</p>
<p
class=
"card-text"
>
<b>
Groups(s):
</b>
<p
class=
"card-text"
>
<b>
Groups(s):
</b>
{% for group in course.group.all %} {{group}} {% endfor %}
{% for group in course.group.all %} {{group}} {% endfor %}
...
...
source/webapp/templates/courses/create.html
View file @
7a0e6b0e
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<a
href=
"{% url "
webapp:courses_list
"
%}"
>
Return to the main page..
</a>
<a
href=
"{% url "
webapp:courses_list
"
%}"
>
Return to the main page..
</a>
<hr>
<hr>
<h1>
Create new Course
</h1>
<h1>
Create new Course
</h1>
{{course}}
<div
class=
'column-center'
>
<div
class=
'column-center'
>
<form
action=
"{% url "
webapp:course_create
"
%}"
method=
"POST"
>
<form
action=
"{% url "
webapp:course_create
"
%}"
method=
"POST"
>
{% include "partial/create_form.html" with button_text="Create new course" %}
{% include "partial/create_form.html" with button_text="Create new course" %}
...
...
source/webapp/templates/courses/detail.html
View file @
7a0e6b0e
...
@@ -19,19 +19,19 @@
...
@@ -19,19 +19,19 @@
</blockquote>
</blockquote>
</div>
</div>
<div
style=
"width: 150px; height: 70px; margin: 20px;"
>
<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>
</div>
</div>
</div>
{% for class in course.courses.all %}
{% 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"
>
<div
class=
"card-header"
>
<h6
style=
"color: #3A63A7;"
>
Week #{{forloop.counter}}
</h6>
<h6
style=
"color: #3A63A7;"
>
Week #{{forloop.counter}}
</h6>
</div>
</div>
<div
class=
"card-body text-dark"
>
<div
class=
"card-body text-dark"
>
<h5
class=
"card-title"
>
Topic: {{ class.title }}
</h5>
<h5
class=
"card-title"
>
Topic: {{ class.title }}
</h5>
<p
class=
"card-text"
>
Description: {{ class.description }}
</p>
<p
class=
"card-text"
>
Description: {{ class.description }}
</p>
{{ class.file }}
<a
href=
"{{ class.file.url }}"
>
See the lecture
</a>
<hr>
<hr>
<p>
<b>
Created at:
</b>
{{ class.created_at }} -
<b>
by:
</b>
{{ course.teacher }}
</p>
<p>
<b>
Created at:
</b>
{{ class.created_at }} -
<b>
by:
</b>
{{ course.teacher }}
</p>
</div>
</div>
...
...
source/webapp/urls.py
View file @
7a0e6b0e
...
@@ -10,5 +10,5 @@ urlpatterns = [
...
@@ -10,5 +10,5 @@ urlpatterns = [
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'
),
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
...
@@ -12,17 +12,17 @@ class CreateClassView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
...
@@ -12,17 +12,17 @@ class CreateClassView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
fields
=
[
'title'
,
'description'
,
'file'
]
fields
=
[
'title'
,
'description'
,
'file'
]
template_name
=
'classes/create.html'
template_name
=
'classes/create.html'
permission_required
=
'webapp.add_class'
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
):
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
)
course
=
get_object_or_404
(
Course
,
pk
=
course_pk
)
classweek
=
form
.
save
(
commit
=
False
)
classweek
=
form
.
save
()
classweek
.
course
=
classweek
course
.
courses
.
add
(
classweek
)
classweek
.
save
()
return
redirect
(
"webapp:course_detail"
,
course_pk
=
course
.
pk
)
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
):
class
EditClassView
(
UpdateView
):
...
...
source/webapp/views/courses_views.py
View file @
7a0e6b0e
...
@@ -13,7 +13,7 @@ class CourseCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
...
@@ -13,7 +13,7 @@ class CourseCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
template_name
=
'courses/create.html'
template_name
=
'courses/create.html'
form_class
=
CourseForm
form_class
=
CourseForm
model
=
Course
model
=
Course
pk_url_kwarg
=
'
project
_pk'
pk_url_kwarg
=
'
course
_pk'
permission_required
=
'webapp.add_course'
permission_required
=
'webapp.add_course'
def
get_form
(
self
,
form_class
=
None
):
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