summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-08-15 16:16:43 +0200
committerNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-08-15 16:16:43 +0200
commit11ffb78a95d27ebf8ed0b238cde640028eff8e25 (patch)
tree5c9a0d4d102592db4cc0bb51352927d45c65f838
parented5e89436e219f0cf0f699c322f23b762d18f385 (diff)
downloadklausuren-11ffb78a95d27ebf8ed0b238cde640028eff8e25.tar.gz
klausuren-11ffb78a95d27ebf8ed0b238cde640028eff8e25.tar.bz2
klausuren-11ffb78a95d27ebf8ed0b238cde640028eff8e25.zip
refactoring
-rw-r--r--app.py13
-rw-r--r--templates/module_show.html3
-rw-r--r--templates/upload.html32
3 files changed, 20 insertions, 28 deletions
diff --git a/app.py b/app.py
index 51249de..baaf3d2 100644
--- a/app.py
+++ b/app.py
@@ -96,17 +96,10 @@ def upload(study, module = None):
return redirect(url_for('study_index', study = study, module = module))
- module_list = None
- if module:
- try: form.module.data = [k for (k,v) in form.module.choices if v == module][0]
- except: pass
-
- print(form.module.data)
- module_list = fit[study].get_module(module)
+ try: form.module.data = [k for (k,v) in form.module.choices if v == module][0]
+ except: pass
- return render_template('upload.html',
- study = study, form = form, module_list = module_list, module=module
- )
+ return render_template('upload.html', study = study, form = form)
diff --git a/templates/module_show.html b/templates/module_show.html
index 9e7e336..ea27e05 100644
--- a/templates/module_show.html
+++ b/templates/module_show.html
@@ -6,7 +6,8 @@
<ul>
{% for name,oid in files %}
<li>
- <a href="{{url_for('study_show', study = study, oid=oid)}}">{{name}}</a>
+ <a href="{{url_for('study_show', study = study,
+ oid=oid)}}">{{name|truncate(50,True)}}</a>
</li>
{% endfor %}
</ul>
diff --git a/templates/upload.html b/templates/upload.html
index a248040..8683be0 100644
--- a/templates/upload.html
+++ b/templates/upload.html
@@ -38,13 +38,7 @@
</p>
</form>
- <div id="module-index">
- {% if module and module_list %}
- <h4>{{module}}</h4>
- {% from 'module_show.html' import render_module_list %}
- {{ render_module_list(module_list)}}
- {% endif %}
- </div>
+ <div id="module-index"></div>
</div>
<script type="text/javascript">
@@ -52,6 +46,15 @@
var elem = $('#module_new');
var module = $('#module');
+ var update_modules = function() {
+ var text = module.find("option:selected").text();
+ $.get('/{{study}}/modules/' + text, function(data) {
+ $('#module-index').replaceWith($(data).find('#module-index'));
+ });
+ };
+
+ update_modules();
+
if(module.val() != 'new')
elem.hide();
@@ -61,18 +64,13 @@
var text = current.find("option:selected").text();
if(value == 'new') {
- $('#module-index').fadeOut('fast', function() {
- elem.fadeIn();
- });
+ $('#module-index').fadeOut('fast', function() { elem.fadeIn(); });
} else {
elem.fadeOut('fast', function() {
- if(value != '') {
- $.get('/{{study}}/modules/' + text, function(data) {
- $('#upload div').replaceWith($(data).find('#module-index'));
- });
- } else {
- $('#module-index').fadeOut('fast');
- }
+ if(value != '')
+ update_modules();
+ else
+ $('#module-index').fadeOut('fast');
});
}