Commit 8944d6e9 by rongjun

bug

parent c2a19616
...@@ -3,11 +3,13 @@ from __future__ import absolute_import ...@@ -3,11 +3,13 @@ from __future__ import absolute_import
from django.db.models.query_utils import Q from django.db.models.query_utils import Q
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.decorators import action
from core.framework.manageviews import TemplateHTMLRendererView, \ from core.framework.manageviews import TemplateHTMLRendererView, \
ManageResponseViewSet, ManageListView, ManageAddView, \ ManageResponseViewSet, ManageListView, ManageAddView, \
ManageEditView, ManageActiveView, ManageDeleteView ManageEditView, ManageActiveView, ManageDeleteView
from core.framework.permissions import IsAuthManager from core.framework.permissions import IsAuthManager
from core.framework.pagination import ManagePagination from core.framework.pagination import ManagePagination
from core.framework.response import MangeAPIResponse
from apps.task.models import Task from apps.task.models import Task
from apps.task.filters import ManageTaskFilter from apps.task.filters import ManageTaskFilter
...@@ -30,8 +32,8 @@ class ManageTaskView(TemplateHTMLRendererView): ...@@ -30,8 +32,8 @@ class ManageTaskView(TemplateHTMLRendererView):
class ManageTaskAPIViewSet(ManageListView, ManageAddView, class ManageTaskAPIViewSet(ManageListView, ManageAddView,
ManageEditView, ManageActiveView, ManageDeleteView, ManageEditView, ManageDeleteView,
ManageResponseViewSet): ManageResponseViewSet):
model = Task model = Task
filter_cls = ManageTaskFilter filter_cls = ManageTaskFilter
queryset = Task.objects.all() queryset = Task.objects.all()
...@@ -39,3 +41,12 @@ class ManageTaskAPIViewSet(ManageListView, ManageAddView, ...@@ -39,3 +41,12 @@ class ManageTaskAPIViewSet(ManageListView, ManageAddView,
serializer_class = ManageTaskSerializer serializer_class = ManageTaskSerializer
add_serializer_class = ManageTaskAddSerializer add_serializer_class = ManageTaskAddSerializer
pagination_class = ManagePagination pagination_class = ManagePagination
@action(methods=['post'], detail=False)
def ban(self, request, **kwargs):
pk = request.GET.get('id')
task = Task.objects.get(pk=pk)
task.active = False
task.save(update_fields=['active'])
task.set_active_list(task.instrument)
return MangeAPIResponse()
...@@ -36,7 +36,10 @@ class Task(BaseModel): ...@@ -36,7 +36,10 @@ class Task(BaseModel):
'type': al.config.get('type'), 'max_val': str(al.config.get('max_val')), 'type': al.config.get('type'), 'max_val': str(al.config.get('max_val')),
'min_val': str(al.config.get('min_val'))} 'min_val': str(al.config.get('min_val'))}
dd.append(d) dd.append(d)
cache.set(instrument, dd, 24*60*60) if not dd:
cache.set(instrument, [], 0)
else:
cache.set(instrument, dd, 24*60*60)
@staticmethod @staticmethod
def get_active_list(instrument): def get_active_list(instrument):
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
add_url = "{% url 'manage-task-add' %}", add_url = "{% url 'manage-task-add' %}",
edit_url = "{% url 'manage-task-edit' %}", edit_url = "{% url 'manage-task-edit' %}",
delete_url = "{% url 'manage-task-delete' %}", delete_url = "{% url 'manage-task-delete' %}",
ban_url = "{% url 'manage-task-ban' %}", ban_url = "{% url 'manage-task-ban' %}";
reset_url = "{% url 'manage-task-reset' %}";
function init() { function init() {
$(fm_add).find("select[name='emails']").attr("multiple", true); $(fm_add).find("select[name='emails']").attr("multiple", true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment