def get(self, request): ures = UserResource() course_res = CourseResource() pres = ProjectResource(editable=self.viewing_own_records, record_viewer=self.record_viewer, is_viewer_faculty=self.is_viewer_faculty) assignments = [] ctx = { 'space_viewer': ures.render_one(request, self.record_viewer), 'editable': self.viewing_own_records, 'course': course_res.render_one(request, request.course), 'is_faculty': self.is_viewer_faculty, 'is_superuser': request.user.is_superuser, } if self.record_owner: ctx['space_owner'] = ures.render_one(request, self.record_owner) if not request.course.is_true_member(self.record_owner): return self.render_to_json_response(ctx) projects = Project.objects.visible_by_course_and_user( request.course, request.user, self.record_owner, self.viewing_faculty_records) # Show unresponded assignments if viewing self & self is a student if not self.is_viewer_faculty and self.viewing_own_records: assignments = list( Project.objects.unresponded_assignments( request.course, request.user)) else: projects = Project.objects.visible_by_course( request.course, request.user) # update counts and paginate ctx['compositions'] = len(projects) > 0 or len(assignments) > 0 ctx.update(self.paginate(pres, assignments, projects)) return self.render_to_json_response(ctx)
def get(self, request): ures = UserResource() course_rez = CourseResource() pres = ProjectResource(editable=self.viewing_own_records, record_viewer=self.record_viewer, is_viewer_faculty=self.is_viewer_faculty) assignments = [] ctx = { 'space_viewer': ures.render_one(request, self.record_viewer), 'editable': self.viewing_own_records, 'course': course_rez.render_one(request, request.course), 'is_faculty': self.is_viewer_faculty } if (self.record_owner): in_course_or_404(self.record_owner.username, request.course) projects = Project.objects.visible_by_course_and_user( request, request.course, self.record_owner) # Show unresponded assignments if viewing self & self is a student if not self.is_viewer_faculty and self.viewing_own_records: assignments = Project.objects.unresponded_assignments( request, self.record_viewer) ctx['space_owner'] = ures.render_one(request, self.record_owner) ctx['assignments'] = pres.render_assignments(request, assignments) else: projects = Project.objects.visible_by_course(request, request.course) #offset = int(request.GET.get("offset", 0)) #limit = int(request.GET.get("limit", 20)) ctx['projects'] = pres.render_projects(request, projects) ctx['compositions'] = len(projects) > 0 or len(assignments) > 0 return self.render_to_json_response(ctx)
def get(self, request): ures = UserResource() course_res = CourseResource() pres = ProjectResource(editable=self.viewing_own_records, record_viewer=self.record_viewer, is_viewer_faculty=self.is_viewer_faculty) assignments = [] ctx = { 'space_viewer': ures.render_one(request, self.record_viewer), 'editable': self.viewing_own_records, 'course': course_res.render_one(request, request.course), 'is_faculty': self.is_viewer_faculty, 'is_superuser': request.user.is_superuser, } if self.record_owner: ctx['space_owner'] = ures.render_one(request, self.record_owner) if not request.course.is_true_member(self.record_owner): return self.render_to_json_response(ctx) projects = Project.objects.visible_by_course_and_user( request.course, request.user, self.record_owner, self.viewing_faculty_records) # Show unresponded assignments if viewing self & self is a student if not self.is_viewer_faculty and self.viewing_own_records: assignments = Project.objects.unresponded_assignments( request.course, request.user) else: projects = Project.objects.visible_by_course(request.course, request.user) # update counts and paginate ctx['compositions'] = len(projects) > 0 or len(assignments) > 0 ctx.update(self.paginate(pres, assignments, projects)) return self.render_to_json_response(ctx)
def get(self, request): ures = UserResource() course_rez = CourseResource() pres = ProjectResource(editable=self.viewing_own_records, record_viewer=self.record_viewer, is_viewer_faculty=self.is_viewer_faculty) assignments = [] ctx = { 'space_viewer': ures.render_one(request, self.record_viewer), 'editable': self.viewing_own_records, 'course': course_rez.render_one(request, request.course), 'is_faculty': self.is_viewer_faculty } if (self.record_owner): in_course_or_404(self.record_owner.username, request.course) projects = Project.objects.visible_by_course_and_user( request, request.course, self.record_owner, self.viewing_faculty_records) # Show unresponded assignments if viewing self & self is a student if not self.is_viewer_faculty and self.viewing_own_records: assignments = Project.objects.unresponded_assignments( request, self.record_viewer) ctx['space_owner'] = ures.render_one(request, self.record_owner) ctx['assignments'] = pres.render_assignments(request, assignments) else: projects = Project.objects.visible_by_course( request, request.course) ctx['projects'] = pres.render_projects(request, projects) ctx['compositions'] = len(projects) > 0 or len(assignments) > 0 return self.render_to_json_response(ctx)
CourseInviteUserByEmailView, CourseAcceptInvitationView, CourseResendInviteView, set_user_setting, CoursePanoptoSourceView, CoursePanoptoIngestLogView, CourseConvertMaterialsView, LTICourseSelector, LTICourseCreate, SplashView) from mediathread.projects.views import (ProjectCollectionView, ProjectDetailView, ProjectItemView, ProjectPublicView, ProjectListView, AssignmentListView) from mediathread.taxonomy.api import TermResource, VocabularyResource from registration.backends.default.views import RegistrationView from tastypie.api import Api tastypie_api = Api('') tastypie_api.register(TermResource()) tastypie_api.register(VocabularyResource()) tastypie_api.register(CourseResource()) admin.autodiscover() bookmarklet_root = os.path.join(os.path.dirname(__file__), '../media/', 'bookmarklets') redirect_after_logout = getattr(settings, 'LOGOUT_REDIRECT_URL', None) auth_urls = path('accounts/', include('django.contrib.auth.urls')) logout_page = path('accounts/logout/', LogoutView.as_view(), {'next_page': redirect_after_logout}) admin_logout_page = path('accounts/logout/', LogoutView.as_view(), {'next_page': '/admin/'})