Ejemplo n.º 1
0
    def get(self, request, *args, **kwargs):
        creds = UserCredentials()
        api = CanvasAPI()

        activeTerms = ActiveTerm.objects.order_by('-active_term')

        for activeTerm in activeTerms:
            term = activeTerm.active_term
            canvasID = api.get_canvasID(creds.get_OUNetID())
            api_response = api.get_class_by_teacher(canvasID, term.term_id)
            api_list = list(api_response)

            for course in api_list:
                course_id = int(course['id'])
                course_found = self.model.objects.filter(
                    course_id=course_id).first()

                if course_found is None:
                    subaccount = Subaccount.objects.filter(
                        subaccount_id=course['account_id']).first()
                    course_create = self.model.objects.create(
                        course_id=course_id,
                        name=course['name'],
                        course_code=course['course_code'],
                        term=term,
                        subaccount=subaccount)
                    course_create.save()

        return super(CourseListView, self).get(request, *args, **kwargs)
Ejemplo n.º 2
0
    def get_queryset(self):
        creds = UserCredentials()
        api = CanvasAPI()

        canvasID = api.get_canvasID(creds.get_OUNetID())
        api_response = api.get_class_by_teacher(canvasID)
        api_list = list(api_response)

        course_ids = []
        for course in api_list:
            course_ids.append(int(course['id']))

        return self.model.objects.filter(course_id__in=course_ids)
Ejemplo n.º 3
0
    def get_queryset(self):
        creds = UserCredentials()
        api = CanvasAPI()

        activeTerms = ActiveTerm.objects.order_by('-active_term')

        canvasID = api.get_canvasID(creds.get_OUNetID())
        course_ids = []
        for activeTerm in activeTerms:
            term = activeTerm.active_term
            api_response = api.get_class_by_teacher(canvasID, term.term_id)
            api_list = list(api_response)

            for course in api_list:
                course_ids.append(int(course['id']))

        return self.model.objects.filter(course_id__in=course_ids)