Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신은섭(Shin Eun Seop)
/
2018-1-d.cloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
신은섭(Shin Eun Seop)
2018-05-17 11:43:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
16be61fc8b588c5c9eb2b18d48b65eccf16ec3c0
16be61fc
1 parent
7ed4068d
add draft
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
2 deletions
dcloud/website/templates/website/base.html
dcloud/website/templates/website/post_detail.html
dcloud/website/templates/website/post_draft_list.html
dcloud/website/urls.py
dcloud/website/views.py
dcloud/website/templates/website/base.html
View file @
16be61f
...
...
@@ -11,6 +11,7 @@
<div
class=
"page-header"
>
{% if user.is_authenticated %}
<a
href=
"{% url 'post_new' %}"
class=
"top-menu"
><span
class=
"glyphicon glyphicon-plus"
></span></a>
<a
href=
"{% url 'post_draft_list' %}"
class=
"top-menu"
><span
class=
"glyphicon glyphicon-edit"
></span></a>
{% endif %}
<h1><a
href=
"/"
>
Django Girls Blog
</a></h1>
</div>
...
...
dcloud/website/templates/website/post_detail.html
View file @
16be61f
...
...
@@ -7,6 +7,8 @@
<div
class=
"date"
>
{{ post.published_date }}
</div>
{% else %}
<a
class=
"btn btn-default"
href=
"{% url 'post_publish' pk=post.pk %}"
>
Publish
</a>
{% endif %}
{% if user.is_authenticated %}
<a
class=
"btn btn-default"
href=
"{% url 'post_edit' pk=post.pk %}"
><span
class=
"glyphicon glyphicon-pencil"
></span></a>
...
...
dcloud/website/templates/website/post_draft_list.html
0 → 100644
View file @
16be61f
{% extends 'website/base.html' %}
{% block content %}
{% for post in posts %}
<div
class=
"post"
>
<p
class=
"date"
>
created: {{ post.created_date|date:'d-m-Y' }}
</p>
<h1><a
href=
"{% url 'post_detail' pk=post.pk %}"
>
{{ post.title }}
</a></h1>
<p>
{{ post.text|truncatechars:200 }}
</p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
dcloud/website/urls.py
View file @
16be61f
...
...
@@ -6,6 +6,8 @@ urlpatterns = [
url
(
r'^post/(?P<pk>\d+)/$'
,
views
.
post_detail
,
name
=
'post_detail'
),
url
(
r'^post/new/$'
,
views
.
post_new
,
name
=
'post_new'
),
url
(
r'^post/(?P<pk>\d+)/edit/$'
,
views
.
post_edit
,
name
=
'post_edit'
),
url
(
r'^drafts/$'
,
views
.
post_draft_list
,
name
=
'post_draft_list'
),
url
(
r'^post/(?P<pk>\d+)/publish/$'
,
views
.
post_publish
,
name
=
'post_publish'
),
url
(
r'^files/'
,
views
.
file_list
,
name
=
'file_list'
),
]
\ No newline at end of file
...
...
dcloud/website/views.py
View file @
16be61f
...
...
@@ -30,7 +30,7 @@ def post_new(request):
return
redirect
(
'post_detail'
,
pk
=
post
.
pk
)
else
:
form
=
PostForm
()
return
render
(
request
,
'
blog
/post_edit.html'
,
{
'form'
:
form
})
return
render
(
request
,
'
website
/post_edit.html'
,
{
'form'
:
form
})
def
post_edit
(
request
,
pk
):
post
=
get_object_or_404
(
Post
,
pk
=
pk
)
...
...
@@ -44,4 +44,13 @@ def post_edit(request, pk):
return
redirect
(
'post_detail'
,
pk
=
post
.
pk
)
else
:
form
=
PostForm
(
instance
=
post
)
return
render
(
request
,
'blog/post_edit.html'
,
{
'form'
:
form
})
\ No newline at end of file
return
render
(
request
,
'website/post_edit.html'
,
{
'form'
:
form
})
def
post_draft_list
(
request
):
posts
=
Post
.
objects
.
filter
(
published_date__isnull
=
True
)
.
order_by
(
'created_date'
)
return
render
(
request
,
'website/post_draft_list.html'
,
{
'posts'
:
posts
})
def
post_publish
(
request
,
pk
):
post
=
get_object_or_404
(
Post
,
pk
=
pk
)
post
.
publish
()
return
redirect
(
'post_detail'
,
pk
=
pk
)
...
...
Please
register
or
login
to post a comment