Created
March 19, 2010 22:08
-
-
Save hlian/338252 to your computer and use it in GitHub Desktop.
scg.apps.courses.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import django.utils.simplejson as json | |
from django.core.urlresolvers import reverse | |
from django.http import HttpResponse | |
from django.shortcuts import render_to_response | |
from django.template import RequestContext | |
from scg.apps.courses.models import Course | |
from scg.apps.reviews.models import CourseReview | |
def course(request, cid=None): | |
c = Course.objects.get(cid=cid) | |
r = CourseReview.objects.filter(course=c) | |
first, second = None, None | |
if len(r) >= 1: | |
first = r[0].comment | |
if len(r) >= 2: | |
second = r[1].comment | |
data = { | |
'first': first, | |
'second': second, | |
'link': reverse('scg.apps.courses.views.course_detail', args=[c.cid]), | |
} | |
return HttpResponse(json.dumps(data), mimetype='text/plain') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment