def create_conference(request): conference = Conference() conference.user = request.user conference.title = request.POST.get('title', 'Unnamed conference') if conference.title == '': conference.title = 'Unnamed conference' conference.save() return redirect('/app/conference/list')
def login_as_guest(request): if request.user.is_authenticated(): # if the user 'guestXYZ' is logged in, don't reset his conference objects, # simply redirect him to the main page # if another (normal) user is already logged in, redirect him to the main page return redirect('/app/conference/list/') else: # Create new guest user suffix = User.objects.make_random_password(length=5, allowed_chars='1234567890') username = "******" + suffix while User.objects.filter(username=username).exists(): suffix = User.objects.make_random_password(length=5, allowed_chars='1234567890') username = "******" + suffix password = '' user = User.objects.create_user(username, '', password) user.save() guest_user = authenticate(username=username, password=password) django_login(request, guest_user) c = Conference() c.user = user c.title = "Demo Conference " + suffix c.num_days = 2 c.schedule_string = '[[[[]], [[]], [[], []]], []]' c.settings_string = '[[[60], [60], [60, 60]], []]' c.names_string = "[[['Slot1'], ['Slot2'], ['Slot 3a', 'Slot 3b']]]" c.start_times = "['7:00', '7:00']" c.save() return redirect('/app/conference/list/')
def copy_conference(request): # Create conference base new_conference = Conference() new_conference.user = request.user copied_conference = Conference.objects.get(pk=request.POST.get('conference', None), user=request.user) new_conference.title = "Copy of " + copied_conference.title # Copy conference structure settings_str = copied_conference.settings_string new_conference.settings_string = settings_str # Copy names names_str = copied_conference.names_string new_conference.names_string = names_str # Create new empty list of papers settings_list = ast.literal_eval(settings_str) new_list = [] for d in settings_list: day = [] for r in d: row = [] for c in r: col = [] row.append(col) day.append(row) new_list.append(day) new_conference.schedule_string = str(new_list) new_conference.num_days = copied_conference.num_days new_conference.slot_length = copied_conference.slot_length new_conference.save() return redirect('/app/conference/list')
def copy_conference(request): # Create conference base new_conference = Conference() new_conference.user = request.user copied_conference = Conference.objects.get(pk=request.POST.get( 'conference', None), user=request.user) new_conference.title = "Copy of " + copied_conference.title # Copy conference structure settings_str = copied_conference.settings_string new_conference.settings_string = settings_str # Copy names names_str = copied_conference.names_string new_conference.names_string = names_str # Create new empty list of papers settings_list = ast.literal_eval(settings_str) new_list = [] for d in settings_list: day = [] for r in d: row = [] for c in r: col = [] row.append(col) day.append(row) new_list.append(day) new_conference.schedule_string = str(new_list) new_conference.num_days = copied_conference.num_days new_conference.slot_length = copied_conference.slot_length new_conference.save() return redirect('/app/conference/list')