def get(self, request): try: class_id = request.GET['class_id'] week_day = request.GET['week_day'] if WeeklySchedule.objects.filter(class_id=class_id, week_day=week_day).exists(): temp_week = WeeklySchedule.objects.get(class_id=class_id, week_day=week_day) serializer = serializers.WeeklyScheduleSerializer(temp_week) return CustomResponse(self, status_code=200, errors=[], message="", data=serializer.data, status=status.HTTP_200_OK) else: return CustomResponse(self, status_code=406, errors=[], message="برنامه مورد نظر یافت نشد .", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get(self, request): try: day = request.GET['day'] month = request.GET['month'] year = request.GET['year'] if AttendanceList.objects.filter(day=day, month=month, year=year).exists(): temp_list = AttendanceList.objects.filter(day=day, month=month, year=year) serializer = serializers.AttendanceSerializer(temp_list, many=True) return CustomResponse(self, status_code=200, errors=[], message="", data=serializer.data, status=status.HTTP_200_OK) else: return CustomResponse( self, status_code=406, errors=['دانش آموزی امروز مدرسه نیومده .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get(self, request): try: section_id = request.GET['section_id'] if Lessons.objects.filter(section_id=section_id).exists(): temp_lessons = Lessons.objects.filter(section_id=section_id) serializer = serializers.LessonsSerializers(temp_lessons, many=True) return CustomResponse(self, status_code=200, errors=[], message="", data=serializer.data, status=status.HTTP_200_OK) else: return CustomResponse( self, status_code=406, errors=[], message="درسی برای مقطع مورد نظر وجود ندارد .", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def post(self, request): try: serializer = serializers.GradeListSerializer(data=request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="نمره دانش آموز با موفقیت ثبت شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse(self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get(self, request): try: grade_owner = request.GET['grade_owner'] teacher_id = request.GET['teacher_id'] if GradeList.objects.filter(grade_owner_id=grade_owner, teacher_id=teacher_id).exists(): temp_grade = GradeList.objects.filter( grade_owner_id=grade_owner, teacher_id=teacher_id) serializer = serializers.GradeListSerializer(temp_grade, many=True) return CustomResponse(self, status_code=200, errors=[], message="", data=serializer.data, status=status.HTTP_200_OK) else: return CustomResponse(self, status_code=406, errors=['نمره ای یافت نشد .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def put(self, request): try: role = request.user.role if role == 3 or role == 4: return CustomResponse( self, status_code=403, errors=["شما دسترسی به این بخش را ندارید"], message="", data="", status=status.HTTP_403_FORBIDDEN) else: class_id = request.GET['class_id'] week_day = request.GET['week_day'] if WeeklySchedule.objects.filter(week_day=week_day, class_id=class_id).exists(): temp_week = WeeklySchedule.objects.get(week_day=week_day, class_id=class_id) serializer = serializers.WeeklyScheduleSerializer( temp_week, request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="برنامه با موفقیت ویرایش شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse( self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) else: return CustomResponse( self, status_code=406, errors=["برنامه با این ایدی وجود ندارد"], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def put(self, request): try: grade_owner = request.GET['grade_owner'] lesson_id = request.GET['lesson_id'] day = request.GET['day'] month = request.GET['month'] year = request.GET['year'] if GradeList.objects.filter(grade_owner_id=grade_owner, lesson_id=lesson_id, day=day, month=month, year=year).exists(): temp_grade = GradeList.objects.get(grade_owner_id=grade_owner, lesson_id=lesson_id, day=day, month=month, year=year) serializer = serializers.GradeListSerializer( temp_grade, request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="نمره این درس با موفقیت بروزرسانی شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse( self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) else: return CustomResponse( self, status_code=406, errors=['دانش آموز در این درس نمره ای ندارد .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def put(self, request): try: role = request.user.role if role == 3 or role == 4: return CustomResponse( self, status_code=403, errors=["شما دسترسی به این بخش را ندارید"], message="", data="", status=status.HTTP_403_FORBIDDEN) else: lesson_id = request.GET['lesson_id'] if Lessons.objects.all().filter(id=lesson_id).exists(): temp_lesson = Lessons.objects.get(id=lesson_id) serializer = serializers.LessonsSerializers( temp_lesson, request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="درس با موفقیت ویرایش شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse( self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) else: return CustomResponse( self, status_code=406, errors=["درس با این ایدی وجود ندارد"], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def put(self, request): try: user_id = request.GET['user_id'] day = request.GET['day'] month = request.GET['month'] year = request.GET['year'] if AttendanceList.objects.filter(day=day, month=month, year=year, user_id=user_id).exists(): temp_row = AttendanceList.objects.get(day=day, month=month, year=year, user_id=user_id) serializer = serializers.AttendanceSerializer( temp_row, request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="اطلاعات با موفقیت اپدیت شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse( self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) else: return CustomResponse( self, status_code=406, errors=['دانش آموزش مورد نظر امروز مدرسه نیومده .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def get(self, request): try: temp_all_lessons = Lessons.objects.all() serializer = serializers.LessonsSerializers(temp_all_lessons, many=True) return CustomResponse(self, status_code=200, errors=[], message="", data=serializer.data, status=status.HTTP_200_OK) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request): try: role = request.user.role if role == 3 or role == 4: return CustomResponse( self, status_code=403, errors=["شما دسترسی به این بخش را ندارید"], message="", data="", status=status.HTTP_403_FORBIDDEN) else: week_day = request.GET['week_day'] class_id = request.GET['class_id'] if WeeklySchedule.objects.filter(week_day=week_day, class_id=class_id).exists(): WeeklySchedule.objects.get(week_day=week_day, class_id=class_id).delete() return CustomResponse(self, status_code=200, errors=[], message="برنامه با موفقیت حذف شد .", data="", status=status.HTTP_200_OK) else: return CustomResponse( self, status_code=406, errors=["برنامه با این ایدی وجود ندارد"], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: patrace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def post(self, request): try: role = request.user.role if role == 3 or role == 4: return CustomResponse( self, status_code=403, errors=["شما دسترسی به این بخش را ندارید"], message="", data="", status=status.HTTP_403_FORBIDDEN) else: serializer = serializers.WeeklyScheduleSerializer( data=request.data) if serializer.is_valid(): serializer.save() return CustomResponse( self, status_code=200, errors=[], message="برنامه با موفقیت ایجاد شد .", data="", status=status.HTTP_200_OK) else: message = serializer.errors return CustomResponse( self, status_code=406, errors=message, message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request): try: grade_owner = request.GET['grade_owner'] lesson_id = request.GET['lesson_id'] day = request.GET['day'] month = request.GET['month'] year = request.GET['year'] if GradeList.objects.filter(grade_owner_id=grade_owner, lesson_id=lesson_id, day=day, month=month, year=year): GradeList.objects.get(grade_owner_id=grade_owner, lesson_id=lesson_id, day=day, month=month, year=year).delete() return CustomResponse( self, status_code=200, errors=[], message="نمره این درس دانش آموز حذف شد .", data="", status=status.HTTP_200_OK) else: return CustomResponse( self, status_code=406, errors=['دانش آموز در این درس نمره ای ندارد .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def delete(self, request): try: user_id = request.GET['user_id'] day = request.GET['day'] month = request.GET['month'] year = request.GET['year'] if AttendanceList.objects.filter(day=day, month=month, year=year, user_id=user_id).exists(): temp_list = AttendanceList.objects.get( day=day, month=month, year=year, user_id=user_id).delete() return CustomResponse( self, status_code=200, errors=[], message="دانش آموز مورد نظر از لیست حضور حذف شد .", data="", status=status.HTTP_200_OK) else: return CustomResponse( self, status_code=406, errors=['دانش آموزش مورد نظر امروز مدرسه نیومده .'], message="", data="", status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: trace_back = traceback.format_exc() message = str(e) + ' ' + str(trace_back) return CustomResponse(self, status_code=500, errors=message, message="", data="", status=status.HTTP_500_INTERNAL_SERVER_ERROR)