Exemplo n.º 1
0
    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')
Exemplo n.º 2
0
 def getSectionsAndCoursesByUser(self, username):
     # Retval[0] = courses, Retval[1] = sections
     from Managers.sectionManager import SectionManager as SM
     from Managers.courseManager import CourseManager as CM
     tempSectionManager = SM(self.storage)
     tempCourseManager = CM(self.storage)
     courseList = []
     sectionList = []
     for section in self.storage.get_sections_by():
         if section.instructor is not None and section.instructor.username == username:
             sectionList.append(
                 tempSectionManager.view({
                     "dept": section.course.dept,
                     "cnum": section.course.cnum,
                     "snum": section.snum
                 })[0])
             # if not in courses list already, then add to it
             bCourseAddToList = True  #temp bool for course logic
             for existingCourse in courseList:
                 # If a course already exists we don't add a new one
                 if existingCourse["cnum"] == section.course.cnum:
                     bCourseAddToList = False
             if bCourseAddToList:
                 courseList.append(
                     tempCourseManager.view({
                         "dept": section.course.dept,
                         "cnum": section.course.cnum
                     })[0])
     return courseList, sectionList
Exemplo n.º 3
0
    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})
Exemplo n.º 4
0
    def __init__(self, dm: dsm, parent=None):

        # Right now only CS dept courses can be added with manager.
        # Dept list can be changed to support more departments
        self.depts = ['CS', 'MATH']
        self.storage = dm
        if parent is None:
            from Managers.sectionManager import SectionManager as SM
            self.section_manager = SM(self.storage)
        else:
            self.section_manager = parent
Exemplo n.º 5
0
    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})
Exemplo n.º 6
0
    def setUp(self):

        self.u1 = User.objects.create(username="******",
                                      first_name="Gimpy",
                                      last_name="McGoo",
                                      email="*****@*****.**",
                                      password="******",
                                      role="instructor")
        self.u1.save()
        self.c1 = Course.objects.create(cnum="351",
                                        name="Data Structures and Algorithms",
                                        description="N/A",
                                        dept="CS")
        self.c1.save()
        self.s1 = Section.objects.create(snum="401",
                                         stype="lecture",
                                         course=self.c1,
                                         room=395,
                                         instructor=self.u1,
                                         days="W",
                                         time="12:30PM-1:30PM")
        self.s1.save()
        self.u2 = User.objects.create(username="******",
                                      first_name="Jayson",
                                      last_name="Rock",
                                      email="*****@*****.**",
                                      password="******",
                                      role="instructor")
        self.u2.save()
        self.u3 = User.objects.create(username="******",
                                      first_name="Ron",
                                      last_name="Skimpy",
                                      email="*****@*****.**",
                                      password="******",
                                      role="administrator")
        self.u3.save()
        temp = storage()
        self.sec = SM()
 def setUp(self):
     self.storage = DjangoStorageManager
     self.section_manager = SM(self.storage)
     self.course_manager = CM(self.storage)
     self.user_manager = UM(self.storage)
Exemplo n.º 8
0
 def __init__(self,
              mySM: SM = SM(),
              myUM: UM = UM(JSM()),
              myCM: CM = CM(),
              myAM: AM = AM(JSM())):
     pass
Exemplo n.º 9
0
 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]})
Exemplo n.º 10
0
 def view(self, request, code=""):
     sections = SM(Storage()).view({})
     return render(request, "sections/section_list.html", {'sections': sections})
Exemplo n.º 11
0
 def view(self, request, code=""):
     print(SM(Storage()).view({}))
     courses = CM(Storage()).view({})
     return render(request, "courses/course_list.html", {'courses': courses})