def post(self, request): if user_validate(request): teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] # ------end notification data = {'notify': notify, 'notifications': notification} notification_msg = request.POST.get('notification') username = request.POST.get('username') if 'TE' in username: messages.error(request, "You can not send notification to Teacher") elif "ST" in username: user = get_object_or_404(Students, username=username) notification = Notification(student=user, from_user=teacher, notification=notification_msg) notification.save() messages.success( request, f'Notification Send to {user.username} successfully') return redirect('library_send_notification') return redirect('teacher_login')
def get(self, request, username): if validate_user(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 if is_class_teacher(request): student = get_object_or_404(Students, username=username) data = { 'student': student, 'is_ct': True, 'notify': notify, 'notifications': notification } try: documents = Documents.objects.get(student=student) data['documents']: documents except: pass return render(request, 'teachers/student-info.html', data) else: messages.error(request, 'Yo are not a class teacher') return redirect('teacher_home') return redirect('teacher_login')
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')
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')
def post(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] data = request.POST #send cls in dropdown classes = Class.objects.all() cls = data.get('class') section = data.get('section') clss = get_object_or_404(Class, class_name=cls) all_syllabus = Syllabus.objects.filter( class_name=clss.id, section=section, ) data = { 'classes': classes, 'all_syllabus': all_syllabus, 'notify': notify, 'notifications': notification } return render(request, 'teachers/view-syllabus.html', data) else: return redirect('teacher_login')
def search_user(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] username = False user = request.GET.get('user') if 'ST' in user: try: username = Students.objects.get(username = user) except: messages.error(request,'Please check userID') elif 'TE' in user: try: username = Teacher.objects.get(username = user) except: messages.error(request, 'Please check userID') else: messages.error(request, 'Please check userID') if username: books = Books.objects.all() data = {'notify': notify, 'notifications': notification, 'user' : username, 'books':books} return render(request, 'library/issue-book.html', data) else: return redirect('teacher_login')
def get(self, request): if validate_user(request): if is_class_teacher(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 teacher_role = get_object_or_404(Role, user=user.id) students = Students.objects.filter( class_name=teacher_role.class_name, section=teacher_role.section) data = { 'students': students, 'notify': notify, 'notifications': notification } is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/all-students.html', data) else: return redirect('teacher_home') else: return redirect('teacher_login')
def get(self, request): if validate_user(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 try: user_role = Role.objects.get(user=user.id) except: user_role = None if user_role is not None and user_role.role == "Class Teacher": leaves = Leave.objects.filter( is_student=True).order_by('-start_date') data = { 'all_leaves': leaves, 'is_student': True, 'notify': notify, 'notifications': notification } is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/view-leave.html', data) else: messages.error(request, 'You are not class teacher') return redirect('teacher_home') else: return redirect('teacher_login')
def get(self, request): if validate_user(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: all_notice = Notices.objects.filter( Q(recipient__icontains=q) | Q(type__icontains=q)).order_by('-date') else: all_notice = Notices.objects.filter( Q(recipient="All") | Q(recipient="Teacher")).order_by('-date') data = { 'all_notice': all_notice, 'notify': notify, 'notifications': notification } is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/notice.html', data) else: return redirect('teacher_login')
def get(self, request): if user_validate(request): today = datetime.datetime.today() 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 year = request.GET.get('year') month = request.GET.get('month') mnth = [str(i) for i in range(1, 13)] if month in mnth: attandance = Teacher_Attandance.objects.filter( teacher=user.id, datetime__year=year, datetime__month=int(month)) else: attandance = None data = { 'notify': notify, 'notifications': notification, 'year': today.year, 'attandance': attandance } return render(request, 'library/view-attandance.html', data) else: return redirect('teacher_login')
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: notices = Notices.objects.filter( Q(recipient__icontains=q) | Q(type__icontains=q)) if (len(notices) > 0): all_notice = notices else: all_notice = Notices.objects.filter( Q(recipient__icontains="All") | Q(recipient__icontains="Teacher")).order_by('-date') else: all_notice = Notices.objects.filter( Q(recipient__icontains="All") | Q(recipient__icontains="Teacher")).order_by('-date') data = { 'notify': notify, 'notifications': notification, 'all_notice': all_notice } return render(request, 'library/notice.html', data) else: return redirect('teacher_login')
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')
def get(self, 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] data = {'notify': notify, 'notifications': notification} return render(request, "library/change_password.html", data)
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')
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] data = {'notify': notify, 'notifications': notification} return render(request, 'library/issue-book.html', data) else: return redirect('teacher_login')
def post(self, request): if validate_user(request): classes = Class.objects.all() teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] # ------end notification data = { 'classes': classes, 'notify': notify, 'notifications': notification } notify_to = request.POST.get('notify_to') notification_msg = request.POST.get('notification') current_user = get_object_or_404( Teacher, username=request.session.get('user')) if notify_to == '1': # for perticular class and section cls = request.POST.get('class') section = request.POST.get('section') clss = get_object_or_404(Class, class_name=cls) students = Students.objects.filter(class_name=clss, section=section) for stdnt in students: notification = Notification(student=stdnt, from_user=current_user, notification=notification_msg) notification.save() messages.success( request, f'Notification Send to All {clss} {section} Students successfully' ) elif notify_to == '2': #for perticular user username = request.POST.get('username') if 'TE' in username: messages.error(request, "You can not send notification to Teacher") elif "ST" in username: user = get_object_or_404(Students, username=username) notification = Notification(student=user, from_user=current_user, notification=notification_msg) notification.save() messages.success( request, f'Notification Send to {user.username} successfully') return render(request, 'lms_admin/send-notification.html', data) return redirect('teacher_login')
def get(self, request, **kwargs): 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] id = kwargs.get('pk') book = get_object_or_404(Books, pk=id) data = {'book':book, 'notify': notify, 'notifications': notification} return render(request, 'library/edit-book.html', data) else: return redirect('teacher_login')
def get(self, request): if validate_user(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] data = {'notify': notify, 'notifications': notification} is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, "teachers/change_password.html", data) else: return redirect('teacher_login')
def post(self, request): if validate_user(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 today = datetime.date.today() classes = Class.objects.all() subjects = Class_subjects.objects.all() data = request.POST cls = data.get('class') section = data.get('section') subject = data.get('subject') clss = get_object_or_404(Class, class_name=cls) students = Students.objects.filter(class_name=clss.id, section=section) marks = Marks.objects.filter(class_name=clss.id, section=section, subject=subject, date_added__startswith=today) if len(marks) > 0: messages.error( request, f'You already Submitted {subject} marks for Class {cls} {section} . ' ) marked = True else: marked = False data = { 'classes': classes, 'subjects': subjects, 'class': cls, 'section': section, 'subject': subject, 'students': students, 'marked': marked, 'notify': notify, 'notifications': notification } return render(request, 'teachers/upload-marks.html', data) else: return redirect('teacher_login')
def get(self, request): if user_validate(request): teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] # ------end notification data = { 'notify': notify, 'notifications': notification, 'teacher': teacher } return render(request, 'library/edit-profile.html', data) return redirect('teacher_login')
def get(self, request): if validate_user(request): teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] # ------end notification classes = Class.objects.all() data = { 'classes': classes, 'notify': notify, 'notifications': notification } return render(request, 'teachers/send-notification.html', data) return redirect('teacher_login')
def get(self, request): if validate_user(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] data = {'notify': notify, 'notifications': notification} # ------end notification data['user'] = user is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/edit-profile.html', data) else: return redirect('teacher_login')
def get(self, request): if validate_user(request): if is_class_teacher(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 data = { 'is_ct': True, 'notify': notify, 'notifications': notification } date = request.GET.get('date') if date is not None: date = date.split('-') user_name = request.session.get('user') user = get_object_or_404(Teacher, username=user_name) teacher_role = get_object_or_404(Role, user=user.id) std_username = request.GET.get('username') if std_username is not None and date is not None: student = get_object_or_404(Students, username=std_username) if student.class_name == teacher_role.class_name and student.section == teacher_role.section: attandance = Student_Attandance.objects.filter( student=student.id, datetime__year=date[0], datetime__month=date[1], datetime__day=date[2]) if len(attandance) == 1: data['attandance'] = attandance[0] else: messages.error( request, "This Student is not in your class please Check Student ID ." ) return render(request, 'teachers/update-attandance.html', data) else: messages.error(request, 'Yo are not a class teacher') return redirect('teacher_home') else: return redirect('teacher_login')
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 events = Event.objects.all().order_by('start_date') data = { 'notify': notify, 'notifications': notification, 'events': events } return render(request, 'library/events.html', data) else: return redirect('teacher_login')
def get(self, request): if validate_user(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 is_ct = is_class_teacher(request) data = { 'is_ct': is_ct, 'notify': notify, 'notifications': notification } return render(request, 'teachers/apply-leave.html', data) else: return redirect('teacher_login')
def get(self, request): if validate_user(request): is_ct = is_class_teacher(request) teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] data = {'notify': notify, 'notifications': notification} # ------end notification if is_ct: data['is_ct'] = is_ct return render(request, 'teachers/Student-fee.html', data) else: messages.error(request, 'Yo are not a class teacher') return redirect('teacher_home') else: return redirect('teacher_login')
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 leaves = Leave.objects.filter( teacher=user.pk).order_by('start_date') data = { 'notify': notify, 'notifications': notification, 'all_leaves': leaves } return render(request, 'library/view-leave.html', data) else: return redirect('teacher_login')
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 classes = Class.objects.all() data = { 'classes': classes, 'notify': notify, 'notifications': notification } is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/view-syllabus.html', data) else: return redirect('teacher_login')
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 all_books_count = Books.objects.all().count() issue_book_count = Issue_book.objects.all().count() data = { 'notify': notify, 'notifications': notification, 'book_count': all_books_count, 'issue_book_count': issue_book_count } return render(request, 'library/index.html', data) else: return redirect('teacher_login')
def get(self, request, **kwargs): if validate_user(request): teacher = get_object_or_404(Teacher, username=request.session.get('user')) ## for notification noti_info = get_notifications(teacher) notify = noti_info[0] notification = noti_info[1] # ------end notification pk = kwargs.get('pk') mark = get_object_or_404(Marks, pk=pk) data = { 'mark': mark, 'notify': notify, 'notifications': notification } is_ct = is_class_teacher(request) data['is_ct'] = is_ct return render(request, 'teachers/update-mark.html', data) else: return redirect('teacher_login')