summaryrefslogtreecommitdiffstats
path: root/app/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/app/main.py b/app/main.py
index ef4e549..180715e 100644
--- a/app/main.py
+++ b/app/main.py
@@ -23,15 +23,6 @@ def get_studies():
path_rel = os.path.join('studies', abbr)
path_app = os.path.join('app', 'static', path_rel)
studies[abbr] = Storage(path_rel, path_app)
-
- # iterate over all courses in our backend
- for course in g._studies[abbr].get_courses():
- # check if course is already listed
- entry = (course.encode('ascii', errors='ignore'), course)
- if entry not in courses:
- current_app.config['STUDIES'][abbr].append(entry)
-
- current_app.config['STUDIES'][abbr].sort()
return studies
@@ -43,7 +34,10 @@ def upload(study, course = None):
form.study.data = study
# dynamically fill form values
- form.course.choices = current_app.config['STUDIES'][study]
+ courses = set(current_app.config['STUDIES'][study] +
+ get_studies()[study].get_courses())
+ choices = [(k,k) for k in sorted(courses, key=unicode.lower)]
+ form.course.choices = choices
if 'new' not in dict(form.course.choices):
form.course.choices.append(('', u'---'))
form.course.choices.append(('new', u'neuen Kurs hinzufügen'))
@@ -51,12 +45,8 @@ def upload(study, course = None):
if form.validate_on_submit():
if form.course.data == 'new':
course = form.course_new.data
- slug = course.encode('ascii', errors='ignore')
- current_app.config['STUDIES'][study].append((slug,course))
- current_app.config['STUDIES'][study].sort()
-
else:
- course = dict(current_app.config['STUDIES'][study])[form.course.data]
+ course = form.course.data
year = form.year.data
filename = secure_filename(form.exam.data.filename)