zz修改3

{% extends "pages/page.html" %}


{% load mezzanine_tags %}


{% block main %}{{ block.super }}


{% editable page.richtextpage.content %}
{{ page.richtextpage.content|richtext_filters|safe }}
         
{% for page in blockpages %}
{% if  page.parent_id  >= 0%}
<li class="stress">
<h4><a href="{{ page.get_absolute_url }}" data-gaevent="home_recommend_articles:v1.1.1.1:article" title="{{ page.title }}" target="_blank">{{ page.title }}</a></h4> 
{{page.description}}                         
</li>
{%endif%} 
{% endfor %}




{% endeditable %}


<style type="text/css">
.cmnt-list {
display: block;
width: 100%;
clear: both;
margin: 10px 0;
padding: 0;
list-style: none;
}
.cmnt-list .cmnt {
display: block;
margin: 0 0 10px;
padding: 10px 10px 0;
background: #fff;
border: 1px solid #eee;
overflow: hidden;
}
li.odd {
background: #f8f8f8 !important;
}
li.comment {
background: #fff;
margin: 10px 0 20px 0;
padding: 20px 20px 0 20px;
border: 1px solid #eee;
position: relative;
}
.cmnt-img {
float: left;
margin: 0 10px 5px 0;
}
.cmnt-meta {
padding-top: 5px;
}
.cmnt-meta .c-title {
font-size: 12px;
margin-top: 5px;
color: #a4a4a4;
}
.cmnt-meta span {
display: block;
font-size: 13px;
line-height: 1;
}
.cmnt-meta .c-date {
float: right;
margin-top: -30px;
margin-left: 10px;
font-size: 12px;
color: #a4a4a4;
}
.cmnt-body {
clear: both;
padding: 0px 0;
font-size: 13px;
color: #4c4c4c;
word-break: break-all;
}
.cmnt-footer .c-like {
margin-top: -10px;
float: right;
}


.cmnt-box p {
margin-bottom: 10px;
}


#comments {
padding-top: 20px;
}


.sub-title {
position: relative;
color: #444;
font-size: 16px;
font-weight: normal;
border-bottom: 1px solid #e9e9e9;
}


h5 {
font: bold 15px/24px "Microsoft YaHei", 'Myriad Pro','Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}


.commentform .left {
float: left;
display: block;
width: 80px;
}
.commentform .right {
display: block;
margin-left: 90px;
}
.commentform .panel_head {
margin: 5px 0 !important;
}
.commentform .comment_btn {
width: 85px;
height: 26px;
margin: 10px 0 0 90px;
border: none;
background: url(../images/submit_bg.gif) no-repeat 0 0;
color: #666;
font: normal 12px/26px Arial, Helvetica, sans-serif;
text-align: center;
}
</style>


<script type="text/javascript">
function oncomment()
{
  //alert(1);
var str=document.getElementById("comment_content").value;
//alert(str);
    //GetSendUrl="http://127.0.0.1:8000";


GetSendUrl="comment"+"?text="+str;
var xmlHttp1;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp1=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
  }


    xmlHttp1.open("GET",GetSendUrl,true);
//xmlHttp1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
xmlHttp1.send(null);
xmlHttp1.onreadystatechange=function()
    {
        if (xmlHttp1.readyState == 4) 
        {
            var result = xmlHttp1.responseText;
            alert(result);
        }    
    }
}
</script>




<h5 id="comments" class="sub-title"><i class="glyphicon"></i>最新评论</h5>
<ul class="cmnt-list">
    <li id="comment-20017" class="comment cmnt even">
    
    <div class="cmnt-box">
        <div class="cmnt-header">
                            <a class="cmnt-img"><img width="37" height="37" src="./6_files/8fbdaaa5ea6d3b49c8c1c825aafeb5d9.png" alt=""></a>
                <div class="cmnt-meta">
                                        <span>chevrolets</span>
                                        <span class="c-title">&nbsp;</span>
                    <span class="c-date"><a href="http://blog.jobbole.com/44845/#comment-20017">2013/08/06</a></span>
                </div>
                    </div>
        <div class="cmnt-body">
            <p></p><p>看完了,谢谢分享</p>
<p></p>
                    </div>
                    <div class="cmnt-footer">


                
                <p class="c-like">
                    <a title="赞同" alt="赞同" class="20017voteflag  t-up  href-style vote-comment-up  register-user-only   " data-comment-id="20017"><i class="fa fa-thumbs-o-up"></i> <span id="20017voteuptotal">0</span></a>
                    <a title="反对" alt="反对" class="20017voteflag  t-down  href-style vote-comment-down  register-user-only   " data-comment-id="20017"><i class="fa fa-thumbs-o-down"></i> <span id="20017votedowntotal">0</span></a>


                    <a class="comment-reply-link register-user-only" href="http://blog.jobbole.com/44845/?replytocom=20017#respond" οnclick="return addComment.moveForm(&quot;comment-20017&quot;, &quot;20017&quot;, &quot;respond&quot;, &quot;44845&quot;)">回复 <i class="fa fa-reply"></i></a>
                </p>
            </div>
            </div>
    </li>        
</ul>
<div class="commentform">


<ul>
<li class="left">评论内容:</li>
<li class="right" style="position:relative;">
<textarea class="comment_content" name="comment_content" id="comment_content" style="width: 400px; height: 200px;">

</textarea></li>
<ul><input type="hidden" id="comment_replyId" name="comment_replyId"><input type="hidden" id="comment_userId" name="comment_userId" value="521203"><input type="hidden" id="commentId" name="commentId" value="">
<input type="submit" class="comment_btn" value="提交" οnclick="javascript:oncomment()">&nbsp;&nbsp;
 
</ul>
</ul>
</div>


{% endblock %}


{% block right_panel %}
{% include "hot.html" %}

{% endblock %}


def page(request, slug, template=u"pages/page.html", extra_context=None):
    """
         选一个template
    Select a template for a page and render it. The request
    object should have a ``page`` attribute that's added via
    ``mezzanine.pages.middleware.PageMiddleware``. The page is loaded
    earlier via middleware to perform various other functions.
    The urlpattern that maps to this view is a catch-all pattern, in
    which case the page attribute won't exist, so raise a 404 then.


    For template selection, a list of possible templates is built up
    based on the current page. This list is order from most granular
    match, starting with a custom template for the exact page, then
    adding templates based on the page's parent page, that could be
    used for sections of a site (eg all children of the parent).
    Finally at the broadest level, a template for the page's content
    type (it's model class) is checked for, and then if none of these
    templates match, the default pages/page.html is used.
    """
    print ("come this 1")
       
    reqparts = slug.split("/")
    reqslugs = ["/".join(reqparts[:i]) for i in range(1, len(reqparts) + 1)]
    
    
    if  reqparts[len(reqparts)-1].strip()== "comment":
        #print     request.GET.get("text", "")
        if 'text' in request.GET and request.GET['text']:
            text = request.GET['text']
            print (text)
        return HttpResponse("Hello world:"+text)
    
    if len(reqslugs)==1:
        pages  = Page.objects.all()
        outpages =[]
        for eachpage in pages:
            print (eachpage.id)
            parts = eachpage.slug.split("/")
            slugs = ["/".join(parts[:i]) for i in range(1, len(parts) + 1)]
          
            if  slugs[0].strip() == slug and len(slugs)==2 :
                print ("haha")
                print (eachpage.slug)
                print ("haha")
                outpages.append(eachpage)
        if  len(outpages)>0:      
            extra_context['blockpages'] = outpages
        
    from mezzanine.pages.middleware import PageMiddleware
    if not PageMiddleware.installed():
        raise ImproperlyConfigured("mezzanine.pages.middleware.PageMiddleware "
                                   "(or a subclass of it) is missing from " +
                                   "settings.MIDDLEWARE_CLASSES")


    if not hasattr(request, "page") or request.page.slug != slug:
        raise Http404


    # Check for a template name matching the page's slug. If the homepage
    # is configured as a page instance, the template "pages/index.html" is
    # used, since the slug "/" won't match a template name.
    template_name = str(slug) if slug != home_slug() else "index"
    templates = [u"pages/%s.html" % template_name]
    
    print (templates)
    method_template = request.page.get_content_model().get_template_name()
    if method_template:
        templates.insert(0, method_template)
    if request.page.content_model is not None:
        templates.append(u"pages/%s/%s.html" % (template_name,
            request.page.content_model))
    for parent in request.page.get_ascendants(for_user=request.user):
        parent_template_name = str(parent.slug)
        # Check for a template matching the page's content model.
        if request.page.content_model is not None:
            templates.append(u"pages/%s/%s.html" % (parent_template_name,
                request.page.content_model))
    # Check for a template matching the page's content model.
    if request.page.content_model is not None:
        templates.append(u"pages/%s.html" % request.page.content_model)
    templates.append(template)
    
    
    
    return render(request, templates, extra_context or {})



            c1=mycomment(comment_page='1',comment_text=text)
            c1.save()

class mycomment(models.Model):
    comment_page = models.CharField(max_length=30)
    comment_text = models.CharField(max_length=400)


    def __unicode__(self):
        return self.name


python manage.py sqlall django_comments

syncdb



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值