Exemplo n.º 1
0
def plusTutorAllowedTeamsNumber(request):
    tutor = getTutorUserFromRequest(request)
    tutorCourse = tutor.getTutorCourseByCourseId(
        request.session.get('selected_course_id'))
    tutorCourse.allowedTeamsNumber += 1
    tutorCourse.save()
    return redirect('tutor_projects:projects')
Exemplo n.º 2
0
 def test_get_tutor_user_from_request(self):
     client = Client()
     client.login(username='******', password='******')
     request = self.factory.get('/zpr/')
     request.user = self.user
     userFromRequest = getTutorUserFromRequest(request)
     self.assertEqual(userFromRequest.profile.user.user, self.user)
Exemplo n.º 3
0
 def dispatch(self, request, *args, **kwargs):
     if has_tutor_permissions(request.user):
         tutor = getTutorUserFromRequest(request)
         if tutor.is_admin:
             request.session['isAdmin'] = True
         return super(IndexView, self).dispatch(request, *args, **kwargs)
     else:
         return HttpResponseForbidden(
             'User has no access rights for viewing this page')
Exemplo n.º 4
0
 def test_plusTutorAllowedTeamsNumber(self):
     session = self.client.session
     session['selected_course_id'] = 1
     session.save()
     request = self.client.post('/zpr/tutor/projects/teamsNumber/plus')
     request.user = self.user
     userFromRequest = getTutorUserFromRequest(request)
     self.assertEqual(
         userFromRequest.getTutorAllowedTeamsNumberByCourseId(1), 3)
Exemplo n.º 5
0
    def get(self, request):
        posts = []
        selectedCourseId = request.session.get('selected_course_id')
        if selectedCourseId is not None:
            try:
                posts = Post.objects.filter(
                    course=selectedCourseId).order_by('-creation_time')
            except Post.DoesNotExist:
                pass
        else:
            posts = Post.objects.all().order_by('-creation_time')

        tutor = getTutorUserFromRequest(request)
        tutorCourses = tutor.courses.all()
        request.session['courses'] = tutorCourses
        return render(request, self.template_name, {'posts': posts})
Exemplo n.º 6
0
    def get(self, request):
        delayErrorAlertFade(request, 'wrongFile')
        selectedCourseId = request.session.get('selected_course_id')
        if (selectedCourseId is not None):
            tutor = getTutorUserFromRequest(request)
            tutorCourse = tutor.getTutorCourseByCourseId(selectedCourseId)

            allCourseProjects = Project.objects.filter(course=selectedCourseId)
            return render(
                request, self.template_name, {
                    'nbar': 'projects',
                    'course_projects': allCourseProjects,
                    'tutorAllowedTeamsNumber': tutorCourse.allowedTeamsNumber
                })
        else:
            return redirect('tutor:index')
Exemplo n.º 7
0
 def form_valid(self, form):
     tutor = getTutorUserFromRequest(self.request)
     form.instance.tutor = tutor
     return super(PostCreate, self).form_valid(form)
Exemplo n.º 8
0
def assignTutorToCourse(request, pk):
    tutor = getTutorUserFromRequest(request)
    course = Course.objects.get(id=pk)
    course.tutoruser_set.add(tutor)
    course.save()
    return redirect('tutor_courses:index')
Exemplo n.º 9
0
 def get(self, request):
     tutor = getTutorUserFromRequest(request)
     allCourses = Course.objects.all()
     templateCourses = populateTemplateCourses(allCourses, tutor)
     return render(request, self.template_name,
                   {'nbar': 'courses', 'courses': templateCourses})