Открыть боковую панель
peteroshkvarkov
Project-38
Коммиты
69ee5fcf
Коммит
69ee5fcf
создал
Ноя 05, 2023
по автору
AdLeGeR
Просмотр файлов
сделал сортировкку ао ниминацииям, предметам и названиям
владелец
ea321bf3
Изменения
4
Скрыть пробелы
Построчно
Рядом
portal/projects/models.py
Просмотр файла @
69ee5fcf
...
@@ -26,6 +26,11 @@ class Project(Model):
...
@@ -26,6 +26,11 @@ class Project(Model):
tasks
=
CharField
(
max_length
=
1000
,
null
=
True
)
tasks
=
CharField
(
max_length
=
1000
,
null
=
True
)
expected_results
=
CharField
(
max_length
=
1000
,
null
=
True
)
expected_results
=
CharField
(
max_length
=
1000
,
null
=
True
)
defence_video
=
CharField
(
max_length
=
200
,
null
=
True
)
defence_video
=
CharField
(
max_length
=
200
,
null
=
True
)
_nominations
=
[
'Учатник районного НОУ'
,
'Призёр районного НОУ'
,
'Победитель районного НОУ'
,
'Учатник городского НОУ'
,
'Призёр городского НОУ'
,
'Победитель городского НОУ'
,
'Учатник областного НОУ'
,
'Призёр областного НОУ'
,
'Победитель областного НОУ'
,
'Учатник всероссийского НОУ'
,
'Призёр всероссийского НОУ'
,
'Победитель всероссийского НОУ'
]
nominations
=
CharField
(
max_length
=
100
,
null
=
True
)
# фильтрация предметов при записи их в бд(что бы не удалось поставить не существующий предмет
# фильтрация предметов при записи их в бд(что бы не удалось поставить не существующий предмет
def
set_subject
(
self
,
subjects
:
str
):
def
set_subject
(
self
,
subjects
:
str
):
...
@@ -65,6 +70,13 @@ class Project(Model):
...
@@ -65,6 +70,13 @@ class Project(Model):
def
get_level
(
self
):
def
get_level
(
self
):
return
self
.
_level
return
self
.
_level
def
set_nominations
(
self
,
s_nominations
):
s_n
=
s_nominations
.
split
(
','
)
for
nomination
in
s_n
:
if
nomination
not
in
self
.
_nominations
:
return
self
.
nominations
=
s_nominations
# эта константа показывает сколько версий может быть у одного файла
# эта константа показывает сколько версий может быть у одного файла
...
...
portal/projects/views.py
Просмотр файла @
69ee5fcf
...
@@ -422,8 +422,18 @@ def close_project(request: HttpRequest):
...
@@ -422,8 +422,18 @@ def close_project(request: HttpRequest):
def
archive
(
request
:
HttpRequest
):
def
archive
(
request
:
HttpRequest
):
projects
=
Project
.
objects
.
filter
(
_status
=
'done'
)[
0
:
20
]
projects
=
Project
.
objects
.
filter
(
_status
=
'done'
)
if
request
.
method
==
'POST'
:
nominations
=
request
.
POST
.
get
(
'nominations'
,
'Не указано'
).
split
(
','
)
subject
=
request
.
POST
.
get
(
'subject'
,
'Не указано'
)
name
=
request
.
POST
.
get
(
'name'
,
''
)
if
nominations
[
0
]
!=
'Не указано'
and
nominations
[
0
]
!=
''
:
projects
=
projects
.
filter
(
nominations__in
=
nominations
)
if
subject
!=
'Не указано'
and
subject
!=
''
:
projects
=
projects
.
filter
(
_subjects__icontains
=
subject
)
if
name
!=
''
:
projects
=
projects
.
filter
(
name__icontains
=
name
)
projects
=
projects
[:
20
]
# упаковка проектов и файлов в один массив состоящий из объектов класса ProjectPack
# упаковка проектов и файлов в один массив состоящий из объектов класса ProjectPack
context_projects
=
[]
context_projects
=
[]
...
@@ -440,6 +450,7 @@ def archive(request:HttpRequest):
...
@@ -440,6 +450,7 @@ def archive(request:HttpRequest):
'status'
:
project
.
get_status
(),
'status'
:
project
.
get_status
(),
'subjects'
:
project
.
get_subjects
()})
'subjects'
:
project
.
get_subjects
()})
context_projects
.
append
(
values
.
copy
())
context_projects
.
append
(
values
.
copy
())
print
(
project
.
get_subjects
())
context
=
{
'projects'
:
context_projects
,
'nominations'
:
Project
.
_nominations
,
return
render
(
request
,
'projects/archive.html'
,
context
=
{
'projects'
:
context_projects
})
"subjects"
:
[
subject
.
name
for
subject
in
Subject
.
objects
.
all
()]}
return
render
(
request
,
'projects/archive.html'
,
context
=
context
)
portal/static/js/projects/archive.js
0 → 100644
Просмотр файла @
69ee5fcf
$
(
"
ul li.list-li.nominations
"
).
click
(
function
()
{
$
(
"
#nominations-filter
"
).
val
(
$
(
this
).
text
());
});
$
(
"
ul li.list-li.subject
"
).
click
(
function
()
{
$
(
"
#subject-filter
"
).
val
(
$
(
this
).
text
());
});
\ No newline at end of file
portal/templates/projects/archive.html
Просмотр файла @
69ee5fcf
...
@@ -2,9 +2,65 @@
...
@@ -2,9 +2,65 @@
{% load js %}
{% load js %}
{% block head %}
{% block head %}
<title>
Архив работ
</title>
<title>
Архив работ
</title>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
href=
"https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap"
rel=
"stylesheet"
>
<link
rel=
"shortcut icon"
href=
"{% static 'img/global/icon.png' %}"
type=
"image/x-icon"
>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"
></script>
{% endblock head %}
{% endblock head %}
{% block content %}
{% block content %}
<div
class=
"filters"
>
<form
class=
"container"
method=
"POST"
action=
"{% url 'archive' %}"
>
{% csrf_token %}
<div
class=
"left"
>
<div
class=
"search"
>
<input
class=
"search-input"
type=
"text"
placeholder=
"Поиск..."
name=
"name"
>
<button
class=
"search-button"
></button>
</div>
<div
class=
"checkboxes"
>
<div
class=
"div-list"
>
<div
class=
"list-name"
>
Предмет
</div>
<input
type=
"hidden"
id=
"subject-filter"
name=
"subject"
/>
<div
class=
"list-names"
>
<div
class=
"list-p"
>
Не указано
</div>
<ul
class=
"list"
name=
"subject"
>
<li
class=
"list-li subject"
>
Не указано
</li>
{% for subject in subjects %}
<li
class=
"list-li subject"
>
{{subject}}
</li>
{% endfor %}
</ul>
</div>
</div>
<div
class=
"div-list"
>
<div
class=
"list-name"
>
Номинация
</div>
<input
type=
"hidden"
id=
"nominations-filter"
name=
"nominations"
/>
<div
class=
"list-names"
>
<div
class=
"list-p"
>
Не указано
</div>
<ul
class=
"list"
name=
"nominations"
>
<li
class=
"list-li nominations"
>
Не указано
</li>
{% for nomination in nominations %}
<li
class=
"list-li nominations"
>
{{nomination}}
</li>
{% endfor %}
</ul>
</div>
</div>
<div>
<input
type=
"checkbox"
id=
"past_year"
class=
"checkbox"
name=
"past_year"
>
<label
class=
"checkbox-name"
for=
"past_year"
>
Прошлых лет
</label>
</div>
</div>
</div>
<div
class=
"right"
>
<button
class=
"btn filter_btn"
type=
"submit"
>
Применить
</button>
</div>
</form>
</div>
<ul>
<ul>
{%for project in projects%}
{%for project in projects%}
<li>
<li>
...
@@ -30,4 +86,7 @@
...
@@ -30,4 +86,7 @@
</li>
</li>
{%endfor%}
{%endfor%}
</ul>
</ul>
<script
src=
"{% static 'js/global/list.js' %}"
></script>
<script
src=
"{% static 'js/projects/archive.js' %}"
></script>
{% endblock content %}
{% endblock content %}
\ No newline at end of file
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать