From d77f31dd382eb5c8ee38439b9fd92fad0d15e2cd Mon Sep 17 00:00:00 2001 From: stv Date: Sat, 28 Feb 2015 21:07:23 -0800 Subject: [PATCH] Remove circuit djangoapp from LMS These endpoints (`edit_circuit` and `save_circuit`) had already been commented out of `urls.py`, so these views were disabled. --- lms/djangoapps/circuit/__init__.py | 0 lms/djangoapps/circuit/models.py | 10 ----- lms/djangoapps/circuit/views.py | 65 ------------------------------ lms/envs/common.py | 1 - lms/static/coffee/src/main.coffee | 9 ----- lms/templates/edit_circuit.html | 8 ---- lms/urls.py | 4 -- 7 files changed, 97 deletions(-) delete mode 100644 lms/djangoapps/circuit/__init__.py delete mode 100644 lms/djangoapps/circuit/models.py delete mode 100644 lms/djangoapps/circuit/views.py delete mode 100644 lms/templates/edit_circuit.html diff --git a/lms/djangoapps/circuit/__init__.py b/lms/djangoapps/circuit/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lms/djangoapps/circuit/models.py b/lms/djangoapps/circuit/models.py deleted file mode 100644 index 8da678f08a..0000000000 --- a/lms/djangoapps/circuit/models.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.db import models - - -class ServerCircuit(models.Model): - # Later, add owner, who can edit, part of what app, etc. - name = models.CharField(max_length=32, unique=True, db_index=True) - schematic = models.TextField(blank=True) - - def __unicode__(self): - return self.name + ":" + self.schematic[:8] diff --git a/lms/djangoapps/circuit/views.py b/lms/djangoapps/circuit/views.py deleted file mode 100644 index 3e8a39cb43..0000000000 --- a/lms/djangoapps/circuit/views.py +++ /dev/null @@ -1,65 +0,0 @@ -import json - -import xml.etree.ElementTree - -from django.http import Http404 -from django.http import HttpResponse -from edxmako.shortcuts import render_to_response - -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 - except: - schematic = '' - - circuit_line = xml.etree.ElementTree.Element('input') - circuit_line.set('type', 'hidden') - circuit_line.set('class', 'schematic') - circuit_line.set('width', '640') - circuit_line.set('height', '480') - circuit_line.set('name', 'schematic') - circuit_line.set('id', 'schematic_' + circuit) - circuit_line.set('value', schematic) # We do it this way for security -- guarantees users cannot put funny stuff in schematic. - return xml.etree.ElementTree.tostring(circuit_line) - - -def edit_circuit(_request, circuit): - try: - sc = ServerCircuit.objects.get(name=circuit) - except: - sc = None - - if not circuit.isalnum(): - raise Http404() - response = render_to_response('edit_circuit.html', {'name': circuit, - 'circuit_line': circuit_line(circuit)}) - response['Cache-Control'] = 'no-cache' - return response - - -def save_circuit(request, circuit): - if not circuit.isalnum(): - raise Http404() - print dict(request.POST) - schematic = request.POST['schematic'] - print schematic - try: - sc = ServerCircuit.objects.get(name=circuit) - except: - sc = ServerCircuit() - sc.name = circuit - sc.schematic = schematic - print ":", sc.schematic - sc.save() - json_str = json.dumps({'results': 'success'}) - response = HttpResponse(json_str, mimetype='application/json') - response['Cache-Control'] = 'no-cache' - return response diff --git a/lms/envs/common.py b/lms/envs/common.py index 9b761399ac..90a29ee83c 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1819,7 +1819,6 @@ INSTALLED_APPS = ( 'openedx.core.djangoapps.theming', # Our courseware - 'circuit', 'courseware', 'student', diff --git a/lms/static/coffee/src/main.coffee b/lms/static/coffee/src/main.coffee index 561225761d..6db41318e5 100644 --- a/lms/static/coffee/src/main.coffee +++ b/lms/static/coffee/src/main.coffee @@ -18,15 +18,6 @@ $ -> if $('body').hasClass('courseware') Courseware.start() - # Preserved for backward compatibility - window.submit_circuit = (circuit_id) -> - $("input.schematic").each (index, el) -> - el.schematic.update_value() - - schematic_value $("#schematic_#{circuit_id}").attr("value") - $.postWithPrefix "/save_circuit/#{circuit_id}", schematic: schematic_value, (data) -> - alert('Saved') if data.results == 'success' - window.postJSON = (url, data, callback) -> $.postWithPrefix url, data, callback diff --git a/lms/templates/edit_circuit.html b/lms/templates/edit_circuit.html deleted file mode 100644 index ca72cf040d..0000000000 --- a/lms/templates/edit_circuit.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- -${ circuit_line } - - -
-
diff --git a/lms/urls.py b/lms/urls.py index 6ef2f67cdb..20fbe25763 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -331,10 +331,6 @@ if settings.COURSEWARE_ENABLED: # TODO: These views need to be updated before they work url(r'^calculate$', 'util.views.calculate'), - # TODO: We should probably remove the circuit package. I believe it was only used in the old way of saving wiki - # circuits for the wiki - # url(r'^edit_circuit/(?P[^/]*)$', 'circuit.views.edit_circuit'), - # url(r'^save_circuit/(?P[^/]*)$', 'circuit.views.save_circuit'), url(r'^courses/?$', 'branding.views.courses', name="courses"), url(r'^change_enrollment$',