Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
Coursework_64
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Volkov Gherman
Coursework_64
Commits
34366f6a
Commit
34366f6a
authored
Nov 04, 2021
by
Volkov Gherman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Заввершил проект курсовой работы News
parent
fad0df08
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
28 additions
and
17 deletions
+28
-17
.gitignore
.gitignore
+5
-0
README.md
source/README.md
+4
-1
urls.cpython-38.pyc
source/accounts/__pycache__/urls.cpython-38.pyc
+0
-0
password_change_form.html
...accounts/templates/registration/password_change_form.html
+1
-1
urls.py
source/accounts/urls.py
+2
-2
db.sqlite3
source/db.sqlite3
+0
-0
views.cpython-38.pyc
source/webapp/__pycache__/views.cpython-38.pyc
+0
-0
main.css
source/webapp/static/css/main.css
+0
-6
base.html
source/webapp/templates/base.html
+1
-1
index.html
source/webapp/templates/index.html
+3
-0
post_detail.html
source/webapp/templates/post/post_detail.html
+5
-2
views.py
source/webapp/views.py
+7
-4
No files found.
.gitignore
0 → 100644
View file @
34366f6a
.idea
venv
*.sqlite3
__pycache__
**.pyc
source/README.md
View file @
34366f6a
Проект с кодовым названием NEWS, нужно склонировать, установить зависимости из файла requirements.txt, загрузить фикстуры
Проект с кодовым названием NEWS, нужно склонировать, установить зависимости из файла requirements.txt, загрузить фикстуры.
\ No newline at end of file
Админ - log - admin
pass - admin12345
\ No newline at end of file
source/accounts/__pycache__/urls.cpython-38.pyc
View file @
34366f6a
No preview for this file type
source/accounts/templates/registration/password_change_form.html
View file @
34366f6a
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<form
action=
"{% url 'accounts:password_change_done' request.user.pk %}"
method=
"post"
>
<form
action=
"{% url 'accounts:password_change_done' request.user.pk %}"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ form|crispy }}
{{ form|crispy }}
<button
class=
"btn btn-outline-dark log_btn"
type=
"submit"
>
Login
</button>
<button
class=
"btn btn-outline-dark log_btn"
type=
"submit"
>
Change
</button>
</form>
</form>
</div>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
source/accounts/urls.py
View file @
34366f6a
from
django.contrib.auth.views
import
LoginView
,
LogoutView
,
PasswordChangeView
from
django.contrib.auth.views
import
LoginView
,
LogoutView
,
PasswordChangeView
from
django.urls
import
path
from
django.urls
import
path
,
reverse_lazy
from
accounts.views
import
RegisterView
from
accounts.views
import
RegisterView
...
@@ -9,5 +9,5 @@ urlpatterns = [
...
@@ -9,5 +9,5 @@ urlpatterns = [
path
(
"account/login/"
,
LoginView
.
as_view
(),
name
=
"login"
),
path
(
"account/login/"
,
LoginView
.
as_view
(),
name
=
"login"
),
path
(
"account/logout/"
,
LogoutView
.
as_view
(),
name
=
"logout"
),
path
(
"account/logout/"
,
LogoutView
.
as_view
(),
name
=
"logout"
),
path
(
"account/registration/"
,
RegisterView
.
as_view
(),
name
=
"register"
),
path
(
"account/registration/"
,
RegisterView
.
as_view
(),
name
=
"register"
),
path
(
"account/<int:pk>/change_password"
,
PasswordChangeView
.
as_view
(),
name
=
"password_change_done"
),
path
(
"account/<int:pk>/change_password"
,
PasswordChangeView
.
as_view
(
success_url
=
reverse_lazy
(
'accounts:password_change_done'
)
),
name
=
"password_change_done"
),
]
]
source/db.sqlite3
View file @
34366f6a
No preview for this file type
source/webapp/__pycache__/views.cpython-38.pyc
View file @
34366f6a
No preview for this file type
source/webapp/static/css/main.css
View file @
34366f6a
body
{
body
{
margin
:
0
;
margin
:
0
;
}
footer
{
position
:
absolute
;
bottom
:
0
;
right
:
0
;
left
:
0
;
}
}
/*BASE*/
/*BASE*/
...
...
source/webapp/templates/base.html
View file @
34366f6a
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
{% csrf_token %}
{% csrf_token %}
<button
class=
"btn text-dark btn-link"
title=
"Logout"
><i
class=
"bi bi-door-closed icon"
></i></button>
<button
class=
"btn text-dark btn-link"
title=
"Logout"
><i
class=
"bi bi-door-closed icon"
></i></button>
</form>
</form>
{% if reque
r
t.user.is_superuser %}
{% if reque
s
t.user.is_superuser %}
<a
style=
"margin-right: 10px;"
href=
"{% url "
webapp:post_create
"
%}"
class=
"text-dark"
title=
"Add post"
><i
class=
"bi bi-file-plus icon"
></i></a>
<a
style=
"margin-right: 10px;"
href=
"{% url "
webapp:post_create
"
%}"
class=
"text-dark"
title=
"Add post"
><i
class=
"bi bi-file-plus icon"
></i></a>
{% endif %}
{% endif %}
<a
style=
"margin-right: 10px;"
href=
"{% url "
accounts:password_change_done
"
request
.
user
.
pk
%}"
class=
"text-dark"
title=
"Change password"
><i
class=
"bi bi-pencil icon"
></i></a>
<a
style=
"margin-right: 10px;"
href=
"{% url "
accounts:password_change_done
"
request
.
user
.
pk
%}"
class=
"text-dark"
title=
"Change password"
><i
class=
"bi bi-pencil icon"
></i></a>
...
...
source/webapp/templates/index.html
View file @
34366f6a
...
@@ -15,6 +15,9 @@
...
@@ -15,6 +15,9 @@
<p
class=
"card-text post_d_text"
>
{{ post.text }}
</p>
<p
class=
"card-text post_d_text"
>
{{ post.text }}
</p>
<hr>
<hr>
<p
class=
"card-text"
><i>
{{ post.create }}
</i></p>
<p
class=
"card-text"
><i>
{{ post.create }}
</i></p>
{% if request.user.is_superuser %}
<p>
Active?: {{ post.is_active }}
</p>
{% endif %}
<a
href=
"{% url 'webapp:post_detail' post.pk %}"
class=
"btn btn-outline-dark"
>
In detail..
</a>
<a
href=
"{% url 'webapp:post_detail' post.pk %}"
class=
"btn btn-outline-dark"
>
In detail..
</a>
</div>
</div>
</div>
</div>
...
...
source/webapp/templates/post/post_detail.html
View file @
34366f6a
...
@@ -15,6 +15,9 @@
...
@@ -15,6 +15,9 @@
<p
class=
"card-text post_d_text"
>
{{ post.text }}
</p>
<p
class=
"card-text post_d_text"
>
{{ post.text }}
</p>
<hr>
<hr>
<p
class=
"card-text"
><i>
{{ post.create }}
</i></p>
<p
class=
"card-text"
><i>
{{ post.create }}
</i></p>
{% if request.user.is_superuser %}
<p>
Active?: {{ post.is_active }}
</p>
{% endif %}
{% if request.user.is_superuser %}
{% if request.user.is_superuser %}
<div
class=
"post_d_buttons"
>
<div
class=
"post_d_buttons"
>
<a
href=
"{% url 'webapp:post_update' post.pk %}"
class=
"btn btn-outline-dark"
>
Update
</a>
<a
href=
"{% url 'webapp:post_update' post.pk %}"
class=
"btn btn-outline-dark"
>
Update
</a>
...
@@ -32,8 +35,8 @@
...
@@ -32,8 +35,8 @@
<div
class=
"toast comment_container"
role=
"alert"
aria-live=
"assertive"
aria-atomic=
"true"
>
<div
class=
"toast comment_container"
role=
"alert"
aria-live=
"assertive"
aria-atomic=
"true"
>
<div
class=
"toast-header com_header"
>
<div
class=
"toast-header com_header"
>
{#
<img
src=
"..."
class=
"rounded mr-2"
alt=
"..."
>
#}
{% if request.user.is_superuser %}
{% if request.user.is_superuser
or comment.author == request.user
%}
{% include 'comment/comment_delete.html' %}
{% include 'comment/comment_delete.html' %}
{% endif %}
{% endif %}
<strong
class=
"mr-auto"
>
{{ comment.author }}
</strong>
<strong
class=
"mr-auto"
>
{{ comment.author }}
</strong>
...
...
source/webapp/views.py
View file @
34366f6a
...
@@ -17,8 +17,10 @@ class PostListView(ListView):
...
@@ -17,8 +17,10 @@ class PostListView(ListView):
paginate_by
=
10
paginate_by
=
10
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
filter
(
is_active
=
True
)
if
self
.
request
.
user
.
is_superuser
:
return
queryset
queryset
=
super
()
.
get_queryset
()
.
filter
(
is_active
=
True
)
return
queryset
return
super
()
.
get_queryset
()
class
PostDetailView
(
DetailView
):
class
PostDetailView
(
DetailView
):
...
@@ -93,7 +95,8 @@ class CommentDeleteView(PermissionRequiredMixin, DeleteView):
...
@@ -93,7 +95,8 @@ class CommentDeleteView(PermissionRequiredMixin, DeleteView):
permission_required
=
'webapp.delete_comment'
permission_required
=
'webapp.delete_comment'
def
has_permission
(
self
):
def
has_permission
(
self
):
return
super
()
.
has_permission
()
or
self
.
object
==
self
.
request
.
user
self
.
object
=
self
.
get_object
()
return
super
()
.
has_permission
()
or
self
.
object
.
author
==
self
.
request
.
user
def
get_success_url
(
self
):
def
get_success_url
(
self
):
return
reverse
(
'webapp:post_detail'
,
kwargs
=
{
"pk"
:
self
.
object
.
post
.
pk
})
return
reverse
(
'webapp:post_detail'
,
kwargs
=
{
"pk"
:
self
.
object
.
post
.
pk
})
...
@@ -117,7 +120,7 @@ class SearchView(ListView):
...
@@ -117,7 +120,7 @@ class SearchView(ListView):
return
context
return
context
def
get_queryset
(
self
):
def
get_queryset
(
self
):
query_set
=
super
()
.
get_queryset
()
query_set
=
super
()
.
get_queryset
()
.
filter
(
is_active
=
True
)
if
self
.
search_value
:
if
self
.
search_value
:
query
=
Q
(
title__icontains
=
self
.
search_value
)
|
Q
(
text__icontains
=
self
.
search_value
)
query
=
Q
(
title__icontains
=
self
.
search_value
)
|
Q
(
text__icontains
=
self
.
search_value
)
query_set
=
query_set
.
filter
(
query
)
query_set
=
query_set
.
filter
(
query
)
...
...
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