Beispiel #1
0
    def create(self, request, *args, **kwargs):
        permission_required(request.user, ['oa.add_workreporttemplate'])
        serializer = self.get_serializer(data=request.data)
        if serializer.is_valid():
            # 添加工作报告模板
            work_report_template = serializer.create(serializer.validated_data)

            add_log(request.user, 1, '添加工作报告模板 %s' % work_report_template.name)
            return success_response('添加成功')
        else:
            return error_response(1, serializer.errors)
Beispiel #2
0
    def create(self, request, *args, **kwargs):
        permission_required(request.user, ['oa.add_notification'])
        serializer = self.get_serializer(data=request.data)
        if serializer.is_valid():
            # 添加通知
            notification = serializer.create(serializer.validated_data)

            add_log(request.user, 1, '添加通知 %s' % notification.name)
            return success_response('添加成功')
        else:
            return error_response(1, serializer.errors)
Beispiel #3
0
 def update(self, request, *args, **kwargs):
     permission_required(request.user, ['school.change_staff'])
     staff = Staff.objects.get(pk=kwargs['pk'])
     serializer = StaffSerializer(staff, data=request.data, partial=True)
     if serializer.is_valid():
         serializer.save()
         add_log(
             request.user, 2,
             '修改员工 %s信息,%s' % (staff.user.name, queryset_str(request.data)))
         return success_response(serializer.data)
     else:
         return error_response(1, serializer.errors)
Beispiel #4
0
    def create(self, request, *args, **kwargs):
        permission_required(request.user, ['school.add_department'])
        print(request.data)
        serializer = self.get_serializer(data=request.data)
        if serializer.is_valid():
            # 添加部门
            department = serializer.create(serializer.validated_data)

            add_log(request.user, 1, '添加部门 %s' % department.name)
            return success_response('添加成功')
        else:
            return error_response(1, serializer.errors)
Beispiel #5
0
    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)
Beispiel #6
0
 def update(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.change_notice'])
     notice = Notice.objects.get(pk=kwargs['pk'])
     serializer = NoticeSerializer(notice, data=request.data, partial=True)
     if serializer.is_valid():
         serializer.save()
         add_log(
             request.user, 2,
             '修改公告 %s,%s' % (notice.content, queryset_str(request.data)))
         return success_response(serializer.data)
     else:
         return error_response(1, serializer.errors)
Beispiel #7
0
 def update(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.change_smsassign'])
     sms_assign = SMSAssign.objects.get(pk=kwargs['pk'])
     serializer = SMSAssignSerializer(sms_assign,
                                      data=request.data,
                                      partial=True)
     if serializer.is_valid():
         serializer.save()
         add_log(
             request.user, 2, '修改短信分配 %s,%s' %
             (sms_assign.user.get_full_name(), queryset_str(request.data)))
         return success_response(serializer.data)
     else:
         return error_response(1, serializer.errors)
Beispiel #8
0
 def update(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.change_smsrecord'])
     sms_record = SMSRecord.objects.get(pk=kwargs['pk'])
     serializer = SMSRecordSerializer(sms_record,
                                      data=request.data,
                                      partial=True)
     if serializer.is_valid():
         serializer.save()
         add_log(
             request.user, 2, '修改短信记录 %s,%s' %
             (sms_record.to_user_tel, queryset_str(request.data)))
         return success_response(serializer.data)
     else:
         return error_response(1, serializer.errors)
Beispiel #9
0
 def update(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.change_smstemplate'])
     sms_template = SMSTemplate.objects.get(pk=kwargs['pk'])
     serializer = SMSTemplateSerializer(sms_template,
                                        data=request.data,
                                        partial=True)
     if serializer.is_valid():
         serializer.save()
         add_log(
             request.user, 2, '修改短信模板 %s,%s' %
             (sms_template.name, queryset_str(request.data)))
         return success_response(serializer.data)
     else:
         return error_response(1, serializer.errors)
Beispiel #10
0
 def list(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.view_workreport'])
     work_report = WorkReport.objects.all()
     serializer = WorkReportListSerializer(work_report, context={'request': request}, many=True)
     return success_response(serializer.data)
Beispiel #11
0
 def list(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.view_emailtemplate'])
     email_templates = EmailTemplate.objects.all()
     serializer = EmailTemplateListSerializer(email_templates, context={'request': request}, many=True)
     return success_response(serializer.data)
Beispiel #12
0
 def list(self, request, *args, **kwargs):
     permission_required(request.user, ['oa.view_notification'])
     notifications = Notification.objects.all()
     serializer = NotificationListSerializer(notifications, context={'request': request}, many=True)
     return success_response(serializer.data)