def list(self, request, *args, **kwargs): permission_required(request.user, ['school.view_school']) schools = School.objects.all() serializer = SchoolListSerializer(schools, context={'request': request}, many=True) return success_response(serializer.data)
def list(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_smsassign']) sms_assigns = SMSAssign.objects.all() serializer = SMSAssignListSerializer(sms_assigns, context={'request': request}, many=True) return success_response(serializer.data)
def list(self, request, *args, **kwargs): permission_required(request.user, ['school.view_branch']) branches = Branch.objects.all() serializer = BranchListSerializer(branches, context={'request': request}, many=True) return success_response(serializer.data)
def list(self, request, *args, **kwargs): permission_required(request.user, ['school.view_staff']) departments = Staff.objects.all() serializer = StaffListSerializer(departments, context={'request': request}, many=True) return success_response(serializer.data)
def list(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_noticetemplate']) notice_template = NoticeTemplate.objects.all() serializer = NoticeTemplateListSerializer(notice_template, context={'request': request}, many=True) return success_response(serializer.data)
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_sms']) try: sms = SMS.objects.get(pk=kwargs['pk']) serializer = SMSSerializer(sms, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '短信不存在')
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_notice']) try: notice = Notice.objects.get(pk=kwargs['pk']) serializer = NoticeSerializer(notice, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '公告不存在')
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_emailtemplate']) try: email_template = EmailTemplate.objects.get(pk=kwargs['pk']) serializer = EmailTemplateSerializer(email_template, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '邮件模板不存在')
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['oa.view_workreport']) try: work_report = WorkReport.objects.get(pk=kwargs['pk']) serializer = WorkReportSerializer(work_report, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '工作报告不存在')
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['school.view_school']) try: school = School.objects.get(pk=kwargs['pk']) serializer = SchoolSerializer(school, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '学校不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_workreport']) try: work_report = WorkReport.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除工作报告 %s' % work_report.report_user.name) work_report.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '工作报告不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_notification']) try: notification = Notification.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除通知 %s' % notification.from_user.name) notification.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '通知不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_smsrecord']) try: sms_record = SMSRecord.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除短信 %s' % sms_record.content) sms_record.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '短信记录不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['school.delete_school']) try: school = School.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除学校 %s' % school.name) school.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '学校不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_email']) try: email = Email.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除邮件 %s' % email.name) email.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '邮件不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['school.delete_branch']) try: department = Department.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除部门 %s' % department.name) department.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '部门不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['school.delete_branch']) try: branch = Branch.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除校区 %s' % branch.name) branch.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '校区不存在')
def retrieve(self, request, *args, **kwargs): permission_required(request.user, ['school.view_department']) try: department = Department.objects.get(pk=kwargs['pk']) serializer = DepartmentSerializer(department, context={'request': request}) return success_response(serializer.data) except ObjectDoesNotExist: return error_response(1, '部门不存在')
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_noticetemplate']) try: notice_template = NoticeTemplate.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除公告模板 %s' % notice_template.name) notice_template.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '公告模板不存在')
def update(self, request, *args, **kwargs): permission_required(request.user, ['oa.change_workreport']) work_report = WorkReport.objects.get(pk=kwargs['pk']) serializer = WorkReportSerializer(work_report, data=request.data, partial=True) if serializer.is_valid(): serializer.save() add_log(request.user, 2, '修改工作报告 %s,%s' % (work_report.name, queryset_str(request.data))) return success_response(serializer.data) else: return error_response(1, serializer.errors)
def update(self, request, *args, **kwargs): permission_required(request.user, ['oa.change_emailtemplate']) email_template = EmailTemplate.objects.get(pk=kwargs['pk']) serializer = EmailTemplateSerializer(email_template, data=request.data, partial=True) if serializer.is_valid(): serializer.save() add_log(request.user, 2, '修改邮件模板 %s,%s' % (email_template.name, queryset_str(request.data))) return success_response(serializer.data) else: return error_response(1, serializer.errors)
def destroy(self, request, *args, **kwargs): permission_required(request.user, ['oa.delete_smsassign']) try: sms_assign = SMSAssign.objects.get(pk=kwargs['pk']) add_log(request.user, 3, '删除短信分配 %s' % sms_assign.user.get_full_name()) sms_assign.delete() return success_response('删除成功') except ObjectDoesNotExist: return error_response(1, '短信分配不存在')
def update(self, request, *args, **kwargs): permission_required(request.user, ['oa.change_notification']) notification = Notification.objects.get(pk=kwargs['pk']) serializer = NotificationSerializer(notification, data=request.data, partial=True) if serializer.is_valid(): serializer.save() add_log(request.user, 2, '修改通知 %s,%s' % (notification.name, queryset_str(request.data))) return success_response(serializer.data) else: return error_response(1, serializer.errors)
def update(self, request, *args, **kwargs): permission_required(request.user, ['school.change_school']) school = School.objects.get(pk=kwargs['pk']) serializer = SchoolSerializer(school, data=request.data, partial=True) if serializer.is_valid(): serializer.save() add_log(request.user, 2, '修改学校 %s信息,%s' % (school.name, queryset_str(request.data))) return success_response(serializer.data) else: return error_response(1, serializer.errors)
def create(self, request, *args, **kwargs): permission_required(request.user, ['oa.add_workreport']) serializer = self.get_serializer(data=request.data) if serializer.is_valid(): # 添加工作报告 work_report = serializer.create(serializer.validated_data) add_log(request.user, 1, '添加工作报告 %s' % work_report.name) return success_response('添加成功') else: return error_response(1, serializer.errors)
def create(self, request, *args, **kwargs): permission_required(request.user, ['school.add_staff']) serializer = self.get_serializer(data=request.data) if serializer.is_valid(): # 添加部门 staff = serializer.create(serializer.validated_data) add_log(request.user, 1, '添加员工 %s' % staff.user.name) return success_response('添加成功') else: return error_response(1, serializer.errors)
def create(self, request, *args, **kwargs): permission_required(request.user, ['oa.add_noticetemplate']) serializer = self.get_serializer(data=request.data) if serializer.is_valid(): # 添加公告模板 notice_template = serializer.create(serializer.validated_data) add_log(request.user, 1, '添加公告模板 %s' % notice_template.name) return success_response('添加成功') else: return error_response(1, serializer.errors)
def update(self, request, *args, **kwargs): permission_required(request.user, ['oa.change_sms']) sms = SMS.objects.get(pk=kwargs['pk']) serializer = SMSSerializer(sms, data=request.data, partial=True) if serializer.is_valid(): serializer.save() add_log(request.user, 2, '修改短信 %s,%s' % (sms.name, queryset_str(request.data))) return success_response(serializer.data) else: return error_response(1, serializer.errors)
def create(self, request, *args, **kwargs): permission_required(request.user, ['oa.add_smsrecord']) serializer = self.get_serializer(data=request.data) if serializer.is_valid(): # 添加短信 sms = serializer.create(serializer.validated_data) add_log(request.user, 1, '添加短信记录 %s' % sms.to_user_tel) return success_response('添加成功') else: return error_response(1, serializer.errors)
def create(self, request, *args, **kwargs): permission_required(request.user, ['oa.add_smsassign']) serializer = self.get_serializer(data=request.data) if serializer.is_valid(): # 添加短信分配 sms_assign = serializer.create(serializer.validated_data) add_log(request.user, 1, '添加短信分配 %s' % sms_assign.user.get_full_name()) return success_response('添加成功') else: return error_response(1, serializer.errors)