def reload_user(self, request): #self.model.objects.all().delete() Submission.objects.all().delete() creds = UserCredentials() api = CanvasAPI() user_list = api.get_account_users() for user in user_list: userRecord = self.model.objects.filter(canvas_id = user['id']).first() if userRecord is None: user_create = self.model.objects.create(canvas_id = user['id'], name = user['name'], sortable_name = user['sortable_name'], short_name = user['short_name'], sis_user_id = user['sis_user_id'], login_id = user['login_id']) user_create.save() self.message_user(request, "Canvas User list successfully reloaded!") return HttpResponseRedirect("../")
def reload_student(self, request): self.model.objects.all().delete() Submission.objects.all().delete() creds = UserCredentials() api = CanvasAPI() student_list = api.get_account_users() for student in student_list: student_create = self.model.objects.create( canvas_id=student['id'], name=student['name'], sortable_name=student['sortable_name'], short_name=student['short_name'], sis_user_id=student['sis_user_id'], login_id=student['login_id']) student_create.save() self.message_user(request, "Student list successfully reloaded!") return HttpResponseRedirect("../")