From ed5e89436e219f0cf0f699c322f23b762d18f385 Mon Sep 17 00:00:00 2001 From: Nico von Geyso Date: Wed, 15 Aug 2012 15:49:32 +0200 Subject: added module entries in form upload --- app.py | 17 ++++- static/style_v1.css | 178 ------------------------------------------- static/style_v2.css | 185 +++++++++++++++++++++++++++++++++++++++++++++ templates/layout.html | 9 ++- templates/module_show.html | 44 ++++++----- templates/upload.html | 125 ++++++++++++++++++------------ 6 files changed, 306 insertions(+), 252 deletions(-) delete mode 100644 static/style_v1.css create mode 100644 static/style_v2.css diff --git a/app.py b/app.py index 430942c..51249de 100644 --- a/app.py +++ b/app.py @@ -62,8 +62,9 @@ class UploadForm(Form): -@app.route('//upload', methods=['GET', 'POST']) -def upload(study): +@app.route('//upload/', methods=['GET', 'POST']) +@app.route('//upload/', methods=['GET', 'POST']) +def upload(study, module = None): form = UploadForm() form.study.data = study @@ -95,7 +96,17 @@ def upload(study): return redirect(url_for('study_index', study = study, module = module)) - return render_template('upload.html', study = study, form = form) + 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) + + return render_template('upload.html', + study = study, form = form, module_list = module_list, module=module + ) diff --git a/static/style_v1.css b/static/style_v1.css deleted file mode 100644 index 35063ad..0000000 --- a/static/style_v1.css +++ /dev/null @@ -1,178 +0,0 @@ -html, body { - padding: 0; - margin: 0; - height: 100%; - font: 13px/1.5 'Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif; -} - -body { - background-color: #333; -} - -#content { - background-color: #fff; - clear: both; - margin: 0px auto; - width: 920px; - padding: 20px; -} - - -#header { - background-color: #fff; - margin: 0px auto 10px auto; - float: left; - width: 100%; -} - -footer { - clear: both; - margin: 0px auto; - width: 920px; - padding: 20px; - text-align: center; - color: #fff; -} - -footer a, footer a:visited { - color: #fff; -} - -#sub-header { - width:100%; -} - -#container { - float: left; -} - -#header h1, #header p, #header form { - padding: 20px 0px 20px 20px; -} - -#header h1 { - display: inline-block; - float: left; - width: 50%; - margin: 0px; -} -#header p { - display: inline-block; - font-family: monospace; - text-align: right; - line-height: 180%; - padding: 5px; - margin: 0; - float: right; - width: 30%; -} - -#header h1 small { - color: #777; - font-size: 50%; -} - -#header form { - float: right; - padding-right: 20px; - text-align: right; -} - -#filelist { - list-style: none; -} - -#container p { - margin-bottom: 0px; -} - -label { - float: left; - width: 200px; -} - -ul.flashes { - margin: 0px auto; - width: 40%; -} - -ul.flashes li { - list-style-type: none; - border: 2px solid green; - background-color: #0D5; - padding: 5px; - padding: 0px; - text-align: center; -} - -a, a:visited { - font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; - color: #0069D6; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -#sub-header p { - float: right; - text-align: right; -} - -span.error { - font-weight: bold; - color: #F00; - display: block; - margin-left: 200px; -} - -select { - font-family: monospace; - width: 350px; - border: 1px solid #ccc; - padding: 5px 5px; - background-color: #fff; -} - -#module_new { - width: 200px; - margin-left: 10px; - padding: 5px 5px; - border: 1px solid #ccc; -} - -#studies { - margin: auto; - text-align: center; - padding: 40px 0px 60px 0px; -} - -#studies ul { - display: inline-block; -} - -#studies li { - float: left; - list-style-type: none; - text-align: center; - width: 200px; -} - -#studies li a { - margin: 0px 20px; - padding: 10px; - border: 1px solid #ccc; - display: block; -} - -#studies li a:hover { - background-color: #ccc; - border: 1px solid #000; -} - -#studies li img{ - display: block; - margin: 0px auto; -} - diff --git a/static/style_v2.css b/static/style_v2.css new file mode 100644 index 0000000..89fa08b --- /dev/null +++ b/static/style_v2.css @@ -0,0 +1,185 @@ +html, body { + padding: 0; + margin: 0; + height: 100%; + font: 13px/1.5 'Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif; +} + +body { + background-color: #333; +} + +#content { + background-color: #fff; + clear: both; + margin: 0px auto; + width: 1000px; + padding: 20px; +} + + +#header { + background-color: #fff; + margin: 0px auto 10px auto; + float: left; + width: 100%; +} + +footer { + clear: both; + margin: 0px auto; + width: 920px; + padding: 20px; + text-align: center; + color: #fff; +} + +footer a, footer a:visited { + color: #fff; +} + +#sub-header { + width:100%; +} + +#container { + float: left; +} + +#header h1, #header p, #header form { + padding: 20px 0px 20px 20px; +} + +#header h1 { + display: inline-block; + float: left; + width: 50%; + margin: 0px; +} +#header p { + display: inline-block; + font-family: monospace; + text-align: right; + line-height: 180%; + padding: 5px; + margin: 0; + float: right; + width: 30%; +} + +#header h1 small { + color: #777; + font-size: 50%; +} + + +#filelist { + list-style: none; +} + +#container p { + margin-bottom: 0px; +} + +label { + float: left; + width: 200px; +} + +ul.flashes { + margin: 0px auto; + width: 40%; +} + +ul.flashes li { + list-style-type: none; + border: 2px solid green; + background-color: #0D5; + padding: 5px; + padding: 0px; + text-align: center; +} + +a, a:visited { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + color: #0069D6; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +#sub-header p { + float: right; + text-align: right; +} + +span.error { + font-weight: bold; + color: #F00; + display: block; + margin-left: 200px; +} + +select { + font-family: monospace; + width: 350px; + border: 1px solid #ccc; + padding: 5px 5px; + background-color: #fff; +} + +#module_new { + width: 200px; + margin-left: 10px; + padding: 5px 5px; + border: 1px solid #ccc; +} + +#studies { + margin: auto; + text-align: center; + padding: 40px 0px 60px 0px; +} + +#studies ul { + display: inline-block; +} + +#studies li { + float: left; + list-style-type: none; + text-align: center; + width: 200px; +} + +#studies li a { + margin: 0px 20px; + padding: 10px; + border: 1px solid #ccc; + display: block; +} + +#studies li a:hover { + background-color: #ccc; + border: 1px solid #000; +} + +#studies li img{ + display: block; + margin: 0px auto; +} + +#upload form, #upload div { + display: inline-block; +} + +#upload div { + vertical-align: top; + padding-left: 30px; +} + +.right { + float: right; +} 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 @@ + filename='style_v2.css')}}" /> Fit @@ -26,12 +26,13 @@
{% if study %}

- {% 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')) %} - neue Klausur hochladen + neue Klausur hochladen {% endif %} {% else %} - zurück + zurück {% endif %}

{{study.capitalize()}}

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) %} +
    +{% for year,files in module %} +
  • + {{year}} +
      + {% for name,oid in files %} +
    • + {{name}} +
    • + {% endfor %} +
    +
  • +{% else %} +
  • Keine Einträge bisher
  • +{% endfor %} +
+{% endmacro %} + {% extends "layout.html" %} {% block body %} -

{{module}}

+

+ zurück zur Übersicht +

-

- zurück zur Übersicht -

+
+

{{module}}

-
    - {% for year,files in entries %} -
  • - {{year}} -
      - {% for name,oid in files %} -
    • - {{name}} -
    • - {% endfor %} -
    -
  • - {% endfor %} -
+ {{ render_module_list(entries)}} +
{% 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) %} +

+ + {{ field|safe }} + + {% if extra_field %} + {{extra_field(**kwargs)|safe}} + {% endif %} + + {% if field.errors or extra_field.errors %} + + {% for error in field.errors %}{{ error }}{% endfor %} + {% for error in extra_field.errors %}{{ error }}{% endfor %} + + {% endif %} +

+{% endmacro %} + +{% macro render_field(field) %} + {{ render_fields(field, None) }} +{% endmacro %} + {% extends "layout.html" %} {% block body %}

neue Klausur hochladen

- {% macro render_fields(field, extra_field) %} -

- - {{ field|safe }} - - {% if extra_field %} - {{extra_field(**kwargs)|safe}} - {% endif %} - - {% if field.errors or extra_field.errors %} - - {% for error in field.errors %}{{ error }}{% endfor %} - {% for error in extra_field.errors %}{{ error }}{% endfor %} - - {% endif %} -

- {% endmacro %} - - {% macro render_field(field) %} - {{ render_fields(field, None) }} - {% endmacro %} - - -
- {{ form.csrf_token }} - - {{ render_field(form.exam) }} - {{ render_fields(form.module, form.module_new, placeholder='Modulname') }} - {{ render_field(form.year) }} - -

- -

-
+ }); + } 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'); + } + }); + + } + }); + }); + {% endblock %} -- cgit v1.2.3-1-g7c22