Открыть боковую панель
peteroshkvarkov
Project-38
Коммиты
7e843286
Коммит
7e843286
создал
Июн 11, 2023
по автору
Кабанин Денис Андреевич
Просмотр файлов
Добавил вывод ошибок в форме создания проекта
владелец
e28750fe
Изменения
5
Скрыть пробелы
Построчно
Рядом
portal/media/avatars/20_0TX3Vml.jpg
удалено
100644 → 0
Просмотр файла @
e28750fe
9,1 КБ
portal/media/avatars/t2CNeSsPLNA_SaHWFrb.jpg
0 → 100644
Просмотр файла @
7e843286
17,3 КБ
portal/projects/views.py
Просмотр файла @
7e843286
...
@@ -4,6 +4,7 @@ from django.http import HttpResponse, FileResponse
...
@@ -4,6 +4,7 @@ from django.http import HttpResponse, FileResponse
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.http.request
import
HttpRequest
from
django.http.request
import
HttpRequest
from
django.contrib
import
messages
from
management.models
import
User
from
management.models
import
User
from
projects.models
import
Project
,
File
from
projects.models
import
Project
,
File
...
@@ -117,17 +118,20 @@ def check_post_request(*need_values):
...
@@ -117,17 +118,20 @@ def check_post_request(*need_values):
if
request
.
method
!=
'POST'
:
if
request
.
method
!=
'POST'
:
return
redirect
(
reverse
(
"projects"
))
return
redirect
(
reverse
(
"projects"
))
if
not
request
.
user
.
is_authenticated
:
if
not
request
.
user
.
is_authenticated
:
return
render
(
request
,
"NotEnoughPermissions.html"
)
messages
.
error
(
request
,
'У вас нет прав для совершения этого действия'
)
return
render
(
request
,
"projects/create.html"
)
for
value
in
need_values
:
for
value
in
need_values
:
request_value
=
request
.
POST
.
get
(
value
,
''
)
request_value
=
request
.
POST
.
get
(
value
,
''
)
if
request_value
==
''
:
if
request_value
==
''
:
return
render
(
request
,
"WrongData.html"
)
messages
.
error
(
request
,
'Неверно введённые данные'
)
return
render
(
request
,
"projects/create.html"
)
return
func
(
request
)
return
func
(
request
)
return
wrapper
return
wrapper
return
decorator
return
decorator
@
check_post_request
(
'teacher'
,
'name'
,
"subject"
,
"teacher-checkbox"
)
@
check_post_request
(
'teacher'
,
'name'
,
"subject"
)
def
create
(
request
:
HttpRequest
):
def
create
(
request
:
HttpRequest
):
teacher_id
=
request
.
POST
.
get
(
"teacher"
)
teacher_id
=
request
.
POST
.
get
(
"teacher"
)
subject
=
request
.
POST
.
get
(
"subject"
)
subject
=
request
.
POST
.
get
(
"subject"
)
...
@@ -168,7 +172,8 @@ def create(request: HttpRequest):
...
@@ -168,7 +172,8 @@ def create(request: HttpRequest):
@
check_post_request
(
'project'
)
@
check_post_request
(
'project'
)
def
correct_project
(
request
:
HttpRequest
):
def
correct_project
(
request
:
HttpRequest
):
project_id
=
request
.
POST
.
get
(
"project"
)
project_id
=
request
.
POST
.
get
(
"project_id"
)
print
(
project_id
)
try
:
try
:
project_id
=
project_id
project_id
=
project_id
project
=
Project
.
objects
.
get
(
id
=
project_id
)
project
=
Project
.
objects
.
get
(
id
=
project_id
)
...
...
portal/static/css/projects/fl.css
Просмотр файла @
7e843286
...
@@ -81,6 +81,14 @@
...
@@ -81,6 +81,14 @@
display
:
block
;
display
:
block
;
}
}
.checkbox
{
user-select
:
none
;
}
.checkbox-label
{
cursor
:
pointer
;
}
.tea
{
.tea
{
width
:
40%
;
width
:
40%
;
}
}
...
@@ -150,4 +158,21 @@
...
@@ -150,4 +158,21 @@
.but
:active
{
.but
:active
{
background
:
#232323
;
background
:
#232323
;
}
.errors
{
display
:
flex
;
flex-direction
:
column
;
}
.error
{
margin
:
0
;
margin-bottom
:
10px
;
padding
:
10px
;
border-radius
:
5px
;
font-size
:
16px
;
line-height
:
20px
;
border
:
1px
solid
#ff1c25
;
background
:
#ff828230
;
color
:
#000000
;
}
}
\ No newline at end of file
portal/templates/projects/create.html
Просмотр файла @
7e843286
...
@@ -12,20 +12,27 @@
...
@@ -12,20 +12,27 @@
{% csrf_token %}
{% csrf_token %}
<div
class=
"formPZ"
>
<div
class=
"formPZ"
>
<h1
class=
"form h1"
>
Подача заявки
</h1>
<h1
class=
"form h1"
>
Подача заявки
</h1>
<div
class=
"errors"
>
{% if messages %}
{% for message in messages %}
<p
class=
"error"
>
{{ message }}
</p>
{% endfor %}
{% endif %}
</div>
<div
class=
"form"
>
<div
class=
"form"
>
<h3
class=
"h3"
>
Название
</h3>
<h3
class=
"h3"
>
Название
*
</h3>
<input
name=
"name"
class=
"wf"
/>
<input
name=
"name"
class=
"wf"
required
/>
</div>
</div>
<div
class=
"form"
>
<div
class=
"form"
>
<h3
class=
"h3"
>
Описание
</h3>
<h3
class=
"h3"
>
Описание
*
</h3>
<textarea
name=
"description"
class=
"wf ta"
></textarea>
<textarea
name=
"description"
class=
"wf ta"
required
></textarea>
</div>
</div>
<div
class=
"form selects"
>
<div
class=
"form selects"
>
<div
class=
"tea"
>
<div
class=
"tea"
>
<h3
class=
"h3 tea"
>
Учитель
</h3>
<h3
class=
"h3 tea"
>
Учитель
*
</h3>
<div
class=
"teachers"
>
<div
class=
"teachers"
>
<div
class=
"teacher teacher-open"
>
<div
class=
"teacher teacher-open"
>
<select
name=
"teacher"
id=
"selTea"
class=
"wf select2"
required
multiple
>
<select
name=
"teacher"
id=
"selTea"
class=
"wf select2"
multiple
>
{% for teacher in teachers %}
{% for teacher in teachers %}
<option
value=
"{{ teacher.id }}"
class=
"opG opt"
>
{{ teacher.fullName }}
</option>
<option
value=
"{{ teacher.id }}"
class=
"opG opt"
>
{{ teacher.fullName }}
</option>
{% endfor %}
{% endfor %}
...
@@ -39,7 +46,7 @@
...
@@ -39,7 +46,7 @@
</div>
</div>
</div>
</div>
<div
class=
"subj"
>
<div
class=
"subj"
>
<h3
class=
"h3 subj"
>
Предмет
</h3>
<h3
class=
"h3 subj"
>
Предмет
*
</h3>
<select
name=
"subject"
id=
"selSubj"
class=
"wf"
required
>
<select
name=
"subject"
id=
"selSubj"
class=
"wf"
required
>
<optgroup
label=
"Математические"
>
<optgroup
label=
"Математические"
>
<option
class=
"opG opt"
>
Математика
</option>
<option
class=
"opG opt"
>
Математика
</option>
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать