Toggle navigation
Toggle navigation
This project
Loading...
Sign in
임태민
/
Mapmory
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
홍지윤
2021-05-22 14:03:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b1d355eca13096c1b6dfc81767b08f84f6a88940
b1d355ec
1 parent
2a07a51a
Update Project directory
- edit page 띄우기 완료 - edit 기능까지 구현 완료!
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
Project/models/Post.js
Project/routes/posts.js
Project/views/posts/edit.ejs
Project/models/Post.js
View file @
b1d355e
...
...
@@ -7,8 +7,8 @@ var postSchema = mongoose.Schema({
address
:{
type
:
String
,
required
:[
true
,
'address is required!'
]},
body
:{
type
:
String
,
required
:[
true
,
'Content is required!'
]},
author
:{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
ref
:
'user'
,
required
:
true
},
createdAt
:{
type
:
Date
,
default
:
Date
.
now
},
updatedAt
:{
type
:
Date
}
,
createdAt
:{
type
:
Date
,
default
:
Date
.
now
()
},
updatedAt
:{
type
:
Date
}
});
...
...
Project/routes/posts.js
View file @
b1d355e
...
...
@@ -4,6 +4,7 @@ var Post = require('../models/Post');
var
util
=
require
(
'../util'
);
// Post home
router
.
get
(
'/'
,
function
(
req
,
res
){
Post
.
find
({})
...
...
@@ -55,8 +56,8 @@ router.get('/:id/edit', util.isLoggedin, checkPermission, function(req, res){
var
errors
=
req
.
flash
(
'errors'
)[
0
]
||
{};
if
(
!
post
){
Post
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
post
){
if
(
err
){
return
res
.
j
oi
n
(
err
)};
res
.
render
(
'posts/edit'
,
{
post
s
:
post
,
errors
:
errors
});
if
(
err
){
return
res
.
j
so
n
(
err
)};
res
.
render
(
'posts/edit'
,
{
post
:
post
,
errors
:
errors
});
});
}
else
{
...
...
@@ -73,9 +74,9 @@ router.put('/:id', util.isLoggedin, checkPermission, function(req, res){
if
(
err
){
req
.
flash
(
'post'
,
req
.
body
),
req
.
flash
(
'errors'
,
util
.
parseError
(
err
));
return
res
.
redirect
(
'/posts/'
+
req
.
params
,
id
+
'/edit'
);
return
res
.
redirect
(
'/posts/'
+
req
.
params
.
id
+
'/edit'
);
};
res
.
redirect
(
'posts/'
+
req
.
params
.
id
);
res
.
redirect
(
'
/
posts/'
+
req
.
params
.
id
);
});
});
...
...
Project/views/posts/edit.ejs
View file @
b1d355e
...
...
@@ -28,6 +28,14 @@
</div>
<div
class=
"form-group"
>
<label
for=
"address"
>
address
</label>
<input
type=
"text"
id=
"address"
name=
"address"
value=
"<%= post.address %>"
class=
"form-control <%= (errors.address)?'is-invalid':'' %>"
>
<
% if(errors.address){ %>
<span
class=
"invalid-feedback"
>
<
%= errors.address.message %>
</span>
<
% } %>
</div>
<div
class=
"form-group"
>
<label
for=
"body"
>
Body
</label>
<textarea
id=
"body"
name=
"body"
rows=
"5"
class=
"form-control <%= (errors.body)?'is-invalid':''%>"
>
<
%= post.body %>
</textarea>
<
% if(errors.body){ %>
...
...
@@ -49,5 +57,6 @@
</form>
</div>
<
%- include('../partials/gmap') %>
</body>
</html>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment