Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
ap-11_django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Давид Ли
ap-11_django
Commits
59608255
Commit
59608255
authored
Aug 07, 2023
by
Давид Ли
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lesson 57
parent
2665861b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
base.html
web/templates/base.html
+20
-0
article.py
web/views/article.py
+6
-1
No files found.
web/templates/base.html
View file @
59608255
...
...
@@ -68,6 +68,26 @@
</div>
</nav>
<div
class=
"container"
>
{% if messages %}
{% for message in messages %}
<div
class=
"alert alert-dismisable fade show
{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}
alert-danger
{% elif message.level == DEFAULT_MESSAGE_LEVELS.SUCCESS %}
alert-success
{% elif message.level == DEFAULT_MESSAGE_LEVELS.INFO %}
alert-primary
{% else %}
alert-secondary
{% endif %}"
role=
"alert"
>
{{ message }}
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
{% endfor %}
{% endif %}
{% block title %}{% endblock %}
{% block content %}{% endblock %}
...
...
web/views/article.py
View file @
59608255
from
urllib.parse
import
urlencode
from
django.contrib
import
messages
from
django.urls
import
reverse
,
reverse_lazy
from
django.db.models
import
Q
from
django.contrib.auth.mixins
import
LoginRequiredMixin
,
PermissionRequiredMixin
,
UserPassesTestMixin
...
...
@@ -25,7 +26,11 @@ class ArticleIndexView(ListView):
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
form
=
self
.
get_search_form
()
self
.
search_value
=
self
.
get_search_value
()
session
=
request
.
session
messages
.
add_message
(
self
.
request
,
messages
.
SUCCESS
,
'Все круто!'
)
messages
.
add_message
(
self
.
request
,
messages
.
DEBUG
,
'Debug'
)
messages
.
add_message
(
self
.
request
,
messages
.
INFO
,
'Info'
)
messages
.
add_message
(
self
.
request
,
messages
.
WARNING
,
'warning'
)
messages
.
add_message
(
self
.
request
,
messages
.
ERROR
,
'error'
)
return
super
()
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
*
,
object_list
=
None
,
**
kwargs
):
...
...
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