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-23 11:23:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c9344380c35a3319ed3da70c75e4fff2ef22d629
c9344380
1 parent
aadadf7a
change some thing
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
73 deletions
dcloud/website/models.py
dcloud/website/templates/registration/delete_account_success.html
dcloud/website/urls.py
dcloud/website/views.py
dcloud/website/models.py
View file @
c934438
from
django.db
import
models
from
django.utils
import
timezone
class
Post
(
models
.
Model
):
author
=
models
.
ForeignKey
(
'auth.User'
,
on_delete
=
models
.
CASCADE
)
title
=
models
.
CharField
(
max_length
=
200
)
text
=
models
.
TextField
()
created_date
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
published_date
=
models
.
DateTimeField
(
blank
=
True
,
null
=
True
)
def
publish
(
self
):
self
.
published_date
=
timezone
.
now
()
self
.
save
()
def
__str__
(
self
):
return
self
.
title
...
...
dcloud/website/templates/registration/delete_account_success.html
View file @
c934438
...
...
@@ -2,5 +2,5 @@
{% block content %}
<h1>
DELTED
</h1>
<!--TODO logout -->
<!--TODO
AUTO
logout -->
{% endblock %}
\ No newline at end of file
...
...
dcloud/website/urls.py
View file @
c934438
from
django.conf.urls
import
url
from
website
import
views
,
auth_views
from
django.shortcuts
import
redirect
urlpatterns
=
[
# blog
url
(
r'^$'
,
views
.
post_list
,
name
=
'post_list'
),
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'^$'
,
redirect
(
'login'
)),
url
(
r'^files/'
,
views
.
file_list
,
name
=
'file_list'
),
url
(
r'^accounts/signup/$'
,
auth_views
.
signup
,
name
=
'signup'
),
url
(
r'^accounts/delete_account/$'
,
auth_views
.
delete_account
,
name
=
'delete_account'
),
...
...
dcloud/website/views.py
View file @
c934438
...
...
@@ -9,52 +9,3 @@ from website.forms import PostForm
def
file_list
(
request
):
files
=
File
.
objects
.
all
()
return
render
(
request
,
'website/file_list.html'
,
{
'files'
:
files
})
def
post_list
(
request
):
posts
=
Post
.
objects
.
filter
(
published_date__lte
=
timezone
.
now
())
.
order_by
(
'published_date'
)
return
render
(
request
,
'website/post_list.html'
,
{
'posts'
:
posts
})
def
post_detail
(
request
,
pk
):
post
=
get_object_or_404
(
Post
,
pk
=
pk
)
return
render
(
request
,
'website/post_detail.html'
,
{
'post'
:
post
})
@login_required
def
post_new
(
request
):
if
request
.
method
==
"POST"
:
form
=
PostForm
(
request
.
POST
)
if
form
.
is_valid
():
post
=
form
.
save
(
commit
=
False
)
post
.
author
=
request
.
user
post
.
published_date
=
timezone
.
now
()
post
.
save
()
return
redirect
(
'post_detail'
,
pk
=
post
.
pk
)
else
:
form
=
PostForm
()
return
render
(
request
,
'website/post_edit.html'
,
{
'form'
:
form
})
@login_required
def
post_edit
(
request
,
pk
):
post
=
get_object_or_404
(
Post
,
pk
=
pk
)
if
request
.
method
==
"POST"
:
form
=
PostForm
(
request
.
POST
,
instance
=
post
)
if
form
.
is_valid
():
post
=
form
.
save
(
commit
=
False
)
post
.
author
=
request
.
user
post
.
published_date
=
timezone
.
now
()
post
.
save
()
return
redirect
(
'post_detail'
,
pk
=
post
.
pk
)
else
:
form
=
PostForm
(
instance
=
post
)
return
render
(
request
,
'website/post_edit.html'
,
{
'form'
:
form
})
@login_required
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
})
@login_required
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