Открыть боковую панель
peteroshkvarkov
Project-38
Коммиты
f6dc0bd6
Коммит
f6dc0bd6
создал
Май 23, 2023
по автору
Rushan Romazanov
Просмотр файлов
Change to hide the issue
владелец
c45db39e
Изменения
4
Скрыть пробелы
Построчно
Рядом
portal/announcements/forms.py
Просмотр файла @
f6dc0bd6
from
django
import
forms
from
django.contrib.staticfiles
import
finders
from
django.core.exceptions
import
ValidationError
from
datetime
import
datetime
from
.models
import
Announcement
...
...
@@ -9,7 +10,7 @@ class AnnouncementForm(forms.Form):
title
=
forms
.
CharField
(
label
=
''
,
required
=
True
,
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'title'
,
'placeholder'
:
'Заголовок объявления'
}))
body
=
forms
.
CharField
(
label
=
''
,
widget
=
forms
.
Textarea
(
attrs
=
{
'class'
:
'body'
}))
is_pinned
=
forms
.
BooleanField
(
label
=
'Закрепить'
,
required
=
False
)
image_url
=
forms
.
FilePathField
(
label
=
'Выбрать обложку'
,
path
=
'static/
img/announcements/covers
'
,
required
=
False
,
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'imurl'
}))
image_url
=
forms
.
FilePathField
(
label
=
'Выбрать обложку'
,
path
=
finders
.
find
(
"
img/announcements/covers
"
)
,
required
=
False
,
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'imurl'
}))
files
=
forms
.
FileField
(
label
=
'Прикрепить файлы'
,
widget
=
forms
.
FileInput
(
attrs
=
{
'class'
:
"files"
}),
required
=
False
)
file_id_to_delete
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
(
attrs
=
{
'class'
:
'fitd'
}),
required
=
False
)
...
...
portal/announcements/migrations/0001_initial.py
Просмотр файла @
f6dc0bd6
# Generated by Django 4.1.3 on 2023-04-21 18:43
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
from
django.contrib.staticfiles
import
finders
class
Migration
(
migrations
.
Migration
):
...
...
@@ -22,7 +23,7 @@ class Migration(migrations.Migration):
(
'body'
,
models
.
TextField
()),
(
'is_pinned'
,
models
.
BooleanField
(
default
=
False
)),
(
'date_of_expiring'
,
models
.
DateTimeField
(
null
=
True
)),
(
'image_url'
,
models
.
FilePathField
(
null
=
True
,
path
=
'/static/
img/announcement
_images'
)),
(
'image_url'
,
models
.
FilePathField
(
null
=
True
,
path
=
finders
.
find
(
"
img/announcement
s/covers"
)
)),
],
options
=
{
'abstract'
:
False
,
...
...
portal/announcements/migrations/0003_alter_announcement_image_url.py
Просмотр файла @
f6dc0bd6
# Generated by Django 4.1.7 on 2023-05-22 18:02
from
django.db
import
migrations
,
models
from
django.contrib.staticfiles
import
finders
class
Migration
(
migrations
.
Migration
):
...
...
@@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations
.
AlterField
(
model_name
=
'announcement'
,
name
=
'image_url'
,
field
=
models
.
FilePathField
(
null
=
True
,
path
=
'static/
img/announcements/covers
'
),
field
=
models
.
FilePathField
(
null
=
True
,
path
=
finders
.
find
(
"
img/announcements/covers
"
)
),
),
]
portal/announcements/models.py
Просмотр файла @
f6dc0bd6
from
django.db
import
models
from
django.conf
import
settings
from
django.contrib.staticfiles
import
finders
class
TimeStampMixin
(
models
.
Model
):
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
...
...
@@ -16,7 +16,7 @@ class Announcement(TimeStampMixin):
author
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
on_delete
=
models
.
CASCADE
)
is_pinned
=
models
.
BooleanField
(
default
=
False
)
date_of_expiring
=
models
.
DateTimeField
(
null
=
True
)
image_url
=
models
.
FilePathField
(
null
=
True
,
path
=
'static/
img/announcements/covers
'
)
image_url
=
models
.
FilePathField
(
null
=
True
,
path
=
finders
.
find
(
"
img/announcements/covers
"
)
)
class
File
(
models
.
Model
):
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать