Ejemplo n.º 1
0
    def get(self, request):
        if validate_user(request):
            ## for notification
            user = get_object_or_404(Teacher,
                                     username=request.session.get('user'))
            noti_info = get_notifications(user)
            notify = noti_info[0]
            notification = noti_info[1]
            # ------end  notification
            q = request.GET.get('q')
            if q is not None:
                allonlineclass = OnlineClass.objects.filter(
                    Q(class_name__class_name__icontains=q)
                    | Q(section__icontains=q) | Q(subject__icontains=q)
                    | Q(date__icontains=q))
            else:
                allonlineclass = OnlineClass.objects.filter(teacher=user.id)

            # paginator
            paginator = Paginator(allonlineclass, 1)
            last_page = paginator.page_range[-1]

            page = request.GET.get('page')

            try:
                onlineclass = paginator.page(page)
            except PageNotAnInteger:
                onlineclass = paginator.page(1)
            except EmptyPage:
                onlineclass = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 5
            else:
                (start_index, end_index) = proper_pagination(onlineclass,
                                                             index=3)

            page_range = list(paginator.page_range)[start_index:end_index]

            if page is None or page == 1:
                count = 1
            else:
                count = onlineclass.start_index()

            data = {
                'onlineclasses': onlineclass,
                'page_range': page_range,
                'count': count,
                'last_page': last_page,
                'notify': notify,
                'notifications': notification
            }
            is_ct = is_class_teacher(request)
            data['is_ct'] = is_ct
            if q is not None:
                data['q'] = q
            return render(request, 'teachers/view-schedule-classes.html', data)
        else:
            return redirect('teacher_login')
Ejemplo n.º 2
0
    def get(self, request):
        if validate_user(request):
            ## for notification
            user = get_object_or_404(Teacher,
                                     username=request.session.get('user'))
            noti_info = get_notifications(user)
            notify = noti_info[0]
            notification = noti_info[1]

            # ------end  notification

            q = request.GET.get('q')
            if q is not None:
                assig = Assignment.objects.filter(
                    Q(class_name__class_name__icontains=q)
                    | Q(section__icontains=q)
                    | Q(subject__icontains=q))
                if len(assig) > 0:
                    all_assig = assig
                else:
                    all_assig = Assignment.objects.filter(teacher=user.id)
            else:
                all_assig = Assignment.objects.filter(teacher=user.id)

            # paginator
            paginator = Paginator(all_assig, 10)
            page = request.GET.get('page')

            try:
                all_assign = paginator.page(page)
            except PageNotAnInteger:
                all_assign = paginator.page(1)
            except EmptyPage:
                all_assign = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 5
            else:
                (start_index, end_index) = proper_pagination(all_assign,
                                                             index=3)
            page_range = list(paginator.page_range)[start_index:end_index]
            if page is None or page == 1:
                count = 1
            else:
                count = all_assign.start_index()
            data = {
                'is_ct': True,
                'all_assign': all_assign,
                'page_range': page_range,
                'count': count,
                'notify': notify,
                'notifications': notification
            }
            is_ct = is_class_teacher(request)
            data['is_ct'] = is_ct
            data['q'] = q
            return render(request, 'teachers/assignment.html', data)
        else:
            return redirect('teacher_login')
Ejemplo n.º 3
0
    def get(self, request):
        if user_validate(request):
            user = get_object_or_404(Teacher, username=request.session.get('user'))
            ## for notification
            noti_info = get_notifications(user)
            notify = noti_info[0]
            notification = noti_info[1]

            msg= False
            q = request.GET.get('q')
            if q is not None:
                if "ST" in q:
                    try:
                        user = get_object_or_404(Students, username=q.upper())
                        all_issues = Issue_book.objects.filter(student = user.id)
                    except:
                        msg = f"No Data found related to {q} User."
                elif "TE" in q:
                    try:
                        user = get_object_or_404(Teacher, username= q.upper())
                        all_issues = Issue_book.objects.filter(student=user.id)
                    except:
                        msg = f"No data found related to {q} User."
                else:
                    all_issues = Issue_book.objects.all()
            else:

                all_issues = Issue_book.objects.all()

                if (len(all_issues) < 1):
                    msg = "There is No Record"
            paginator = Paginator(all_issues, 1)
            page = request.GET.get('page')

            try:
                all_issue_books = paginator.page(page)
            except PageNotAnInteger:
                all_issue_books = paginator.page(1)
            except EmptyPage:
                all_issue_books = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 5
            else:
                (start_index, end_index) = proper_pagination(all_issue_books, index=3)

            page_range = list(paginator.page_range)[start_index:end_index]

            if page is None or page == 1:
                count = 1
            else:
                count = all_issue_books.start_index()

            data = {'all_issue_book':all_issue_books, 'page_range': page_range, 'count': count,
                    'msg': msg, 'notify': notify, 'notifications': notification }
            return render(request, 'library/all-issue-book.html', data)
        else:
            return redirect('teacher_login')
Ejemplo n.º 4
0
    def get(self, request):
        if validate_user(request):
            username = request.session.get('user')
            user = get_object_or_404(Students, username=username)

            q = request.GET.get('q')
            print(q, 'Q')
            if q is not None:
                print("q is None")
                assig = Assignment.objects.filter(
                    Q(class_name__class_name__icontains=q)
                    | Q(section__icontains=q)
                    | Q(subject__icontains=q))
                if len(assig) > 0:
                    all_assig = assig
                else:
                    all_assig = Assignment.objects.filter(
                        class_name=user.class_name, section=user.section)
            else:
                all_assig = Assignment.objects.filter(
                    class_name=user.class_name, section=user.section)
                print(all_assig)

            # paginator
            paginator = Paginator(all_assig, 1)
            page = request.GET.get('page')

            try:
                all_assign = paginator.page(page)
            except PageNotAnInteger:
                all_assign = paginator.page(1)
            except EmptyPage:
                all_assign = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 7
            else:
                (start_index, end_index) = proper_pagination(all_assign,
                                                             index=1)

            page_range = list(paginator.page_range)[start_index:end_index]

            if page is None or page == 1:
                count = 1
            else:
                count = all_assign.start_index()

            data = {
                'all_assign': all_assign,
                'page_range': page_range,
                'count': count
            }

            return render(request, 'students/assignment.html', data)
        return redirect('login')
Ejemplo n.º 5
0
    def get(self, request):
        if user_validate(request):
            user = get_object_or_404(Teacher, username=request.session.get('user'))
            ## for notification
            noti_info = get_notifications(user)
            notify = noti_info[0]
            notification = noti_info[1]
            # ------end  notification
            q = request.GET.get('q')
            if q is not None:
                allbooks = Books.objects.filter(
                    Q(book_name__icontains=q)|
                    Q(auther_name__icontains=q)|
                    Q(isbn_number__icontains=q)|
                    Q(subject__icontains=q)
                )
                if len(allbooks)<0:
                    books = Books.objects.all()
                else:
                    books=allbooks
            else:
                books = Books.objects.all()

                # paginator
            paginator = Paginator(books, 1)
            page = request.GET.get('page')

            try:
                all_books = paginator.page(page)
            except PageNotAnInteger:
                all_books = paginator.page(1)
            except EmptyPage:
                all_books = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 5
            else:
                (start_index, end_index) = proper_pagination(all_books, index=3)

            page_range = list(paginator.page_range)[start_index:end_index]

            if page is None or page == 1:
                count = 1
            else:
                count = all_books.start_index()

            data = {'notify': notify, 'notifications': notification, 'books': all_books, 'page_range': page_range,'count': count}
            if q is None:
                data['q']=q
            else:
                data['q']=None
            return render(request, 'library/all-books.html', data)
        else:
            return redirect('teacher_login')
Ejemplo n.º 6
0
    def get(self, request):
        if user_validate(request):
            q = request.GET.get('q')
            if q is not None:
                allbooks = Books.objects.filter(
                    Q(book_name__icontains=q) | Q(auther_name__icontains=q)
                    | Q(isbn_number__icontains=q) | Q(subject__icontains=q))
                if len(allbooks) < 0:
                    books = Books.objects.all()
                else:
                    books = allbooks
            else:
                books = Books.objects.all()

                # paginator
            paginator = Paginator(books, 1)
            page = request.GET.get('page')

            try:
                all_books = paginator.page(page)
            except PageNotAnInteger:
                all_books = paginator.page(1)
            except EmptyPage:
                all_books = paginator.page(paginator.num_pages)

            if page is None:
                start_index = 0
                end_index = 7
            else:
                (start_index, end_index) = proper_pagination(all_books,
                                                             index=1)

            page_range = list(paginator.page_range)[start_index:end_index]

            if page is None or page == 1:
                count = 1
            else:
                count = all_books.start_index()

            data = {
                'books': all_books,
                'page_range': page_range,
                'count': count
            }
            if q is None:
                data['q'] = q
            else:
                data['q'] = None
            return render(request, 'library/all-books.html', data)
        else:
            return redirect('teacher_login')