question search
This commit is contained in:
parent
1837f67df5
commit
8c1f912bc6
|
@ -63,6 +63,10 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"useExtendedLib": {
|
||||
"kbone": true,
|
||||
"weui": true
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
|
@ -5,9 +5,7 @@
|
|||
<view class="weui-article">
|
||||
<view class="weui-article__h2">{{tm_index+1}}.
|
||||
<span class="txlabel">{{tm_current.type}}</span>
|
||||
</view>
|
||||
<view style="text-align:center">
|
||||
<span style="color:drakblue;font-weight:bold;font-size:14px">{{tm_current.questioncat_name}}</span>
|
||||
<span style="color:gray"> {{tm_current.questioncat_name}}</span>
|
||||
</view>
|
||||
<view class="weui-article__title">{{tm_current.name}}</view>
|
||||
<view wx:if="{{tm_current.img}}" style="text-align:center"><image src="{{tm_current.img}}" mode="aspectFit"></image></view>
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
<view class="weui-article">
|
||||
<view class="weui-article__h2">{{tm_index+1}}.
|
||||
<span class="txlabel">{{currentTm.type}}</span>
|
||||
<span style="color:gray"> {{currentTm.questioncat_name}}</span>
|
||||
</view>
|
||||
<view style="text-align:center">
|
||||
<span style="color:drakblue;font-weight:bold;font-size:14px">{{currentTm.questioncat_name}}</span>
|
||||
(
|
||||
<span style="color:orange;font-weight:bold;font-size:14px">{{currentTm.dtime}}</span>
|
||||
)
|
||||
</view>
|
||||
<view class="weui-article__title">{{currentTm.name}}</view>
|
||||
<view wx:if="{{currentTm.img}}" style="text-align:center"><image src="{{currentTm.img}}" mode="aspectFit"></image></view>
|
||||
|
|
|
@ -42,6 +42,9 @@ Page({
|
|||
background: images
|
||||
})
|
||||
})
|
||||
that.setData({
|
||||
search: this.search.bind(this)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -236,5 +239,18 @@ Page({
|
|||
// })
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
search: function (value) {
|
||||
api.request('/question/question/', 'GET', {search:value}).then(res => {
|
||||
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve([{text: '搜索结果', value: 1}, {text: '搜索结果2', value: 2}])
|
||||
}, 200)
|
||||
})
|
||||
},
|
||||
selectResult: function (e) {
|
||||
|
||||
},
|
||||
})
|
|
@ -1,3 +1,5 @@
|
|||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {
|
||||
"mp-searchbar": "weui-miniprogram/searchbar/searchbar"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
<view class="page">
|
||||
<view>
|
||||
<mp-searchbar bindselectresult="selectResult" search="{{search}}" placeholder="搜题"></mp-searchbar>
|
||||
</view>
|
||||
<view class="page-section page-section-spacing swiper">
|
||||
<swiper indicator-dots="{{indicatorDots}}"
|
||||
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" style='height:{{Hei}}'>
|
||||
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" style='height:{{Hei}}'>
|
||||
<block wx:for="{{background}}" wx:key="*this">
|
||||
<swiper-item>
|
||||
<image style="width: 100%;" src="{{item}}" bindload='imgH'></image>
|
||||
|
@ -9,10 +11,10 @@
|
|||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="3000">
|
||||
<swiper class="swiper_container1" vertical="true" autoplay="true" circular="true" interval="3000">
|
||||
<block wx:for="{{msgList}}" wx:key="title">
|
||||
<swiper-item>
|
||||
<view class="swiper_item">{{item.title}}</view>
|
||||
<view class="swiper_item1">{{item.title}}</view>
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
.swiper_container {
|
||||
.swiper_container1 {
|
||||
margin-top:12rpx;
|
||||
height: 50rpx;
|
||||
width: 100%;
|
||||
text-align: center
|
||||
}
|
||||
.swiper_item {
|
||||
.swiper_item1 {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color:darkblue;
|
||||
|
|
|
@ -2,6 +2,7 @@ from rbac.permission import RbacPermission
|
|||
from rbac.models import UserProfile
|
||||
from crm.models import Consumer
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from django.core.cache import cache
|
||||
|
||||
# 学员接口列表
|
||||
ConsumerPerms = [
|
||||
|
@ -20,6 +21,10 @@ VistorPerms = [
|
|||
'questioncat_view',
|
||||
'my_examtest',
|
||||
]
|
||||
def get_consumerperm_list(consumer):
|
||||
perms = consumer.role.perms.values_list('code', flat=True)
|
||||
cache.get_or_set(consumer.username + '__perms', perms)
|
||||
return perms
|
||||
|
||||
class MyPermission(RbacPermission):
|
||||
|
||||
|
@ -37,10 +42,10 @@ class MyPermission(RbacPermission):
|
|||
# perms = get_permission_list(request.user)
|
||||
return True
|
||||
elif isinstance(request.user,Consumer):
|
||||
if request.user.workscope:
|
||||
perms = ConsumerPerms
|
||||
if cache.get(request.user.username + '__perms'):
|
||||
perms = cache.get(request.user.username + '__perms')
|
||||
else:
|
||||
perms = VistorPerms
|
||||
perms = get_consumerperm_list(request.user)
|
||||
if perms:
|
||||
if not hasattr(view, 'perms_map'):
|
||||
return True
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from rest_framework import serializers
|
||||
from .models import Company, Consumer, PaySubject, ConsumerPerm, ConsumerRole
|
||||
from question.models import Question, Questioncat
|
||||
|
||||
from .permission import get_consumerperm_list
|
||||
|
||||
|
||||
class ConsumerPermSerializer(serializers.ModelSerializer):
|
||||
|
@ -35,7 +35,7 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
|||
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
||||
workscope_name = serializers.StringRelatedField(source='workscope', read_only=True)
|
||||
role_name = serializers.StringRelatedField(source='role', read_only=True)
|
||||
|
||||
perms = serializers.SerializerMethodField(read_only=True)
|
||||
class Meta:
|
||||
model = Consumer
|
||||
exclude = ('avatar','collects')
|
||||
|
@ -46,3 +46,6 @@ class ConsumerSerializer(serializers.ModelSerializer):
|
|||
queryset = queryset.select_related('company','workscope')
|
||||
queryset = queryset.prefetch_related('subjects',)
|
||||
return queryset
|
||||
|
||||
def get_perms(self,obj):
|
||||
return get_consumerperm_list(obj)
|
|
@ -293,9 +293,11 @@ class ConsumerViewSet(ModelViewSet):
|
|||
@action(methods=['get'], detail=False,
|
||||
url_path='correctrole', url_name='correct_role', perms_map=[{'*':'correct_role'}])
|
||||
def correctrole(self, request):
|
||||
role0 = ConsumerRole.objects.get(name='游客')
|
||||
role1 = ConsumerRole.objects.get(name='付费学员')
|
||||
role2 = ConsumerRole.objects.get(name='注册用户')
|
||||
for i in Consumer.objects.all():
|
||||
for i in Consumer.objects.filter(role__isnull = True):
|
||||
i.role = role0
|
||||
if i.workscope and i.username:
|
||||
i.role = role1
|
||||
elif i.username and i.openid:
|
||||
|
|
|
@ -101,7 +101,7 @@ class QuestionViewSet(ModelViewSet):
|
|||
ordering = ['-create_time']
|
||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||
filterset_fields = ['questioncat','level', 'type']
|
||||
search_fields = ['^name']
|
||||
search_fields = ['name', 'options', 'resolution']
|
||||
|
||||
@action(methods=['post'], detail=False,
|
||||
url_path='count', url_name='question_count')
|
||||
|
|
Loading…
Reference in New Issue