parent
8ded9ff4fc
commit
b154d90eed
2 changed files with 7 additions and 2 deletions
7
vendor/symposion/schedule/forms.py
vendored
7
vendor/symposion/schedule/forms.py
vendored
|
@ -1,5 +1,6 @@
|
|||
import csv
|
||||
import time
|
||||
from io import TextIOWrapper
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -66,6 +67,9 @@ class ScheduleSectionForm(forms.Form):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.schedule = kwargs.pop("schedule")
|
||||
if 'encoding' in kwargs:
|
||||
self.encoding = kwargs['encoding']
|
||||
kwargs.pop('encoding')
|
||||
super(ScheduleSectionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
def clean_filename(self):
|
||||
|
@ -118,7 +122,8 @@ class ScheduleSectionForm(forms.Form):
|
|||
|
||||
def build_schedule(self):
|
||||
created_items = []
|
||||
reader = csv.DictReader(self.cleaned_data.get('filename'))
|
||||
f = TextIOWrapper(self.cleaned_data.get('filename'), encoding=self.encoding)
|
||||
reader = csv.DictReader(f)
|
||||
data = [dict((k.strip(), v.strip()) for k, v in x.items()) for x in reader]
|
||||
# build rooms
|
||||
created_items.extend(self._build_rooms(data))
|
||||
|
|
2
vendor/symposion/schedule/views.py
vendored
2
vendor/symposion/schedule/views.py
vendored
|
@ -129,7 +129,7 @@ def schedule_edit(request, slug=None):
|
|||
|
||||
if request.method == "POST":
|
||||
form = ScheduleSectionForm(
|
||||
request.POST, request.FILES, schedule=schedule
|
||||
request.POST, request.FILES, schedule=schedule, encoding=request.encoding
|
||||
)
|
||||
if form.is_valid():
|
||||
if 'submit' in form.data:
|
||||
|
|
Loading…
Reference in a new issue