Открыть боковую панель
peteroshkvarkov
Project-38
Коммиты
bfda9560
Коммит
bfda9560
создал
Сен 05, 2023
по автору
Кабанин Денис Андреевич
Просмотр файлов
Merge branch '160-баг-фикс-в-разделе-проектов' into issue147_project-ui
владельцы
9d4e6db7
c6731ab6
Изменения
12
Развернуть все
Скрыть пробелы
Построчно
Рядом
portal/management/models.py
Просмотр файла @
bfda9560
...
...
@@ -20,6 +20,9 @@ class User(AbstractUser):
def
set_full_name
(
self
):
self
.
full_Name
=
self
.
last_name
+
self
.
first_name
+
self
.
middle_name
def
get_full_name
(
self
)
->
str
:
return
self
.
last_name
+
' '
+
self
.
first_name
+
' '
+
self
.
middle_name
;
def
save_photo
(
self
,
*
args
,
**
kwargs
):
super
().
save
()
img
=
Image
.
open
(
self
.
avatar
.
path
)
...
...
portal/projects/migrations/0003_project__level.py
0 → 100644
Просмотр файла @
bfda9560
# Generated by Django 4.2.3 on 2023-09-02 18:29
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"projects"
,
"0002_file_name_project__type"
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
"project"
,
name
=
"_level"
,
field
=
models
.
CharField
(
max_length
=
10
,
null
=
True
),
),
]
portal/projects/models.py
Просмотр файла @
bfda9560
...
...
@@ -16,7 +16,9 @@ class Project(Model):
_statuses
=
[
"send request"
,
"on work"
,
"send to verification"
,
"done"
]
_status
=
CharField
(
max_length
=
30
)
_subjects
=
CharField
(
max_length
=
100
,
null
=
True
)
_types
=
[
'Проект'
,
'НОУ'
]
_levels
=
[
'Проект'
,
'НОУ'
]
_level
=
CharField
(
max_length
=
10
,
null
=
True
)
_types
=
[
'Исследовательский'
,
'Информационный'
,
'Прикладной'
,
'Ролевой(игровой)'
,
'Социальный'
,
'Технологическийт (инженерный)'
,
'Бизнес-план'
]
_type
=
CharField
(
max_length
=
10
,
null
=
True
)
problem
=
CharField
(
max_length
=
1000
,
null
=
True
)
relevance
=
CharField
(
max_length
=
1000
,
null
=
True
)
...
...
@@ -47,12 +49,21 @@ class Project(Model):
return
self
.
_status
def
set_type
(
self
,
project_type
):
print
(
project_type
,
project_type
in
self
.
_types
,
self
.
_types
)
if
project_type
in
self
.
_types
:
self
.
_type
=
project_type
self
.
save
()
def
get_type
(
self
):
return
self
.
_type
def
set_level
(
self
,
project_level
):
if
project_level
in
self
.
_levels
:
self
.
_level
=
project_level
self
.
save
()
def
get_level
(
self
):
return
self
.
_level
# эта константа показывает сколько версий может быть у одного файла
...
...
portal/projects/templatetags/run.py
удалено
100644 → 0
Просмотр файла @
9d4e6db7
from
django.template
import
Library
register
=
Library
()
@
register
.
filter
(
is_safe
=
True
)
def
run
(
func
):
return
func
\ Нет новой строки в конце файла
portal/projects/views.py
Просмотр файла @
bfda9560
...
...
@@ -42,24 +42,12 @@ def index(request: HttpRequest):
context_projects
=
[]
for
project
in
projects
:
# files = list(File.objects.filter(project=project, version=1))
# variables = vars(project)
# values = {key : val for key, val in zip(variables.keys(), variables.values()) if key != '_state'}
# pp = ProjectPack(**values)
# pp.files = files
full_teacher_name
=
project
.
teacher
.
last_name
+
' '
+
project
.
teacher
.
first_name
[
0
]
+
'. '
+
project
.
teacher
.
middle_name
[
0
]
+
'.'
full_student_name
=
project
.
student
.
last_name
+
' '
+
project
.
student
.
first_name
[
0
]
+
'. '
+
project
.
student
.
middle_name
[
0
]
+
'.'
some_project
=
{
"name"
:
project
.
name
,
"descr"
:
project
.
description
,
"status"
:
project
.
get_status
(),
"type"
:
project
.
get_type
(),
"subjects"
:
project
.
get_subjects
(),
"teacher"
:
full_teacher_name
,
"student"
:
full_student_name
,
"id"
:
project
.
id
,
}
context_projects
.
append
(
some_project
)
files
=
list
(
File
.
objects
.
filter
(
project
=
project
,
version
=
1
))
variables
=
vars
(
project
)
values
=
{
key
:
val
for
key
,
val
in
zip
(
variables
.
keys
(),
variables
.
values
())
if
key
!=
'_state'
}
pp
=
ProjectPack
(
**
values
)
pp
.
files
=
files
context_projects
.
append
(
pp
)
return
render
(
request
,
"projects/index.html"
,
context
=
{
'projects'
:
context_projects
,
'has_projects'
:
len
(
context_projects
)
>
0
})
...
...
@@ -82,6 +70,7 @@ def index(request: HttpRequest):
"status"
:
project
.
get_status
(),
"subjects"
:
project
.
get_subjects
(),
"description"
:
project
.
description
,
"project_level"
:
project
.
get_level
(),
"project_type"
:
project
.
get_type
(),
'problem'
:
project
.
problem
,
"relevance"
:
project
.
relevance
,
...
...
@@ -209,19 +198,20 @@ def correct_project(request: HttpRequest):
return
render
(
request
,
"NotEnoughPermissions.html"
)
name
=
request
.
POST
.
get
(
"name"
,
-
1
)
description
=
request
.
POST
.
get
(
"description"
,
-
1
)
project_
type
=
request
.
POST
.
get
(
'project-
type
'
,
-
1
)
project_
level
=
request
.
POST
.
get
(
'project-
level
'
,
-
1
)
problem
=
request
.
POST
.
get
(
'problem'
,
-
1
)
relevance
=
request
.
POST
.
get
(
'relevance'
,
-
1
)
target
=
request
.
POST
.
get
(
'target'
,
-
1
)
tasks
=
request
.
POST
.
get
(
'tasks'
,
-
1
)
expected_results
=
request
.
POST
.
get
(
'expected-results'
,
-
1
)
project_type
=
request
.
POST
.
get
(
'project-type'
,
-
1
)
print
(
project_type
)
if
name
!=
-
1
:
project
.
name
=
name
if
description
!=
-
1
:
project
.
description
=
description
if
project_
type
!=
-
1
:
project
.
set_
type
(
project_
type
)
if
project_
level
!=
-
1
:
project
.
set_
level
(
project_
level
)
if
problem
!=
-
1
:
project
.
problem
=
problem
if
relevance
!=
-
1
:
...
...
portal/static/css/projects/index.css
Просмотр файла @
bfda9560
...
...
@@ -132,7 +132,7 @@
.list
{
position
:
absolute
;
z-index
:
2
;
z-index
:
5
;
width
:
100%
;
max-height
:
200px
;
overflow-y
:
auto
;
...
...
portal/static/css/projects/project_page_work.css
Просмотр файла @
bfda9560
...
...
@@ -141,13 +141,13 @@
align-items
:
center
;
}
.
type
-line
{
.
level
-line
{
width
:
60%
;
height
:
1px
;
background
:
rgba
(
0
,
0
,
0
,
0.3
);
}
.
type
-label
{
.
level
-label
{
padding-top
:
55px
;
display
:
flex
;
flex-direction
:
column
;
...
...
@@ -158,11 +158,21 @@
cursor
:
pointer
;
}
.
type
-label
:last-child
{
.
level
-label
:last-child
{
background-image
:
url("../../img/project/noy.svg")
;
background-size
:
45px
45px
;
}
.type-label
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
min-width
:
50px
;
cursor
:
pointer
;
display
:
flex
;
flex-direction
:
row
;
}
.form-input
{
margin-bottom
:
15px
;
display
:
block
;
...
...
portal/static/js/global/list.js
Просмотр файла @
bfda9560
...
...
@@ -12,6 +12,7 @@ window.onclick = function(event) {
if
(
event
.
target
.
matches
(
'
.list-li
'
)){
let
text
=
event
.
target
.
innerHTML
;
event
.
target
.
parentNode
.
parentNode
.
childNodes
[
1
].
innerHTML
=
text
;
event
.
target
.
parentNode
.
parentNode
.
childNodes
[
1
].
onchange
();
$
(
'
.list
'
).
css
({
'
display
'
:
'
none
'
});
}
else
if
(
!
event
.
target
.
matches
(
'
.list-p
'
))
{
...
...
portal/static/js/projects/index.js
Просмотр файла @
bfda9560
...
...
@@ -74,4 +74,37 @@ $('.done').hover(function () {
$
(
block
.
childNodes
[
1
].
childNodes
).
removeClass
(
'
dn2
'
);
$
(
block
.
childNodes
[
1
].
childNodes
).
removeClass
(
'
dn3
'
);
},
400
);
});
\ Нет новой строки в конце файла
});
function
filter
(){
let
text
=
document
.
querySelector
(
"
.search-input
"
).
value
.
toLowerCase
();
let
group
=
document
.
getElementById
(
"
filter-group
"
).
innerText
;
let
type
=
document
.
getElementById
(
"
filter-role
"
).
innerText
;
$
(
'
.project
'
).
each
(
function
(
i
,
element
){
if
(
contains_text
(
element
,
text
)
&&
match_group
(
element
,
group
)
&&
match_type
(
element
,
type
)){
element
.
style
.
display
=
'
flex
'
;
}
else
{
element
.
style
.
display
=
'
none
'
;
}
});
}
function
contains_text
(
element
,
text
){
return
element
.
querySelector
(
'
.title
'
).
textContent
.
toLowerCase
().
includes
(
text
)
||
element
.
querySelector
(
'
.student
'
).
textContent
.
toLowerCase
().
includes
(
text
);
}
function
match_group
(
element
,
group
){
if
(
group
==
"
Не указано
"
){
return
true
;
}
return
element
.
querySelector
(
'
.student-group
'
).
textContent
==
group
;
}
function
match_type
(
element
,
type
){
if
(
type
==
"
Не указано
"
){
return
true
;
}
return
element
.
querySelector
(
'
.project-type
'
).
textContent
==
type
;
}
\ Нет новой строки в конце файла
portal/static/js/projects/project_page_on_work.js
Просмотр файла @
bfda9560
...
...
@@ -61,21 +61,33 @@ function checking(name, is_click) {
}
}
}
else
if
(
name
==
'
cb5
'
)
{
if
(
$
(
'
.file-name
'
)[
0
].
innerText
!=
''
)
{
if
(
is_click
)
{
let
content_status
=
$
(
'
.content-status
'
)[
4
];
$
(
content_status
).
html
(
ok
);
$
(
'
.next-btn
'
).
css
({
'
pointer-events
'
:
'
auto
'
});
}
else
{
let
content_status
=
$
(
'
.content-status
'
)[
4
];
$
(
content_status
).
html
(
not_ok
);
if
(
!
is_opened
)
{
$
(
'
.next-btn
'
).
css
({
'
pointer-events
'
:
'
none
'
});
}
}
if
(
$
(
'
.file-name
'
)[
1
].
innerText
!=
''
)
{
}
else
if
(
name
==
'
cb6
'
)
{
if
(
$
(
'
.file-name
'
)[
0
].
innerText
!=
''
)
{
let
content_status
=
$
(
'
.content-status
'
)[
5
];
$
(
content_status
).
html
(
ok
);
}
else
{
let
content_status
=
$
(
'
.content-status
'
)[
5
];
$
(
content_status
).
html
(
not_ok
);
}
if
(
$
(
'
.file-name
'
)[
1
].
innerText
!=
''
)
{
let
content_status
=
$
(
'
.content-status
'
)[
6
];
$
(
content_status
).
html
(
ok
);
}
else
{
let
content_status
=
$
(
'
.content-status
'
)[
6
];
$
(
content_status
).
html
(
not_ok
);
}
}
}
...
...
@@ -108,7 +120,7 @@ if (is_opened) {
checking
(
'
cb
'
+
num_of_cb
);
if
(
num_of_cb
!=
5
)
{
if
(
num_of_cb
!=
6
)
{
if
(
$
(
$
(
new_cb
)[
0
].
childNodes
[
3
].
childNodes
[
1
]).
attr
(
'
class
'
)
==
'
not_ok
'
)
{
if
(
!
is_opened
)
{
$
(
'
.next-btn
'
).
css
({
'
pointer-events
'
:
'
none
'
});
...
...
@@ -119,7 +131,7 @@ if (is_opened) {
if
(
num_of_cb
==
4
)
{
$
(
'
.skip-btn
'
).
css
({
'
display
'
:
'
block
'
});
}
else
if
(
num_of_cb
==
5
)
{
else
if
(
num_of_cb
==
6
)
{
$
(
'
.next-btn
'
).
css
({
'
background-url
'
:
'
none
'
,
'
text-align
'
:
'
center
'
...
...
@@ -137,7 +149,7 @@ if (is_opened) {
$
(
new_cb
).
addClass
(
'
content-block-open
'
);
num_of_cb
++
;
if
(
num_of_cb
!=
5
)
{
if
(
num_of_cb
!=
6
)
{
if
(
$
(
$
(
new_cb
)[
0
].
childNodes
[
3
].
childNodes
[
1
]).
attr
(
'
class
'
)
==
'
not_ok
'
)
{
if
(
!
is_opened
)
{
$
(
'
.next-btn
'
).
css
({
'
pointer-events
'
:
'
none
'
});
...
...
@@ -146,7 +158,7 @@ if (is_opened) {
}
if
(
num_of_cb
==
5
)
{
if
(
num_of_cb
==
6
)
{
$
(
'
.next-btn
'
).
css
({
'
background-url
'
:
'
none
'
,
'
text-align
'
:
'
center
'
...
...
@@ -159,17 +171,26 @@ if (is_opened) {
}
}
// выбор типа проекта
//установление типа проекта
$
(
'
.project-type
'
).
each
(
function
(
i
,
item
)
{
if
(
item
.
value
==
project_type
){
item
.
checked
=
true
;
item
.
onchange
();
}
});
// выбор уровня проекта
$
(
'
.project-
type
'
).
on
(
'
click
'
,
function
()
{
$
(
'
.project-
level
'
).
on
(
'
click
'
,
function
()
{
if
(
$
(
this
).
attr
(
'
id
'
)
==
'
noy
'
)
{
$
(
'
.input-cb
2
'
).
val
(
'
НОУ
'
);
$
(
'
.input-cb
5
'
).
val
(
'
НОУ
'
);
}
else
if
(
$
(
this
).
attr
(
'
id
'
)
==
'
project
'
)
{
$
(
'
.input-cb
2
'
).
val
(
'
Проект
'
);
$
(
'
.input-cb
5
'
).
val
(
'
Проект
'
);
}
});
let
projec_type
=
$
(
'
.input-cb
2
'
).
val
();
let
projec_type
=
$
(
'
.input-cb
5
'
).
val
();
if
(
projec_type
==
'
НОУ
'
)
{
$
(
'
#noy
'
).
click
();
...
...
portal/templates/projects/index.html
Просмотр файла @
bfda9560
...
...
@@ -32,18 +32,13 @@
{% if user.role == "Учитель" or user.role == 'Администратор' %}
<div
class=
"main-nav"
>
<div
class=
"top-nav"
>
<form
class=
"search"
method=
"POST"
>
{% csrf_token %}
{% if name_filter_have %}
<div
class=
"search"
>
<input
class=
"search-input"
type=
"text"
placeholder=
"Поиск..."
name=
"search_names"
value=
"{{ name_filter }}"
>
{% else %}
<input
class=
"search-input"
type=
"text"
placeholder=
"Поиск..."
name=
"search_names"
>
{% endif %}
<input
class=
"search-button"
type=
"submit"
name=
"search_butt"
>
</form>
value=
"{% if name_filter_have %}{{ name_filter }}{% endif %}"
oninput=
"filter(this.value);"
>
</div>
</div>
<
form
class=
"filter"
method=
"POST"
>
<
div
class=
"filter"
>
{% csrf_token %}
<div
class=
"div-list"
>
<p
class=
"list-name"
>
Группа:
</p>
...
...
@@ -51,7 +46,7 @@
{% if group_filter_have %}
<p
class=
"list-p"
id=
"filter-group"
>
{{ group_filter }}
</p>
{% else %}
<p
class=
"list-p"
id=
"filter-group"
>
Не указано
</p>
<p
class=
"list-p"
id=
"filter-group"
onchange=
"filter();"
>
Не указано
</p>
{% endif %}
<ul
class=
"list"
>
<li
class=
"list-li"
>
Не указано
</li>
...
...
@@ -87,7 +82,7 @@
{% if role_filter_have %}
<p
class=
"list-p"
id=
"filter-role"
>
{{ role_filter }}
</p>
{% else %}
<p
class=
"list-p"
id=
"filter-role"
>
Не указано
</p>
<p
class=
"list-p"
id=
"filter-role"
onchange=
"filter();"
>
Не указано
</p>
{% endif %}
<ul
class=
"list sub-list"
>
<li
class=
"list-li"
>
Не указано
</li>
...
...
@@ -96,17 +91,15 @@
</ul>
</div>
</div>
<input
type=
"number"
class=
"input-filter input-filter-group"
name=
"group_filter"
>
<input
type=
"text"
class=
"input-filter input-filter-type"
name=
"type_filter"
>
<input
class=
"btn btn-filter"
type=
"submit"
value=
"Применить"
name=
"filter_submit"
/>
<input
type=
"number"
class=
"input-filter input-filter-group"
name=
"group_filter"
>
<input
type=
"text"
class=
"input-filter input-filter-type"
name=
"type_filter"
>
</
form
>
</
div
>
</div>
{% endif %}
<div
class=
"content"
>
{% load run %}
{% for project in projects %}
{% if project.status == 'send request' %}
{% if project.
get_
status == 'send request' %}
<a
class=
"project project{{project.id}} send-request"
href=
"./?id={{ project.id }}"
>
<div
class=
"anim anim-send-request"
>
<div
class=
"ball"
></div>
...
...
@@ -117,14 +110,16 @@
<h2
class=
"title"
>
{{ project.name }}
</h2>
<span
class=
"subtitle"
>
{{ project.subjects }}
</span>
{% if user.role == 'Ученик' %}
<span>
{{ project.teacher }}
</span>
<span>
{{ project.teacher
.get_full_name
}}
</span>
{% else %}
<span>
{{ project.student }}
</span>
<span
class=
"student"
>
{{ project.student.getPName }}
</span>
<span
hidden
class=
"student-group"
>
{{project.student.group}}
</span>
{% endif %}
<span
hidden
class=
"project-type"
>
{{project.get_level}}
</span>
</div>
</a>
<!-- для проектов на этапе разработки -->
{% elif project.status == 'on work' %}
{% elif project.
get_
status == 'on work' %}
<a
class=
"project project{{project.id}} on-work"
href=
"./?id={{ project.id }}"
>
<div
class=
"anim-on-work"
>
<div
class=
"gear gear1"
>
...
...
@@ -141,13 +136,15 @@
<h2
class=
"title"
>
{{ project.name }}
</h2>
<span
class=
"subtitle"
>
{{ project.type }}
<div
class=
"sub-ball"
></div>
{{ project.subjects }}
</span>
{% if user.role == 'Ученик' %}
<span>
{{ project.teacher }}
</span>
<span>
{{ project.teacher
.get_full_name
}}
</span>
{% else %}
<span>
{{ project.student }}
</span>
<span
class=
"student"
>
{{ project.student.getPName }}
</span>
<span
hidden
class=
"student-group"
>
{{project.student.group}}
</span>
{% endif %}
<span
hidden
class=
"project-type"
>
{{project.get_level}}
</span>
</div>
</a>
{% elif project.status == 'done' %}
{% elif project.
get_
status == 'done' %}
<!-- для выполненных проектов -->
<a
class=
"project project{{project.id}} done"
href=
"./?id={{ project.id }}"
>
<div
class=
"anim-done"
>
...
...
@@ -165,10 +162,12 @@
<h2
class=
"title"
>
{{ project.name }}
</h2>
<span
class=
"subtitle"
>
{{ project.type }}
<div
class=
"sub-ball"
></div>
{{ project.subjects }}
</span>
{% if user.role == 'Ученик' %}
<span>
{{ project.teacher }}
</span>
<span>
{{ project.teacher
.get_full_name
}}
</span>
{% else %}
<span>
{{ project.student }}
</span>
<span
class=
"student"
>
{{ project.student.getPName }}
</span>
<span
hidden
class=
"student-group"
>
{{project.student.group}}
</span>
{% endif %}
<span
hidden
class=
"project-type"
>
{{project.get_level}}
</span>
</div>
</a>
{% endif %}
...
...
portal/templates/projects/project_page.html
Просмотр файла @
bfda9560
Это отличие свёрнуто
Нажмите, чтобы развернуть
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать