guowee / comment / views.py

# Create your views here.
from django.contrib.auth.models import User 
from django.contrib.auth.decorators import login_required
from django.http import Http404, HttpResponse, HttpResponseRedirect,HttpResponseServerError 
from django.shortcuts import render_to_response
from comment.models import *
from appstore.get_apple_appstore import do_encode

def index_comment(request):
    if request.method == 'GET':
        return render_to_response('post_comment.html',
                                                {'user':request.user,
                                                'data':})
    else:
        return  HttpResponse('Please Use GET Method')

def add_newpost(request):
    user=request.user
    if request.method == 'GET':
        return render_to_response('post_comment.html',
                                                {'user':request.user,
                                                'data':})
    elif  request.method == 'POST': 
        p=post()
        p.author=user
        p.content=do_encode(request.POST['content'])
        p.save()
        return HttpResponse('some html')
    else:
        raise HttpResponseServerError
        
def post_comment(request,post_id):
    user=request.user
    if request.method == 'POST':
        comm=comment()
        comm.author=user
        comm.post=post.object.get(id=int(post_id))
        comm.content=do_encode(request.POST['content'])
        comm.save()
        start=len(data.comments_set.all())
        return HttpResponseRedirect('/comment/%s?start=%s' %(post_id,start))
        
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.