diff options
Diffstat (limited to 'website')
-rw-r--r-- | website/ajax.py | 15 | ||||
-rw-r--r-- | website/helpers.py | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/website/ajax.py b/website/ajax.py index a7a1c3c..6b6f998 100644 --- a/website/ajax.py +++ b/website/ajax.py @@ -80,3 +80,18 @@ def execute(request, token, code, book_id, chapter_id, example_id): .filter(example_id=example_id).exists() data = scilab_run(code, token, book_id, dependency_exists) return simplejson.dumps(data) + +@dajaxice_register +def contributor(request, book_id): + dajax = Dajax() + preference = TextbookCompanionPreference.objects.using('scilab')\ + .get(id=book_id) + proposal = TextbookCompanionProposal.objects.using('scilab')\ + .get(id=preference.proposal_id) + context = { + "preference": preference, + "proposal": proposal, + } + contributor = render_to_string('website/templates/ajax-contributor.html', context) + dajax.assign('#databox', 'innerHTML', contributor) + return dajax.json() diff --git a/website/helpers.py b/website/helpers.py index 20ef288..e11cfb3 100644 --- a/website/helpers.py +++ b/website/helpers.py @@ -17,7 +17,7 @@ def scilab_run(code, token, book_id, dependency_exists): plot_exists = False #Finding the plot and appending xs2jpg function - p = re.compile(r'.*plot.*\(.*,.*,*\).*\n|bode\(.*,.*\)') + p = re.compile(r'.*plot.*\(.*\).*\n|bode\(.*\)') plot_path = '' if p.search(code): @@ -49,7 +49,7 @@ def scilab_run(code, token, book_id, dependency_exists): cmd = 'printf "exec(\'{0}\',2);\nquit();"'.format(file_path) cmd += ' | /home/cheese/scilab-5.4.1/bin/scilab-adv-cli -nw' - task = TimerTask(cmd, timeout=10) + task = TimerTask(cmd, timeout=15) output = task.run().communicate()[0] e = task.wait() |