diff --git a/auth/models.py b/auth/models.py index 1a7bf6c221..88cdd2da61 100644 --- a/auth/models.py +++ b/auth/models.py @@ -1,6 +1,7 @@ +import uuid + from django.db import models from django.contrib.auth.models import User -import uuid class UserProfile(models.Model): ## CRITICAL TODO/SECURITY diff --git a/auth/views.py b/auth/views.py index fa8c56933f..56c9cd81de 100644 --- a/auth/views.py +++ b/auth/views.py @@ -1,18 +1,19 @@ +import json import logging +import random +import string -from djangomako.shortcuts import render_to_response, render_to_string -from django.contrib.auth.models import User -from django.shortcuts import redirect +from django.conf import settings from django.contrib.auth import logout, authenticate, login from django.contrib.auth.models import User -from django.http import HttpResponse -import json -from models import Registration, UserProfile -from django.conf import settings +from django.contrib.auth.models import User from django.core.context_processors import csrf from django.core.validators import validate_email, validate_slug -import random, string from django.db import connection +from django.http import HttpResponse +from django.shortcuts import redirect +from djangomako.shortcuts import render_to_response, render_to_string +from models import Registration, UserProfile log = logging.getLogger("mitx.auth") diff --git a/circuit/models.py b/circuit/models.py index ada1a5f295..cc103e1af8 100644 --- a/circuit/models.py +++ b/circuit/models.py @@ -1,6 +1,7 @@ +import uuid + from django.db import models from django.contrib.auth.models import User -import uuid class ServerCircuit(models.Model): # Later, add owner, who can edit, part of what app, etc. diff --git a/circuit/views.py b/circuit/views.py index 235c25b69f..c8840484a8 100644 --- a/circuit/views.py +++ b/circuit/views.py @@ -1,24 +1,26 @@ -from djangomako.shortcuts import render_to_response, render_to_string -from django.shortcuts import redirect +import json import os + +import xml.etree.ElementTree + from django.conf import settings from django.http import Http404 -from models import ServerCircuit -import json -import xml.etree.ElementTree from django.http import HttpResponse +from django.shortcuts import redirect +from djangomako.shortcuts import render_to_response, render_to_string + +from models import ServerCircuit def circuit_line(circuit): + ''' Returns string for an appropriate input element for a circuit. + TODO: Rename. ''' if not circuit.isalnum(): raise Http404() try: sc = ServerCircuit.objects.get(name=circuit) schematic = sc.schematic - print "Got" except: schematic = '' - print "not got" - print "X", schematic circuit_line = xml.etree.ElementTree.Element('input') circuit_line.set('type', 'hidden') diff --git a/courseware/capa/calc.py b/courseware/capa/calc.py index ef34e186e2..bd4136d393 100644 --- a/courseware/capa/calc.py +++ b/courseware/capa/calc.py @@ -1,5 +1,6 @@ import math import operator + from pyparsing import Word, alphas, nums, oneOf, Literal from pyparsing import ZeroOrMore, OneOrMore, StringStart from pyparsing import StringEnd, Optional, Forward diff --git a/courseware/capa/capa_problem.py b/courseware/capa/capa_problem.py index a6021af3bc..b7ac8940fe 100644 --- a/courseware/capa/capa_problem.py +++ b/courseware/capa/capa_problem.py @@ -1,18 +1,24 @@ -import random, numpy, math, scipy -import struct, os +import copy +import math +import numpy +import os +import random import re +import scipy +import struct + from lxml import etree from lxml.etree import Element -import copy + from mako.template import Template -from courseware.content_parser import xpath_remove -import calc, eia from util import contextualize_text - from inputtypes import textline, schematic from responsetypes import numericalresponse, formularesponse, customresponse, schematicresponse +import calc +import eia + response_types = {'numericalresponse':numericalresponse, 'formularesponse':formularesponse, 'customresponse':customresponse, @@ -52,12 +58,14 @@ class LoncapaProblem(object): self.done = False self.filename = filename - if id!=None: + if id: self.problem_id = id else: - self.problem_id = filename + print "NO ID" + raise Exception("This should never happen (183)") + #self.problem_id = filename - if state!=None: + if state: if 'seed' in state: self.seed = state['seed'] if 'student_answers' in state: @@ -68,7 +76,7 @@ class LoncapaProblem(object): self.done = state['done'] # TODO: Does this deplete the Linux entropy pool? Is this fast enough? - if self.seed == None: + if not self.seed: self.seed=struct.unpack('i', os.urandom(4))[0] ## Parse XML file @@ -102,7 +110,7 @@ class LoncapaProblem(object): for key in self.correct_map: if self.correct_map[key] == u'correct': correct += 1 - if self.student_answers == None or len(self.student_answers)==0: + if (not self.student_answers) or len(self.student_answers)==0: return {'score':0, 'total':self.get_max_score()} else: @@ -132,7 +140,7 @@ class LoncapaProblem(object): for entry in problems_simple.xpath("//"+"|//".join(response_properties+entry_types)): answer = entry.get('correct_answer') - if answer != None: + if answer: answer_map[entry.get('id')] = contextualize_text(answer, self.context) return answer_map @@ -162,7 +170,7 @@ class LoncapaProblem(object): status = self.correct_map[problemtree.get('id')] value = "" - if self.student_answers != None and problemtree.get('id') in self.student_answers: + if self.student_answers and problemtree.get('id') in self.student_answers: value = self.student_answers[problemtree.get('id')] return html_special_response[problemtree.tag](problemtree, value, status) #TODO @@ -170,7 +178,7 @@ class LoncapaProblem(object): tree=Element(problemtree.tag) for item in problemtree: subitems = self.extract_html(item) - if subitems != None: + if subitems: for subitem in subitems: tree.append(subitem) for (key,value) in problemtree.items(): diff --git a/courseware/capa/inputtypes.py b/courseware/capa/inputtypes.py index db98363872..c3b59a4537 100644 --- a/courseware/capa/inputtypes.py +++ b/courseware/capa/inputtypes.py @@ -1,8 +1,8 @@ -from djangomako.shortcuts import render_to_response, render_to_string - from lxml.etree import Element from lxml import etree +from djangomako.shortcuts import render_to_response, render_to_string + class textline(object): @staticmethod def render(element, value, state): diff --git a/courseware/capa/responsetypes.py b/courseware/capa/responsetypes.py index d925f31b35..93ebac85f9 100644 --- a/courseware/capa/responsetypes.py +++ b/courseware/capa/responsetypes.py @@ -1,10 +1,15 @@ -import random, numpy, math, scipy, json -from util import contextualize_text +import json +import math +import numpy +import random +import scipy + from calc import evaluator -import random, math from django.conf import settings -import eia +from util import contextualize_text + import calc +import eia # TODO: Should be the same object as in capa_problem global_context={'random':random, diff --git a/courseware/capa/unit.py b/courseware/capa/unit.py index c6a4d4591a..2cbe4f93f0 100644 --- a/courseware/capa/unit.py +++ b/courseware/capa/unit.py @@ -1,6 +1,8 @@ import math -from numpy import eye, array import operator + +from numpy import eye, array + from pyparsing import Word, alphas, nums, oneOf, Literal from pyparsing import ZeroOrMore, OneOrMore, StringStart from pyparsing import StringEnd, Optional, Forward diff --git a/courseware/content_parser.py b/courseware/content_parser.py index c5c0600f9d..fd6fbb2d58 100644 --- a/courseware/content_parser.py +++ b/courseware/content_parser.py @@ -1,13 +1,15 @@ -try: +import json +import hashlib + +from lxml import etree + +try: # This lets us do __name__ == ='__main__' from django.conf import settings from auth.models import UserProfile except: settings = None -from lxml import etree -import json -import hashlib ''' This file will eventually form an abstraction layer between the course XML file and the rest of the system. diff --git a/courseware/models.py b/courseware/models.py index cee61f336b..5c706f10a8 100644 --- a/courseware/models.py +++ b/courseware/models.py @@ -1,43 +1,6 @@ from django.db import models from django.contrib.auth.models import User -# class Organization(models.Model): -# # Tree structure implemented such that child node has left ID -# # greater than all parents, and right ID less than all parents -# left_tree_id = models.IntegerField(unique=True, db_index=True) -# right_tree_id = models.IntegerField(unique=True, db_index=True) -# # This is a duplicate, but we keep this to enforce unique name -# # constraint -# parent = models.ForeignKey('self', null=True, blank=True) -# name = models.CharField(max_length=200) -# ORG_TYPES= (('course','course'), -# ('chapter','chapter'), -# ('section','section'),) -# org_type = models.CharField(max_length=32, choices=ORG_TYPES) -# available = models.DateField(null=True, blank=True) -# due = models.DateField(null=True, blank=True) -# # JSON dictionary of metadata: -# # Time for a video, format of a section, etc. -# metadata = models.TextField(null=True, blank=True) - -# class Modules(models.Model): -# MOD_TYPES = (('hw','homework'), -# ('vid','video_clip'), -# ('lay','layout'), -# (),) -# module_type = models.CharField(max_length=100) -# left_tree_id = models.IntegerField(unique=True, db_index=True) -# right_tree_id = models.IntegerField(unique=True, db_index=True) - -# LAYOUT_TYPES = (('leaf','leaf'), -# ('tab','tab'), -# ('seq','sequential'), -# ('sim','simultaneous'),) -# layout_type = models.CharField(max_length=32, choices=LAYOUT_TYPES) -# data = models.TextField(null=True, blank=True) - -#class HomeworkProblems(models.Model): - class StudentModule(models.Model): # For a homework problem, contains a JSON # object consisting of state diff --git a/courseware/module_render.py b/courseware/module_render.py index 4bfbccf8b3..96833cc32d 100644 --- a/courseware/module_render.py +++ b/courseware/module_render.py @@ -1,41 +1,36 @@ -from django.http import HttpResponse -from django.template import Context, loader -from djangomako.shortcuts import render_to_response, render_to_string -import json, os, sys -from django.core.context_processors import csrf - -from django.db import connection -from django.template import Context -from django.contrib.auth.models import User -from auth.models import UserProfile -from django.shortcuts import redirect - import StringIO -import track.views - -from django.http import Http404 - +import json +import os +import sys +import sys import urllib +import uuid -import courseware.modules.capa_module -import courseware.modules.video_module -import courseware.modules.vertical_module -import courseware.modules.html_module -import courseware.modules.schematic_module -import courseware.modules.seq_module - -from models import StudentModule - -import urllib +from lxml import etree from django.conf import settings +from django.contrib.auth.models import User +from django.core.context_processors import csrf +from django.db import connection +from django.http import Http404 +from django.http import HttpResponse +from django.shortcuts import redirect +from django.template import Context +from django.template import Context, loader +from djangomako.shortcuts import render_to_response, render_to_string + +from auth.models import UserProfile +from models import StudentModule +import track.views import courseware.content_parser as content_parser -import sys - -from lxml import etree -import uuid +import courseware.modules.capa_module +import courseware.modules.html_module +import courseware.modules.schematic_module +import courseware.modules.seq_module +import courseware.modules.vertical_module +import courseware.modules.video_module ## TODO: Add registration mechanism modx_modules={'problem':courseware.modules.capa_module.LoncapaModule, @@ -93,7 +88,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): ajax_return=instance.handle_ajax(dispatch, request.POST) # Save the state back to the database s.state=instance.get_state() - if instance.get_score() != None: + if not instance.get_score(): s.grade=instance.get_score()['score'] s.save() # Return whatever the module wanted to return to the client/caller @@ -107,15 +102,14 @@ def render_x_module(user, request, xml_module, module_object_preload): module_id=xml_module.get('id') #module_class.id_attribute) or "" # Grab state from database - s = object_cache(module_object_preload, - user, - module_type, - module_id) + smod = object_cache(module_object_preload, + user, + module_type, + module_id) - if s == None: # If nothing in the database... + if not smod: # If nothing in the database... state=None else: - smod = s state = smod.state # Create a new instance @@ -128,7 +122,7 @@ def render_x_module(user, request, xml_module, module_object_preload): render_function = lambda x: render_module(user, request, x, module_object_preload)) # If instance wasn't already in the database, create it - if s == None: + if not smod: smod=StudentModule(student=user, module_type = module_type, module_id=module_id, diff --git a/courseware/modules/capa_module.py b/courseware/modules/capa_module.py index 591f9c7516..8eeeec1f3c 100644 --- a/courseware/modules/capa_module.py +++ b/courseware/modules/capa_module.py @@ -1,21 +1,27 @@ -import random, numpy, math, scipy, sys, StringIO, os, struct, json -from x_module import XModule -import sys - -from courseware.capa.capa_problem import LoncapaProblem -from django.http import Http404 - +import StringIO +import datetime import dateutil import dateutil.parser -import datetime - -import courseware.content_parser as content_parser +import json +import math +import numpy +import os +import random +import scipy +import struct +import sys +import traceback from lxml import etree ## TODO: Abstract out from Django from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string +from django.http import Http404 + +from x_module import XModule +from courseware.capa.capa_problem import LoncapaProblem +import courseware.content_parser as content_parser class LoncapaModule(XModule): ''' Interface between capa_problem and x_module. Originally a hack @@ -231,6 +237,8 @@ class LoncapaModule(XModule): for key in get: answers['_'.join(key.split('_')[1:])]=get[key] + print "XXX", answers, get + event_info['answers']=answers # Too late. Cannot submit @@ -255,6 +263,7 @@ class LoncapaModule(XModule): correct_map = self.lcp.grade_answers(answers) except: self.lcp = LoncapaProblem(filename, id=lcp_id, state=old_state) + traceback.print_exc() print {'error':sys.exc_info(), 'answers':answers, 'seed':self.lcp.seed, diff --git a/courseware/modules/html_module.py b/courseware/modules/html_module.py index 0c5a0edae2..61c903d41c 100644 --- a/courseware/modules/html_module.py +++ b/courseware/modules/html_module.py @@ -1,12 +1,12 @@ -from x_module import XModule -from lxml import etree - import json ## TODO: Abstract out from Django from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string +from x_module import XModule +from lxml import etree + class HtmlModule(XModule): id_attribute = 'filename' diff --git a/courseware/modules/schematic_module.py b/courseware/modules/schematic_module.py index a32de9b275..9c7d291b92 100644 --- a/courseware/modules/schematic_module.py +++ b/courseware/modules/schematic_module.py @@ -1,11 +1,11 @@ -from x_module import XModule - import json ## TODO: Abstract out from Django from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string +from x_module import XModule + class SchematicModule(XModule): id_attribute = 'id' diff --git a/courseware/modules/seq_module.py b/courseware/modules/seq_module.py index 737f9ac2e9..2a91b0caa0 100644 --- a/courseware/modules/seq_module.py +++ b/courseware/modules/seq_module.py @@ -1,13 +1,14 @@ -from x_module import XModule -from lxml import etree -from django.http import Http404 - import json +from lxml import etree + ## TODO: Abstract out from Django +from django.http import Http404 from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string +from x_module import XModule + class SequentialModule(XModule): ''' Layout module which lays out content in a temporal sequence ''' diff --git a/courseware/modules/vertical_module.py b/courseware/modules/vertical_module.py index 73a7a6c521..5530e22415 100644 --- a/courseware/modules/vertical_module.py +++ b/courseware/modules/vertical_module.py @@ -1,12 +1,12 @@ -from x_module import XModule -from lxml import etree - import json ## TODO: Abstract out from Django from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string +from x_module import XModule +from lxml import etree + class VerticalModule(XModule): id_attribute = 'id' diff --git a/courseware/modules/video_module.py b/courseware/modules/video_module.py index 93650cb6d3..69a0837403 100644 --- a/courseware/modules/video_module.py +++ b/courseware/modules/video_module.py @@ -1,10 +1,11 @@ -import logging import json +import logging + +from lxml import etree ## TODO: Abstract out from Django from django.conf import settings from djangomako.shortcuts import render_to_response, render_to_string -from lxml import etree from x_module import XModule diff --git a/courseware/views.py b/courseware/views.py index 4345084ec0..9254da1e1e 100644 --- a/courseware/views.py +++ b/courseware/views.py @@ -19,8 +19,9 @@ from lxml import etree from auth.models import UserProfile from models import StudentModule -from module_render import * # TODO: Clean up +from module_render import render_module, modx_dispatch import courseware.content_parser as content_parser +import courseware.modules.capa_module log = logging.getLogger("mitx.courseware") diff --git a/perfstats/middleware.py b/perfstats/middleware.py index ebb8e8142c..1308dd650a 100644 --- a/perfstats/middleware.py +++ b/perfstats/middleware.py @@ -1,7 +1,11 @@ -import views, json, tempfile, time +import json +import tempfile +import time + from django.conf import settings from django.db import connection +import views class ProfileMiddleware: def process_request (self, request): diff --git a/perfstats/views.py b/perfstats/views.py index fef5100a4b..7d0695b9fe 100644 --- a/perfstats/views.py +++ b/perfstats/views.py @@ -1,5 +1,6 @@ # Create your views here. import middleware + from django.http import HttpResponse def end_profile(request): diff --git a/settings_new_askbot.py b/settings_new_askbot.py index 14ede01c85..aa79e08ea8 100644 --- a/settings_new_askbot.py +++ b/settings_new_askbot.py @@ -34,7 +34,7 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( - ('Piotr Mitros', 'pmitros@csail.mit.edu'), + ('Piotr Mitros', 'staff@csail.mit.edu'), ) MANAGERS = ADMINS diff --git a/settings_old_askbot.py b/settings_old_askbot.py index 8ab2a98df8..d7783c05db 100644 --- a/settings_old_askbot.py +++ b/settings_old_askbot.py @@ -26,7 +26,7 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( - ('Piotr Mitros', 'pmitros@csail.mit.edu'), + ('Piotr Mitros', 'staff@csail.mit.edu'), ) MANAGERS = ADMINS diff --git a/simplewiki/__init__.py b/simplewiki/__init__.py index 071ec2c38f..8c4ebf2d51 100644 --- a/simplewiki/__init__.py +++ b/simplewiki/__init__.py @@ -1,6 +1,7 @@ # Source: django-simplewiki. GPL license. -import sys, os +import os +import sys # allow mdx_* parsers to be just dropped in the simplewiki folder module_path = os.path.abspath(os.path.dirname(__file__)) diff --git a/simplewiki/admin.py b/simplewiki/admin.py index 31e0856b75..b53ace1a7a 100644 --- a/simplewiki/admin.py +++ b/simplewiki/admin.py @@ -1,8 +1,9 @@ # Source: django-simplewiki. GPL license. -from django.contrib import admin from django import forms +from django.contrib import admin from django.utils.translation import ugettext as _ + from models import Article, Revision, Permission, ArticleAttachment class RevisionInline(admin.TabularInline): diff --git a/simplewiki/models.py b/simplewiki/models.py index 71add3c0fc..ed6366e801 100644 --- a/simplewiki/models.py +++ b/simplewiki/models.py @@ -1,12 +1,14 @@ -from django.utils.translation import ugettext_lazy as _ -from django.db import models -from django.db.models import signals -from django.contrib.auth.models import User -from markdown import markdown -from django import forms -from django.core.urlresolvers import reverse import difflib import os + +from django import forms +from django.contrib.auth.models import User +from django.core.urlresolvers import reverse +from django.db import models +from django.db.models import signals +from django.utils.translation import ugettext_lazy as _ +from markdown import markdown + from settings import * class ShouldHaveExactlyOneRootSlug(Exception): diff --git a/simplewiki/templatetags/simplewiki_utils.py b/simplewiki/templatetags/simplewiki_utils.py index 5b8eccf910..1534a7b401 100644 --- a/simplewiki/templatetags/simplewiki_utils.py +++ b/simplewiki/templatetags/simplewiki_utils.py @@ -1,9 +1,10 @@ from django import template -from django.template.defaultfilters import stringfilter -from simplewiki.settings import * from django.conf import settings +from django.template.defaultfilters import stringfilter from django.utils.http import urlquote as django_urlquote +from simplewiki.settings import * + register = template.Library() @register.filter() @@ -14,4 +15,4 @@ def prepend_media_url(value): @register.filter() def urlquote(value): """Prepend user defined media root to url""" - return django_urlquote(value) \ No newline at end of file + return django_urlquote(value) diff --git a/simplewiki/views.py b/simplewiki/views.py index ea7e04e419..16bfc11c44 100644 --- a/simplewiki/views.py +++ b/simplewiki/views.py @@ -1,27 +1,26 @@ # -*- coding: utf-8 -*- import types -from django.core.urlresolvers import get_callable -from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseServerError, HttpResponseForbidden, HttpResponseNotAllowed -from django.utils import simplejson -from djangomako.shortcuts import render_to_response, render_to_string -from django.shortcuts import get_object_or_404 -from django.template import RequestContext, Context, loader -from django.utils.translation import ugettext_lazy as _ -from django.core.urlresolvers import reverse -from django.contrib.auth.decorators import login_required -from django.db.models import Q + from django.conf import settings -from django.shortcuts import redirect +from django.contrib.auth.decorators import login_required from django.core.context_processors import csrf - -from django.template import Context +from django.core.urlresolvers import get_callable +from django.core.urlresolvers import reverse +from django.db.models import Q +from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseServerError, HttpResponseForbidden, HttpResponseNotAllowed from django.http import HttpResponse - -import djangomako.middleware -from mako.template import Template +from django.shortcuts import get_object_or_404 +from django.shortcuts import redirect +from django.template import Context +from django.template import RequestContext, Context, loader +from django.utils import simplejson +from django.utils.translation import ugettext_lazy as _ +from djangomako.shortcuts import render_to_response, render_to_string from mako.lookup import TemplateLookup +from mako.template import Template +import djangomako.middleware -from models import * +from models import * # TODO: Clean up from settings import * def view(request, wiki_url): diff --git a/simplewiki/views_attachments.py b/simplewiki/views_attachments.py index 47eb09a0b2..205f836ab9 100644 --- a/simplewiki/views_attachments.py +++ b/simplewiki/views_attachments.py @@ -1,14 +1,15 @@ +import os + +from django.contrib.auth.decorators import login_required +from django.core.servers.basehttp import FileWrapper +from django.db.models.fields.files import FieldFile from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404 from django.template import loader, Context -from django.db.models.fields.files import FieldFile -from django.core.servers.basehttp import FileWrapper -from django.contrib.auth.decorators import login_required -from settings import * +from settings import * # TODO: Clean up from models import Article, ArticleAttachment, get_attachment_filepath from views import not_found, check_permissions, get_url_path, fetch_from_url -import os from simplewiki.settings import WIKI_ALLOW_ANON_ATTACHMENTS diff --git a/staticbook/views.py b/staticbook/views.py index ad1314a71c..bb6e2ada19 100644 --- a/staticbook/views.py +++ b/staticbook/views.py @@ -1,9 +1,10 @@ # Create your views here. -from djangomako.shortcuts import render_to_response, render_to_string -from django.shortcuts import redirect import os + from django.conf import settings from django.http import Http404 +from django.shortcuts import redirect +from djangomako.shortcuts import render_to_response, render_to_string def index(request, page=0): if not request.user.is_authenticated(): diff --git a/urls.py b/urls.py index f24b2088f2..54c910dccf 100644 --- a/urls.py +++ b/urls.py @@ -1,8 +1,7 @@ -from django.conf.urls.defaults import patterns, include, url -import django.contrib.auth.views from django.conf import settings +from django.conf.urls.defaults import patterns, include, url from django.contrib import admin -import perfstats +import django.contrib.auth.views # Uncomment the next two lines to enable the admin: # from django.contrib import admin diff --git a/util/views.py b/util/views.py index 738bd93de7..139906e24a 100644 --- a/util/views.py +++ b/util/views.py @@ -1,21 +1,22 @@ -from djangomako.shortcuts import render_to_response, render_to_string -from django.shortcuts import redirect -from django.contrib.auth.models import User -from django.http import HttpResponse -import json -from django.conf import settings -from django.core.context_processors import csrf -from django.http import Http404 -import courseware.capa.calc -from django.core.mail import send_mail -from django.conf import settings import datetime +import json import sys + +from django.conf import settings +from django.conf import settings +from django.contrib.auth.models import User +from django.core.context_processors import csrf +from django.core.mail import send_mail +from django.http import Http404 +from django.http import HttpResponse +from django.shortcuts import redirect +from djangomako.shortcuts import render_to_response, render_to_string + +import courseware.capa.calc import track.views def calculate(request): -# if not request.user.is_authenticated(): -# raise Http404 + ''' Calculator in footer of every page. ''' equation = request.GET['equation'] try: result = courseware.capa.calc.evaluator({}, {}, equation) @@ -27,8 +28,7 @@ def calculate(request): return HttpResponse(json.dumps({'result':result})) def send_feedback(request): -# if not request.user.is_authenticated(): -# raise Http404 + ''' Feeback mechanism in footer of every page. ''' try: username = request.user.username except: @@ -50,4 +50,5 @@ def send_feedback(request): return HttpResponse(json.dumps({'success':True})) def info(request): + ''' Info page (link from main header) ''' return render_to_response("info.html", {})