Commit 8125180e by Piotr Mitros

Major number of minor cleanups. Fixed from e-mail, import order, ==None, etc.

parent 1abeec78
import uuid
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
import uuid
class UserProfile(models.Model): class UserProfile(models.Model):
## CRITICAL TODO/SECURITY ## CRITICAL TODO/SECURITY
......
import json
import logging import logging
import random
import string
from djangomako.shortcuts import render_to_response, render_to_string from django.conf import settings
from django.contrib.auth.models import User
from django.shortcuts import redirect
from django.contrib.auth import logout, authenticate, login from django.contrib.auth import logout, authenticate, login
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.http import HttpResponse from django.contrib.auth.models import User
import json
from models import Registration, UserProfile
from django.conf import settings
from django.core.context_processors import csrf from django.core.context_processors import csrf
from django.core.validators import validate_email, validate_slug from django.core.validators import validate_email, validate_slug
import random, string
from django.db import connection 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") log = logging.getLogger("mitx.auth")
......
import uuid
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
import uuid
class ServerCircuit(models.Model): class ServerCircuit(models.Model):
# Later, add owner, who can edit, part of what app, etc. # Later, add owner, who can edit, part of what app, etc.
......
from djangomako.shortcuts import render_to_response, render_to_string import json
from django.shortcuts import redirect
import os import os
import xml.etree.ElementTree
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
from models import ServerCircuit
import json
import xml.etree.ElementTree
from django.http import HttpResponse 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): def circuit_line(circuit):
''' Returns string for an appropriate input element for a circuit.
TODO: Rename. '''
if not circuit.isalnum(): if not circuit.isalnum():
raise Http404() raise Http404()
try: try:
sc = ServerCircuit.objects.get(name=circuit) sc = ServerCircuit.objects.get(name=circuit)
schematic = sc.schematic schematic = sc.schematic
print "Got"
except: except:
schematic = '' schematic = ''
print "not got"
print "X", schematic
circuit_line = xml.etree.ElementTree.Element('input') circuit_line = xml.etree.ElementTree.Element('input')
circuit_line.set('type', 'hidden') circuit_line.set('type', 'hidden')
......
import math import math
import operator import operator
from pyparsing import Word, alphas, nums, oneOf, Literal from pyparsing import Word, alphas, nums, oneOf, Literal
from pyparsing import ZeroOrMore, OneOrMore, StringStart from pyparsing import ZeroOrMore, OneOrMore, StringStart
from pyparsing import StringEnd, Optional, Forward from pyparsing import StringEnd, Optional, Forward
......
import random, numpy, math, scipy import copy
import struct, os import math
import numpy
import os
import random
import re import re
import scipy
import struct
from lxml import etree from lxml import etree
from lxml.etree import Element from lxml.etree import Element
import copy
from mako.template import Template from mako.template import Template
from courseware.content_parser import xpath_remove
import calc, eia
from util import contextualize_text from util import contextualize_text
from inputtypes import textline, schematic from inputtypes import textline, schematic
from responsetypes import numericalresponse, formularesponse, customresponse, schematicresponse from responsetypes import numericalresponse, formularesponse, customresponse, schematicresponse
import calc
import eia
response_types = {'numericalresponse':numericalresponse, response_types = {'numericalresponse':numericalresponse,
'formularesponse':formularesponse, 'formularesponse':formularesponse,
'customresponse':customresponse, 'customresponse':customresponse,
...@@ -52,12 +58,14 @@ class LoncapaProblem(object): ...@@ -52,12 +58,14 @@ class LoncapaProblem(object):
self.done = False self.done = False
self.filename = filename self.filename = filename
if id!=None: if id:
self.problem_id = id self.problem_id = id
else: 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: if 'seed' in state:
self.seed = state['seed'] self.seed = state['seed']
if 'student_answers' in state: if 'student_answers' in state:
...@@ -68,7 +76,7 @@ class LoncapaProblem(object): ...@@ -68,7 +76,7 @@ class LoncapaProblem(object):
self.done = state['done'] self.done = state['done']
# TODO: Does this deplete the Linux entropy pool? Is this fast enough? # 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] self.seed=struct.unpack('i', os.urandom(4))[0]
## Parse XML file ## Parse XML file
...@@ -102,7 +110,7 @@ class LoncapaProblem(object): ...@@ -102,7 +110,7 @@ class LoncapaProblem(object):
for key in self.correct_map: for key in self.correct_map:
if self.correct_map[key] == u'correct': if self.correct_map[key] == u'correct':
correct += 1 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, return {'score':0,
'total':self.get_max_score()} 'total':self.get_max_score()}
else: else:
...@@ -132,7 +140,7 @@ class LoncapaProblem(object): ...@@ -132,7 +140,7 @@ class LoncapaProblem(object):
for entry in problems_simple.xpath("//"+"|//".join(response_properties+entry_types)): for entry in problems_simple.xpath("//"+"|//".join(response_properties+entry_types)):
answer = entry.get('correct_answer') answer = entry.get('correct_answer')
if answer != None: if answer:
answer_map[entry.get('id')] = contextualize_text(answer, self.context) answer_map[entry.get('id')] = contextualize_text(answer, self.context)
return answer_map return answer_map
...@@ -162,7 +170,7 @@ class LoncapaProblem(object): ...@@ -162,7 +170,7 @@ class LoncapaProblem(object):
status = self.correct_map[problemtree.get('id')] status = self.correct_map[problemtree.get('id')]
value = "" 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')] value = self.student_answers[problemtree.get('id')]
return html_special_response[problemtree.tag](problemtree, value, status) #TODO return html_special_response[problemtree.tag](problemtree, value, status) #TODO
...@@ -170,7 +178,7 @@ class LoncapaProblem(object): ...@@ -170,7 +178,7 @@ class LoncapaProblem(object):
tree=Element(problemtree.tag) tree=Element(problemtree.tag)
for item in problemtree: for item in problemtree:
subitems = self.extract_html(item) subitems = self.extract_html(item)
if subitems != None: if subitems:
for subitem in subitems: for subitem in subitems:
tree.append(subitem) tree.append(subitem)
for (key,value) in problemtree.items(): for (key,value) in problemtree.items():
......
from djangomako.shortcuts import render_to_response, render_to_string
from lxml.etree import Element from lxml.etree import Element
from lxml import etree from lxml import etree
from djangomako.shortcuts import render_to_response, render_to_string
class textline(object): class textline(object):
@staticmethod @staticmethod
def render(element, value, state): def render(element, value, state):
......
import random, numpy, math, scipy, json import json
from util import contextualize_text import math
import numpy
import random
import scipy
from calc import evaluator from calc import evaluator
import random, math
from django.conf import settings from django.conf import settings
import eia from util import contextualize_text
import calc import calc
import eia
# TODO: Should be the same object as in capa_problem # TODO: Should be the same object as in capa_problem
global_context={'random':random, global_context={'random':random,
......
import math import math
from numpy import eye, array
import operator import operator
from numpy import eye, array
from pyparsing import Word, alphas, nums, oneOf, Literal from pyparsing import Word, alphas, nums, oneOf, Literal
from pyparsing import ZeroOrMore, OneOrMore, StringStart from pyparsing import ZeroOrMore, OneOrMore, StringStart
from pyparsing import StringEnd, Optional, Forward from pyparsing import StringEnd, Optional, Forward
......
try: import json
import hashlib
from lxml import etree
try: # This lets us do __name__ == ='__main__'
from django.conf import settings from django.conf import settings
from auth.models import UserProfile from auth.models import UserProfile
except: except:
settings = None settings = None
from lxml import etree
import json
import hashlib
''' This file will eventually form an abstraction layer between the ''' This file will eventually form an abstraction layer between the
course XML file and the rest of the system. course XML file and the rest of the system.
......
from django.db import models from django.db import models
from django.contrib.auth.models import User 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): class StudentModule(models.Model):
# For a homework problem, contains a JSON # For a homework problem, contains a JSON
# object consisting of state # object consisting of state
......
import StringIO
import json
import os
import sys
import sys
import urllib
import uuid
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.http import HttpResponse
from django.shortcuts import redirect
from django.template import Context
from django.template import Context, loader from django.template import Context, loader
from djangomako.shortcuts import render_to_response, render_to_string 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 auth.models import UserProfile
from django.shortcuts import redirect from models import StudentModule
import StringIO
import track.views import track.views
from django.http import Http404 import courseware.content_parser as content_parser
import urllib
import courseware.modules.capa_module import courseware.modules.capa_module
import courseware.modules.video_module
import courseware.modules.vertical_module
import courseware.modules.html_module import courseware.modules.html_module
import courseware.modules.schematic_module import courseware.modules.schematic_module
import courseware.modules.seq_module import courseware.modules.seq_module
import courseware.modules.vertical_module
from models import StudentModule import courseware.modules.video_module
import urllib
from django.conf import settings
import courseware.content_parser as content_parser
import sys
from lxml import etree
import uuid
## TODO: Add registration mechanism ## TODO: Add registration mechanism
modx_modules={'problem':courseware.modules.capa_module.LoncapaModule, modx_modules={'problem':courseware.modules.capa_module.LoncapaModule,
...@@ -93,7 +88,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): ...@@ -93,7 +88,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
ajax_return=instance.handle_ajax(dispatch, request.POST) ajax_return=instance.handle_ajax(dispatch, request.POST)
# Save the state back to the database # Save the state back to the database
s.state=instance.get_state() s.state=instance.get_state()
if instance.get_score() != None: if not instance.get_score():
s.grade=instance.get_score()['score'] s.grade=instance.get_score()['score']
s.save() s.save()
# Return whatever the module wanted to return to the client/caller # 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): ...@@ -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 "" module_id=xml_module.get('id') #module_class.id_attribute) or ""
# Grab state from database # Grab state from database
s = object_cache(module_object_preload, smod = object_cache(module_object_preload,
user, user,
module_type, module_type,
module_id) module_id)
if s == None: # If nothing in the database... if not smod: # If nothing in the database...
state=None state=None
else: else:
smod = s
state = smod.state state = smod.state
# Create a new instance # Create a new instance
...@@ -128,7 +122,7 @@ def render_x_module(user, request, xml_module, module_object_preload): ...@@ -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)) render_function = lambda x: render_module(user, request, x, module_object_preload))
# If instance wasn't already in the database, create it # If instance wasn't already in the database, create it
if s == None: if not smod:
smod=StudentModule(student=user, smod=StudentModule(student=user,
module_type = module_type, module_type = module_type,
module_id=module_id, module_id=module_id,
......
import random, numpy, math, scipy, sys, StringIO, os, struct, json import StringIO
from x_module import XModule import datetime
import sys
from courseware.capa.capa_problem import LoncapaProblem
from django.http import Http404
import dateutil import dateutil
import dateutil.parser import dateutil.parser
import datetime import json
import math
import courseware.content_parser as content_parser import numpy
import os
import random
import scipy
import struct
import sys
import traceback
from lxml import etree from lxml import etree
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string 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): class LoncapaModule(XModule):
''' Interface between capa_problem and x_module. Originally a hack ''' Interface between capa_problem and x_module. Originally a hack
...@@ -231,6 +237,8 @@ class LoncapaModule(XModule): ...@@ -231,6 +237,8 @@ class LoncapaModule(XModule):
for key in get: for key in get:
answers['_'.join(key.split('_')[1:])]=get[key] answers['_'.join(key.split('_')[1:])]=get[key]
print "XXX", answers, get
event_info['answers']=answers event_info['answers']=answers
# Too late. Cannot submit # Too late. Cannot submit
...@@ -255,6 +263,7 @@ class LoncapaModule(XModule): ...@@ -255,6 +263,7 @@ class LoncapaModule(XModule):
correct_map = self.lcp.grade_answers(answers) correct_map = self.lcp.grade_answers(answers)
except: except:
self.lcp = LoncapaProblem(filename, id=lcp_id, state=old_state) self.lcp = LoncapaProblem(filename, id=lcp_id, state=old_state)
traceback.print_exc()
print {'error':sys.exc_info(), print {'error':sys.exc_info(),
'answers':answers, 'answers':answers,
'seed':self.lcp.seed, 'seed':self.lcp.seed,
......
from x_module import XModule
from lxml import etree
import json import json
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string from djangomako.shortcuts import render_to_response, render_to_string
from x_module import XModule
from lxml import etree
class HtmlModule(XModule): class HtmlModule(XModule):
id_attribute = 'filename' id_attribute = 'filename'
......
from x_module import XModule
import json import json
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string from djangomako.shortcuts import render_to_response, render_to_string
from x_module import XModule
class SchematicModule(XModule): class SchematicModule(XModule):
id_attribute = 'id' id_attribute = 'id'
......
from x_module import XModule
from lxml import etree
from django.http import Http404
import json import json
from lxml import etree
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.http import Http404
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string from djangomako.shortcuts import render_to_response, render_to_string
from x_module import XModule
class SequentialModule(XModule): class SequentialModule(XModule):
''' Layout module which lays out content in a temporal sequence ''' Layout module which lays out content in a temporal sequence
''' '''
......
from x_module import XModule
from lxml import etree
import json import json
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string from djangomako.shortcuts import render_to_response, render_to_string
from x_module import XModule
from lxml import etree
class VerticalModule(XModule): class VerticalModule(XModule):
id_attribute = 'id' id_attribute = 'id'
......
import logging
import json import json
import logging
from lxml import etree
## TODO: Abstract out from Django ## TODO: Abstract out from Django
from django.conf import settings from django.conf import settings
from djangomako.shortcuts import render_to_response, render_to_string from djangomako.shortcuts import render_to_response, render_to_string
from lxml import etree
from x_module import XModule from x_module import XModule
......
...@@ -19,8 +19,9 @@ from lxml import etree ...@@ -19,8 +19,9 @@ from lxml import etree
from auth.models import UserProfile from auth.models import UserProfile
from models import StudentModule 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.content_parser as content_parser
import courseware.modules.capa_module
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
......
import views, json, tempfile, time import json
import tempfile
import time
from django.conf import settings from django.conf import settings
from django.db import connection from django.db import connection
import views
class ProfileMiddleware: class ProfileMiddleware:
def process_request (self, request): def process_request (self, request):
......
# Create your views here. # Create your views here.
import middleware import middleware
from django.http import HttpResponse from django.http import HttpResponse
def end_profile(request): def end_profile(request):
......
...@@ -34,7 +34,7 @@ DEBUG = True ...@@ -34,7 +34,7 @@ DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
ADMINS = ( ADMINS = (
('Piotr Mitros', 'pmitros@csail.mit.edu'), ('Piotr Mitros', 'staff@csail.mit.edu'),
) )
MANAGERS = ADMINS MANAGERS = ADMINS
......
...@@ -26,7 +26,7 @@ DEBUG = True ...@@ -26,7 +26,7 @@ DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
ADMINS = ( ADMINS = (
('Piotr Mitros', 'pmitros@csail.mit.edu'), ('Piotr Mitros', 'staff@csail.mit.edu'),
) )
MANAGERS = ADMINS MANAGERS = ADMINS
......
# Source: django-simplewiki. GPL license. # Source: django-simplewiki. GPL license.
import sys, os import os
import sys
# allow mdx_* parsers to be just dropped in the simplewiki folder # allow mdx_* parsers to be just dropped in the simplewiki folder
module_path = os.path.abspath(os.path.dirname(__file__)) module_path = os.path.abspath(os.path.dirname(__file__))
......
# Source: django-simplewiki. GPL license. # Source: django-simplewiki. GPL license.
from django.contrib import admin
from django import forms from django import forms
from django.contrib import admin
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from models import Article, Revision, Permission, ArticleAttachment from models import Article, Revision, Permission, ArticleAttachment
class RevisionInline(admin.TabularInline): class RevisionInline(admin.TabularInline):
......
from django.utils.translation import ugettext_lazy as _ 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 import models
from django.db.models import signals from django.db.models import signals
from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _
from markdown import markdown from markdown import markdown
from django import forms
from django.core.urlresolvers import reverse
import difflib
import os
from settings import * from settings import *
class ShouldHaveExactlyOneRootSlug(Exception): class ShouldHaveExactlyOneRootSlug(Exception):
......
from django import template from django import template
from django.template.defaultfilters import stringfilter
from simplewiki.settings import *
from django.conf import settings from django.conf import settings
from django.template.defaultfilters import stringfilter
from django.utils.http import urlquote as django_urlquote from django.utils.http import urlquote as django_urlquote
from simplewiki.settings import *
register = template.Library() register = template.Library()
@register.filter() @register.filter()
...@@ -14,4 +15,4 @@ def prepend_media_url(value): ...@@ -14,4 +15,4 @@ def prepend_media_url(value):
@register.filter() @register.filter()
def urlquote(value): def urlquote(value):
"""Prepend user defined media root to url""" """Prepend user defined media root to url"""
return django_urlquote(value) return django_urlquote(value)
\ No newline at end of file
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import types import types
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.core.urlresolvers import get_callable 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.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.db.models import Q from django.db.models import Q
from django.conf import settings from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseServerError, HttpResponseForbidden, HttpResponseNotAllowed
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.shortcuts import redirect from django.shortcuts import redirect
from django.core.context_processors import csrf
from django.template import Context from django.template import Context
from django.http import HttpResponse from django.template import RequestContext, Context, loader
from django.utils import simplejson
import djangomako.middleware from django.utils.translation import ugettext_lazy as _
from mako.template import Template from djangomako.shortcuts import render_to_response, render_to_string
from mako.lookup import TemplateLookup 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 * from settings import *
def view(request, wiki_url): def view(request, wiki_url):
......
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.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404
from django.template import loader, Context 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 models import Article, ArticleAttachment, get_attachment_filepath
from views import not_found, check_permissions, get_url_path, fetch_from_url from views import not_found, check_permissions, get_url_path, fetch_from_url
import os
from simplewiki.settings import WIKI_ALLOW_ANON_ATTACHMENTS from simplewiki.settings import WIKI_ALLOW_ANON_ATTACHMENTS
......
# Create your views here. # Create your views here.
from djangomako.shortcuts import render_to_response, render_to_string
from django.shortcuts import redirect
import os import os
from django.conf import settings from django.conf import settings
from django.http import Http404 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): def index(request, page=0):
if not request.user.is_authenticated(): if not request.user.is_authenticated():
......
from django.conf.urls.defaults import patterns, include, url
import django.contrib.auth.views
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin from django.contrib import admin
import perfstats import django.contrib.auth.views
# Uncomment the next two lines to enable the admin: # Uncomment the next two lines to enable the admin:
# from django.contrib import admin # from django.contrib import admin
......
from djangomako.shortcuts import render_to_response, render_to_string import datetime
from django.shortcuts import redirect
from django.contrib.auth.models import User
from django.http import HttpResponse
import json import json
import sys
from django.conf import settings 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.context_processors import csrf
from django.core.mail import send_mail
from django.http import Http404 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 courseware.capa.calc
from django.core.mail import send_mail
from django.conf import settings
import datetime
import sys
import track.views import track.views
def calculate(request): def calculate(request):
# if not request.user.is_authenticated(): ''' Calculator in footer of every page. '''
# raise Http404
equation = request.GET['equation'] equation = request.GET['equation']
try: try:
result = courseware.capa.calc.evaluator({}, {}, equation) result = courseware.capa.calc.evaluator({}, {}, equation)
...@@ -27,8 +28,7 @@ def calculate(request): ...@@ -27,8 +28,7 @@ def calculate(request):
return HttpResponse(json.dumps({'result':result})) return HttpResponse(json.dumps({'result':result}))
def send_feedback(request): def send_feedback(request):
# if not request.user.is_authenticated(): ''' Feeback mechanism in footer of every page. '''
# raise Http404
try: try:
username = request.user.username username = request.user.username
except: except:
...@@ -50,4 +50,5 @@ def send_feedback(request): ...@@ -50,4 +50,5 @@ def send_feedback(request):
return HttpResponse(json.dumps({'success':True})) return HttpResponse(json.dumps({'success':True}))
def info(request): def info(request):
''' Info page (link from main header) '''
return render_to_response("info.html", {}) return render_to_response("info.html", {})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment