Skip to content

Commit

Permalink
changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
gurusharan2 committed Apr 20, 2017
1 parent 1bf7e30 commit f09a105
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 103 deletions.
32 changes: 21 additions & 11 deletions template.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def read_secure_cookie(self, name):
return cookie_val and check_secure_val(cookie_val)

def check_login(self):
username = self.request.cookies.get("username")
username = self.read_secure_cookie("username")
if username:
return True
else:
Expand Down Expand Up @@ -286,7 +286,8 @@ def get(self, post_id):
self.render("like.html", error="cannot like your own post")
else:
all_likes = db.GqlQuery(
"select * from Like_db where post_id =:post_id", post_id=int(post_id))
"select * from Like_db where post_id =:post_id",
post_id=int(post_id))
flag = 0
if post.likes != 0:
likes = all_likes.get()
Expand Down Expand Up @@ -353,7 +354,9 @@ def post(self, post_id):
comment = self.request.get('comment_textarea')
if comment:
a = Comment_db(
post_id=int(post_id), posted_by=current_user, comment=comment)
post_id=int(post_id),
posted_by=current_user,
comment=comment)
a.put()
self.redirect("/blog")
else:
Expand All @@ -375,7 +378,8 @@ def get(self, comment_id):
self.render("comment_edit.html", a=comment)
else:
self.render(
"like.html", error="sorry! but you can edit only your post")
"like.html",
error="sorry! but you can edit only your post")
else:
self.redirect("/blog/login")

Expand All @@ -386,7 +390,7 @@ def post(self, comment_id):
a = int(comment_id)
key = db.Key.from_path('Comment_db', int(comment_id), parent=None)
comment_row = db.get(key)
if comment_row:
if comment_row.posted_by == self.read_secure_cookie("username"):
comment_row.comment = comment
comment_row.put()
self.redirect("/blog")
Expand All @@ -410,7 +414,8 @@ def get(self, comment_id):
self.redirect("/blog")
else:
self.render(
"like.html", error="sorry! but you can edit only your post")
"like.html",
error="sorry! but you can edit only your post")
else:
self.redirect("/blog/login")
# post edit
Expand All @@ -422,14 +427,18 @@ def get(self, post_id):
curr_user = self.read_secure_cookie("username")
if curr_user:
a = int(post_id)
key = db.Key.from_path('Blog', int(post_id), parent=None)
key = db.Key.from_path('Blog',
int(post_id),
parent=None)
post = db.get(key)
if post:
if post.posted_by == self.read_secure_cookie("username"):
self.render("post_edit.html",login="logout", a=post)
self.render("post_edit.html",
login="logout", a=post)
else:
self.render(
"like.html", error="sorry! but you can edit only your post")
"like.html",
error="sorry! but you can edit only your post")
else:
self.redirect("/blog/login")

Expand All @@ -440,7 +449,7 @@ def post(self, post_id):
a = int(post_id)
key = db.Key.from_path('Blog', int(post_id), parent=None)
post_row = db.get(key)
if post_row:
if post_row.posted_by == self.read_secure_cookie("username"):
post_row.post = edited_post
post_row.put()
self.redirect("/blog")
Expand All @@ -464,7 +473,8 @@ def get(self, Post_id):
self.redirect("/blog")
else:
self.render(
"like.html", error="sorry! but you can edit only your post")
"like.html",
error="sorry! but you can edit only your post")
else:
self.redirect("/blog/login")
# permalink
Expand Down
Binary file modified template.pyc
Binary file not shown.
45 changes: 45 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>blog</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style type="text/css">


h5{
margin-top: 0px;
text-align: right;
margin-right: 5px;
}
a{
text-decoration: None;
color: black;

}
ul{
list-style-type: None;
}
.addnew{
padding-left: 30px;
}
</style>
<body>
<div class="container">
<div class = "heading">
<h1><center>my blog</center></h1>
</div>
<div class="row">
<div class="col-md-3 addnew"><a href="/blog/Newpage"><h3>add a new post</h3></a></div>
<div class="col-md-5"></div>
<div class="col-md-2"><a href="/blog/{{ login }}"><h3 class= "login">{{ login }}</h3></a></div>
<div class="col-md-2"><a href="/blog/signup"><h3 class="right">{{ signup }}</h3></a></div>
</div >
<div>
{% block content %}
{% endblock %}
</div>
</div>

</body>
</html>
14 changes: 6 additions & 8 deletions templates/comment_edit.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{% extends "base.html" %}

{% block content %}
<div>
<form method="post">
<input type="input" name="comment_edit" value="{{a.comment}}">
<input type="submit" name="submit" label="submit">
</form>
<a class ="btn btn-default" href="/blog">cancel</a>
</body>
</html>
</div>
{% endblock %}
44 changes: 4 additions & 40 deletions templates/front.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<title>blog</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style type="text/css">


h5{
margin-top: 0px;
text-align: right;
margin-right: 5px;
}
a{
text-decoration: None;
color: black;

}
ul{
list-style-type: None;
}
.addnew{
padding-left: 30px;
}
</style>
<body>
<div class="container">
<div class = "heading">
<h1><center>my blog</center></h1>
</div>
<div class="row">
<div class="col-md-3 addnew"><a href="/blog/Newpage"><h3>add a new post</h3></a></div>
<div class="col-md-5"></div>
<div class="col-md-2"><a href="/blog/{{ login }}"><h3 class= "login">{{ login }}</h3></a></div>
<div class="col-md-2"><a href="/blog/signup"><h3 class="right">{{ signup }}</h3></a></div>
</div>
{% extends "base.html" %}

{% block content %}


<ul>
Expand Down Expand Up @@ -86,6 +51,5 @@ <h2>comments</h2>
</li>
{% endfor %}
</ul>
</div>
</body>
</html>
{% endblock %}

12 changes: 4 additions & 8 deletions templates/like.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{% extends "base.html" %}

{% block content %}
<h1>{{ error }}</h1>
</body>
</html>
{% endblock%}
42 changes: 6 additions & 36 deletions templates/post_edit.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>blog</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<style type="text/css">

{% extends "base.html" %}

h5{
margin-top: 0px;
text-align: right;
margin-right: 5px;
}
a{
text-decoration: None;
color: black;

}
ul{
list-style-type: None;
}
.addnew{
padding-left: 30px;
}
</style>
<body>
<div class="container">
<h1><center>my blog</center></h1>
<div class="row">
<div class="col-md-3 addnew"><a href="/blog/Newpage"><h3>add a new post</h3></a></div>
<div class="col-md-5"></div>
<div class="col-md-2"><a href="/blog/{{ login }}"><h3 class= "login">{{ login }}</h3></a></div>
<div class="col-md-2"><a href="/blog/signup"><h3 class="right">{{ signup }}</h3></a></div>
</div>
{% block content %}
<div>
<h1>edit post</h1>
<hr>
<form method="post">
<input type="input" name="comment_edit" value="{{a.post}}">
<input type="submit" name="submit" label="submit">
</form>
<a class ="btn btn-default" href="/blog">cancel</a>
</div>
</body>
</html>
</div>
{% endblock %}

0 comments on commit f09a105

Please sign in to comment.