Example #1
0
def addDiscussion(request):
    response = dict(content='', start='0', object='')
    title = request.POST.get('title', '')
    usr = request.user.id
    presentationID = request.POST.get('presentationID', '')
    startTime = request.POST.get('startTime', '')
    endTime = request.POST.get('endTime', '')
    if endTime != '':
        endTime = int(endTime)
    else: 
    	endTime = False
    #timestamp = request.POST.get('timestamp', '')
    timestamp = datetime.datetime.now()
    tags = request.POST.get('tags', '')
    note = request.POST.get('note', '')
    index = request.POST.get('index', '')
    try:
	    discussion = api.addDiscussion(str(title), int(usr), int(presentationID), int(startTime), endTime, timestamp, str(tags), str(note))
	    discussion.isSubscribed = 1
	    discussion.counter = index
	    response['content'] = render_to_string('discussion.html', {'result': api.formatDiscussions([discussion])})
	    discussion = simplejson.loads(serializers.serialize('json', [discussion], indent=4))
	    response['start'] = startTime
	    response['object'] = discussion
    except DiscussionTimeOutOfRangeException as e:
    	response['error'] = e.value
    except APIException as e:
    	response['error'] = "There was a problem with your request. Please try again."
    	api.log_error("APIException thrown ("+str(type(e))+"): "+e.value)
    serialised = simplejson.dumps(response)
    return HttpResponse(serialised, mimetype='application/json')
Example #2
0
def commented(request):
	context = initContext(request.user)
	
	if request.user.is_authenticated():
		context["discussions"] = api.formatDiscussions(api.getMyDiscussions(request.user.id))
		context["comments"] = api.formatComments(api.getMyComments(request.user.id))
		context["notification"] = api.getNotifications(request.user.id)
	else:
		context["error_text"] = "You may need to <a href='/'>login</a>."
		return render(request, 'apierror.html', context)
	
	return render(request, 'commented.html', context)
Example #3
0
	def test_normal(self):
		#just checking for errors currently
		discussions = api.formatDiscussions([Discussion.objects.get(id=DISCUSSION_ID)])