Merge branch 'master' of http://gitea.xxhhcty.xyz:8080/zcdsj/factory
This commit is contained in:
commit
90b7e2087b
|
@ -1,5 +1,5 @@
|
|||
from django_filters import rest_framework as filters
|
||||
from apps.ofm.models import MroomBooking
|
||||
from apps.ofm.models import MroomBooking, BorrowRecord
|
||||
|
||||
from .models import LendingSeal
|
||||
from apps.utils.filters import MyJsonListFilter
|
||||
|
@ -22,3 +22,11 @@ class SealFilter(filters.FilterSet):
|
|||
class Meta:
|
||||
model = LendingSeal
|
||||
fields = ['seal']
|
||||
|
||||
|
||||
class BorrowRecordFilter(filters.FilterSet):
|
||||
file_name = filters.CharFilter(label='按文件名称查询', field_name="borrow_file__name", lookup_expr='icontains')
|
||||
borrow_user = filters.CharFilter(label='按借阅人查询', field_name="create_by__name", lookup_expr='icontains')
|
||||
class Meta:
|
||||
model = BorrowRecord
|
||||
fields = ['file_name', 'borrow_user']
|
|
@ -97,7 +97,6 @@ class FileRecord(CommonBDModel):
|
|||
class BorrowRecord(CommonBDModel):
|
||||
"""TN: 借阅、复印、查阅记录"""
|
||||
borrow_file = models.ManyToManyField(FileRecord, related_name="borrow_records")
|
||||
borrow_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="borrow_user")
|
||||
borrow_date = models.DateField('借阅日期', null=True, blank=True)
|
||||
return_date = models.DateField('归还日期', null=True, blank=True)
|
||||
contacts = models.CharField('借阅人电话', max_length=50, validators=[phone_validator], null=True, blank=True)
|
||||
|
|
|
@ -10,7 +10,7 @@ from .serializers import (MroomSerializer, MroomBookingSerializer, MroomSlotSeri
|
|||
from rest_framework.decorators import action
|
||||
from apps.utils.mixins import CustomListModelMixin
|
||||
from rest_framework.exceptions import ParseError
|
||||
from apps.ofm.filters import MroomBookingFilterset, SealFilter
|
||||
from apps.ofm.filters import MroomBookingFilterset, SealFilter, BorrowRecordFilter
|
||||
|
||||
|
||||
class MroomViewSet(CustomModelViewSet):
|
||||
|
@ -144,7 +144,7 @@ class FileborrowViewSet(CustomModelViewSet):
|
|||
"""
|
||||
queryset = BorrowRecord.objects.all()
|
||||
serializer_class = BorrowRecordSerializer
|
||||
filterset_fields = ["borrow_file", "borrow_user"]
|
||||
filterset_class = BorrowRecordFilter
|
||||
ordering = ["create_time"]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue