Skip to content

Commit

Permalink
fix a bug when using session by a unknown user
Browse files Browse the repository at this point in the history
  • Loading branch information
hustlzp committed Feb 26, 2013
1 parent b388c8f commit d38773f
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 431 deletions.
619 changes: 221 additions & 398 deletions xcz.sublime-workspace

Large diffs are not rendered by default.

Binary file modified xichuangzhu/controllers/product.pyc
Binary file not shown.
Binary file modified xichuangzhu/controllers/user.pyc
Binary file not shown.
7 changes: 6 additions & 1 deletion xichuangzhu/controllers/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def single_work(work_id):
# add bank row
work['Content'] = work['Content'].replace('<p>/</p>', "<div class='bank'></div>")
reviews = Review.get_reviews_by_work(work['WorkID'])
is_loved = Love.check_love(session['user_id'], work_id)

# check is loved
if 'user_id' in session:
is_loved = Love.check_love(session['user_id'], work_id)
else:
is_loved = False
return render_template('single_work.html', work=work, reviews=reviews, is_loved=is_loved)

# proc - love work
Expand Down
Binary file modified xichuangzhu/controllers/work.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions xichuangzhu/static/style/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ body #main-wap .tooltip-inner{padding-top:5px;padding-bottom:5px;}
#page-works .work-item .work-author{font-size:12px;font-weight:normal;}#page-works .work-item .work-author a{color:#333;}
#page-works .work-item .work-content{font-size:14px;line-height:22px;}
#page-single-work .work-title{font-size:25px;line-height:35px;margin-top:30px;margin-bottom:12px;font-weight:bold;text-align:center;clear:both;}
#page-single-work .work-author{text-align:center;margin-bottom:16px;padding-right:10px;font-size:16px;}
#page-single-work .work-foreword{font-size:18px;font-family:'kaiti';margin-bottom:10px;}
#page-single-work .work-author{text-align:center;margin-bottom:15px;padding-right:10px;font-size:16px;}
#page-single-work .work-content{font-family:'仿宋_GB2312';font-weight:bold;margin-bottom:30px;font-size:14pt;}#page-single-work .work-content sup{font-family:'yahei';font-size:12px;font-weight:normal;padding:5px 0px;cursor:pointer;color:#666;}
#page-single-work .work-type-shi{text-align:center;}
#page-single-work .work-type-ci{text-indent:2em;line-height:30px;}
Expand Down Expand Up @@ -73,6 +73,6 @@ body #main-wap .tooltip-inner{padding-top:5px;padding-bottom:5px;}
#page-people .review-item{margin-bottom:15px;}#page-people .review-item .review-title{font-size:16px;font-weight:bold;}
#page-people .review-item .review-extra-info{font-size:12px;line-height:22px;}
#page-people .review-item .review-content{font-size:12px;line-height:22px;}
#page-shop .products-wap{margin-top:15px;position:relative;}
#page-shop .products-wap{margin-top:15px;position:relative;}#page-shop .products-wap .product-item .product-image{opacity:0.9;}#page-shop .products-wap .product-item .product-image:hover{opacity:1;}
#page-single-product .product-image{margin-top:15px;}
#page-single-product .product-introduction{margin-bottom:10px;}
26 changes: 12 additions & 14 deletions xichuangzhu/static/style/page.less
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,23 @@ body{
clear: both;
}

.work-foreword{
font-size: 18px;
font-family: 'kaiti';
margin-bottom: 10px;
}

.work-author{
text-align: center;
margin-bottom: 15px;
margin-bottom: 16px;
padding-right: 10px;
font-size: 16px;
}

.work-foreword{
font-size: 18px;
font-family: 'kaiti';
margin-bottom: 10px;
}

.work-content{
font-family: '仿宋_GB2312';
font-weight: bold;
margin-bottom: 30px;
//font-size: 18px;
font-size: 14pt;

sup{
Expand All @@ -245,6 +244,8 @@ body{
}
.work-type-shi{
text-align: center;
p{
}
}
.work-type-ci{
text-indent: 2em;
Expand Down Expand Up @@ -670,16 +671,13 @@ body{
position: relative;

.product-item{
//float: left;
//margin: 0 20px 15px 0;

.product-image{
//width: 290px;
opacity: 0.9;

img{
//border-radius: 2px;
&:hover{
opacity: 1;
}

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions xichuangzhu/templates/people.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="user-signature">{{ people.Signature }}</div>
</div>

<h2>收藏</h2>
<h2>TA的收藏</h2>

{% for work in works %}
<div class="work-item">
Expand All @@ -29,7 +29,7 @@ <h2>收藏</h2>
</div>
{% endfor %}

<h2>TA 的点评</h2>
<h2>TA的点评</h2>

{% for review in reviews %}
<div class="review-item">
Expand Down
25 changes: 12 additions & 13 deletions xichuangzhu/templates/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,32 @@
<script type="text/javascript">

$(document).ready(function(){
var width = 290, h_gap = 20, v_gap = 20;
var width = 290, h_gap = 20, v_gap = 22;

var lefts = [0, width+v_gap, 2*(width+v_gap)],
var lefts = [0, width+h_gap, 2*(width+h_gap)],
tops = [0, 0, 0];

$('.product-image').each(function(index){
$(this).css({
'width': '290px',
'position': 'absolute',
'left': lefts[index%3] + 'px'
'left': lefts[index%3] + 'px',
'display': 'none'
})

// only when a img loaded, it's height becomes known.
$(this).load(function(){

$(this).css({
'display': 'block',
'top': tops[index%3] + 'px'
});

//
// overadd height
tops[index%3] += $(this).height() + v_gap;

$('.products-wap').css('height', tops[index%3] + 'px');

// set mother wap's height
$('.products-wap').css('height', (tops[index%3] + 20) + 'px');
});
});

Expand All @@ -41,13 +44,9 @@
<div class="products-wap clearfix">
{% for product in products %}
<div class="product-item">
<div>
<a href="{{ url_for('single_product', product_id=product.ProductID)}}">
<img class="product-image" title="{{ product.Product }}" src="{{ product.ImageUrl }}">
</a>
</div>

<div></div>
<a href="{{ url_for('single_product', product_id=product.ProductID)}}">
<img class="product-image" title="{{ product.Product }}" src="{{ product.ImageUrl }}">
</a>
</div>
{% endfor %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion xichuangzhu/templates/single_work.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

$(document).ready(function(){
$('.work-content sup').tooltip({
'placement': 'right'
//'placement': 'right'
});

$('.work-content sup').each(function(index){
Expand Down

0 comments on commit d38773f

Please sign in to comment.