def post(self, request, code=""): print(request.POST) for key in request.POST: print("Key: %s\nValue: %s\nTypeof: %s\n" % (key, request.POST[key], type(request.POST[key]))) rtr = "" if "edit" in request.path: rtr = UM(Storage()).edit(request.POST) elif "add" in request.path: rtr = UM(Storage()).add(request.POST) else: print("Someone sent a post fron %s" % request.path) print(rtr) status = "" if rtr[0]: status = "Added Correctly" else: status = rtr[1] return self.edit(request, code=request.POST['username'], fields={'displaystatus': True, 'status': status}) # Just a placeholder
def get(self, request, user): sections = SM(Storage()).view({}) user_sections = [] user = UM(Storage()).view({'username': user}) for s in sections: if (s.get('instructor') == user[0].get('username')): user_sections.append(s) return render(request,"assign/sections.html",{'sections': sections,'user':user, 'user_sections':user_sections})
def post(self, request, code=""): print(request.POST) if "edit" in request.path: CM(Storage()).edit(request.POST) elif "add" in request.path: CM(Storage()).add(request.POST) return redirect('/courses/view')
def post(self, request, code=""): print(request.POST) res = "" if "edit" in request.path: res = SM(Storage()).edit(request.POST) elif "add" in request.path: res = SM(Storage()).add(request.POST) print(res) return redirect('/sections/view')
def post(self, request, user): section_req = request.POST['section_select'] split_sec = section_req.split('-') dept=split_sec[0] cnum=split_sec[1] snum=split_sec[2].split(' ')[0] section = Storage.get_section(dept=dept,cnum=cnum,snum=snum) fields = {'dept':dept,'cnum':cnum,'snum':snum,'instructor':user,'stype':section.stype} res = SM(Storage()).edit(fields) sections = SM(Storage()).view({}) user = UM(Storage()).view({'username': user}) user_sections = [] for s in sections: if (s.get('instructor') == user[0].get('username')): user_sections.append(s) return render(request,"assign/sections.html",{'sections': sections,'user':user, 'user_sections':user_sections})
def view(self, request, code=""): print(request.GET) fields = {} template = "user/viewpublic.html" # The default is just to load only public data if request.user.is_authenticated and request.user.has_perm('TAServer.can_view_private'): template = "user/viewprivate.html" if code != "": fields['title'] = "View %s" % code fields['data'] = UM(Storage()).view({'username': code}) else: fields['title'] = "View All Users" fields['data'] = UM(Storage()).view({}) fields['datafound'] = len(fields['data']) != 0 fields['display_edit_link'] = request.user.has_perm("TAServer.can_edit_user") return render(request, template, fields)
def edit(self, request, code="", fields={}): if code == "": return self.add(request) rolelist = ['TA', 'Instructor', 'Administrator', 'Supervisor'] fields['role_list'] = rolelist fields['action'] = '/user/edit/%s/' % code fields['canedit'] = request.user.has_perm("TAServer.can_edit_user") or (request.user.username == code and request.user.has_perm("TAServer.can_edit_self")) if fields['canedit']: fields['value'] = UM(Storage()).view({'username': code})[0] fields['checked_role'] = fields['value']['role'] else: fields['value'] = {'username': '******'} return render(request, "user/add.html", fields)
def detail(self, request, code=""): section = SM(Storage()).view({'cnum': code[:3], 'snum': code[3:]}) return render(request, "sections/section_detail.html", {'section': section[0]})
def view(self, request, code=""): sections = SM(Storage()).view({}) return render(request, "sections/section_list.html", {'sections': sections})
def detail(self, request, code=""): course = CM(Storage()).view({'dept': code[:2], 'cnum': code[2:]}) return render(request, "courses/course_detail.html", {'course': course[0]})
def view(self, request, code=""): print(SM(Storage()).view({})) courses = CM(Storage()).view({}) return render(request, "courses/course_list.html", {'courses': courses})