diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/layout.html | 9 | ||||
-rw-r--r-- | templates/module_show.html | 44 | ||||
-rw-r--r-- | templates/upload.html | 125 |
3 files changed, 107 insertions, 71 deletions
diff --git a/templates/layout.html b/templates/layout.html index 85107b8..bad67a2 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" media="all" href="{{url_for('static', - filename='style_v1.css')}}" /> + filename='style_v2.css')}}" /> <script type="text/javascript" src="{{url_for('static',filename='jquery-1.8.0.min.js')}}"></script> <title>Fit</title> </head> @@ -26,12 +26,13 @@ <div id="sub-header"> {% if study %} <p> - {% if not request.base_url.endswith(url_for('upload', study=study)) %} + {% if not request.base_url.endswith(url_for('upload', study=study + , module = module))%} {% if not request.base_url.endswith(url_for('forbidden')) %} - <a href="{{url_for('upload', study=study)}}">neue Klausur hochladen</a> + <a href="{{url_for('upload', study=study, module=module)}}">neue Klausur hochladen</a> {% endif %} {% else %} - <a href="{{url_for('index')}}">zurück</a> + <a href="{{url_for('study_index', study=study, module=module)}}">zurück</a> {% endif %} </p> <h2>{{study.capitalize()}}</h2> diff --git a/templates/module_show.html b/templates/module_show.html index 8b2dda1..9e7e336 100644 --- a/templates/module_show.html +++ b/templates/module_show.html @@ -1,24 +1,32 @@ +{% macro render_module_list(module) %} +<ul id="module-list"> +{% for year,files in module %} + <li> + {{year}} + <ul> + {% for name,oid in files %} + <li> + <a href="{{url_for('study_show', study = study, oid=oid)}}">{{name}}</a> + </li> + {% endfor %} + </ul> + </li> +{% else %} + <li>Keine Einträge bisher</li> +{% endfor %} +</ul> +{% endmacro %} + {% extends "layout.html" %} {% block body %} - <h3>{{module}}</h3> + <p class="right"> + <a href="{{url_for('study_index', study=study)}}">zurück zur Übersicht</a> + </p> - <p> - <a href="{{url_for('study_index', study=study)}}">zurück zur Übersicht</a> - </p> + <div id="module-index"> + <h3>{{module}}</h3> - <ul> - {% for year,files in entries %} - <li> - {{year}} - <ul> - {% for name,oid in files %} - <li> - <a href="{{url_for('study_show', study = study, oid=oid)}}">{{name}}</a> - </li> - {% endfor %} - </ul> - </li> - {% endfor %} - </ul> + {{ render_module_list(entries)}} + </div> {% endblock %} diff --git a/templates/upload.html b/templates/upload.html index dec17c8..a248040 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -1,55 +1,82 @@ +{% macro render_fields(field, extra_field) %} + <p> + <label>{{ field.label }}</label> + {{ field|safe }} + + {% if extra_field %} + {{extra_field(**kwargs)|safe}} + {% endif %} + + {% if field.errors or extra_field.errors %} + <span class="error"> + {% for error in field.errors %}{{ error }}{% endfor %} + {% for error in extra_field.errors %}{{ error }}{% endfor %} + </span> + {% endif %} + </p> +{% endmacro %} + +{% macro render_field(field) %} + {{ render_fields(field, None) }} +{% endmacro %} + {% extends "layout.html" %} {% block body %} <h3>neue Klausur hochladen</h3> - {% macro render_fields(field, extra_field) %} - <p> - <label>{{ field.label }}</label> - {{ field|safe }} - - {% if extra_field %} - {{extra_field(**kwargs)|safe}} - {% endif %} - - {% if field.errors or extra_field.errors %} - <span class="error"> - {% for error in field.errors %}{{ error }}{% endfor %} - {% for error in extra_field.errors %}{{ error }}{% endfor %} - </span> - {% endif %} - </p> - {% endmacro %} - - {% macro render_field(field) %} - {{ render_fields(field, None) }} - {% endmacro %} - - <script type="text/javascript"> - $(document).ready(function() { - var elem = $('#module_new'); - var module = $('#module'); - if(module.val() != 'new') - elem.hide(); - - module.change(function(){ - var value = $(this).val(); - if(value == 'new') + <div id="upload"> + <form method="POST" enctype="multipart/form-data" + action="{{url_for('upload', study=study, module=module)}}"> + {{ form.csrf_token }} + + {{ render_field(form.exam) }} + {{ render_fields(form.module, form.module_new, placeholder='Modulname') }} + {{ render_field(form.year) }} + + <p> + <input type="submit" value="Hochladen" /> + </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> + + <script type="text/javascript"> + $(document).ready(function() { + var elem = $('#module_new'); + var module = $('#module'); + + if(module.val() != 'new') + elem.hide(); + + module.change(function(){ + var current = $(this); + var value = current.val(); + var text = current.find("option:selected").text(); + + if(value == 'new') { + $('#module-index').fadeOut('fast', function() { elem.fadeIn(); - else - elem.fadeOut(); - }); - }); - </script> - <form method="POST" enctype="multipart/form-data" - action="{{url_for('upload', study=study)}}"> - {{ form.csrf_token }} - - {{ render_field(form.exam) }} - {{ render_fields(form.module, form.module_new, placeholder='Modulname') }} - {{ render_field(form.year) }} - - <p> - <input type="submit" value="Hochladen" /> - </p> - </form> + }); + } 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'); + } + }); + + } + }); + }); + </script> {% endblock %} |