forked from YoLoveLife/DevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb8c50
commit 4663181
Showing
24 changed files
with
176 additions
and
190 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 18-3-19 | ||
# Author Yo | ||
# Email [email protected] | ||
import models, serializers | ||
from rest_framework import generics | ||
from rest_framework.pagination import PageNumberPagination | ||
from rest_framework.views import Response, status | ||
from rest_framework.permissions import IsAuthenticated,AllowAny | ||
from deveops.api import WebTokenAuthentication | ||
|
||
__all__ = [ | ||
'TimeLineListByPageAPI', | ||
] | ||
|
||
class TimeLinePagination(PageNumberPagination): | ||
page_size = 10 | ||
|
||
|
||
class TimeLineListByPageAPI(WebTokenAuthentication,generics.ListAPIView): | ||
module = models.History | ||
serializer_class = serializers.HistorySerializer | ||
permission_classes = [IsAuthenticated, ] | ||
pagination_class = TimeLinePagination | ||
queryset = models.History.objects.all() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-16 | ||
# Author Yo | ||
# Email [email protected] | ||
from timeline.models import History | ||
def decorator_api(timeline_type,): | ||
def wrapper(func): | ||
def inner_wrapper(*args, **kwargs): | ||
request, is_validated= func(*args, **kwargs) | ||
history = History(type=timeline_type, ) | ||
history.is_validated = is_validated | ||
history.info = request.data | ||
history.save() | ||
return is_validated #DOT TOUCH it's magic | ||
return inner_wrapper | ||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
from django.db import models | ||
from authority.models import ExtendUser | ||
from execute.models import Callback | ||
import uuid | ||
|
||
|
||
class History(models.Model): | ||
id = models.AutoField(primary_key=True) | ||
uuid = models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False) | ||
user = models.ForeignKey(ExtendUser, blank=True, null=True, default=1, related_name='user',) | ||
type = models.IntegerField(default=0)#历史类型 | ||
is_validated = models.BooleanField(default=False,) | ||
info = models.TextField(default='')#信息 | ||
time = models.DateTimeField(auto_now_add=True,)#历史时间 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding:utf-8 -*- | ||
from manager import models | ||
from rest_framework import serializers | ||
from authority.models import ExtendUser | ||
|
||
__all__ = [ | ||
"HistorySerializer", | ||
] | ||
|
||
|
||
class HistorySerializer(serializers.HyperlinkedModelSerializer): | ||
|
||
class Meta: | ||
model = models.History | ||
fields = ( | ||
'id', 'uuid', 'name', 'info', '_status', 'users', '_framework', 'pmn_groups', 'key', 'jumper', 'framework', | ||
) | ||
read_only_fields = ( | ||
'id', 'uuid', 'framework' | ||
) | ||
write_only_fields = ( | ||
'_framework' | ||
) | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.urls import path | ||
from timeline import api as TimeLineAPI | ||
urlpatterns=[ | ||
# Resource position api | ||
path(r'v1/bypage/', TimeLineAPI.TimeLineListByPageAPI.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,13 @@ | |
# Email [email protected] | ||
from .. import models, serializers | ||
from django.conf import settings | ||
from django.db.models import Q | ||
from rest_framework import generics | ||
from rest_framework.permissions import IsAuthenticated,AllowAny | ||
from rest_framework.pagination import PageNumberPagination | ||
from rest_framework.views import Response, status | ||
from utils.permission import file as FilePermission | ||
import datetime | ||
from deveops.api import WebTokenAuthentication | ||
|
||
__all__ = [ | ||
|
@@ -30,7 +32,11 @@ class UtilsFileListAPI(WebTokenAuthentication,generics.ListAPIView): | |
|
||
def get_queryset(self): | ||
user = self.request.user | ||
query_set = models.FILE.objects.filter(user=user,) | ||
end_time = datetime.datetime.now().strftime('%Y-%m-%d') | ||
start_time = (datetime.datetime.now() - datetime.timedelta(days=2)).strftime('%Y-%m-%d') | ||
query_set = models.FILE.objects.filter(user=user, | ||
pushmission__isnull=False, | ||
create_time__range=(start_time, end_time)) | ||
return query_set | ||
|
||
|
||
|
@@ -46,6 +52,7 @@ def get_queryset(self): | |
return query_set | ||
|
||
|
||
|
||
class UtilsFileCreateAPI(WebTokenAuthentication, generics.CreateAPIView): | ||
module = models.FILE | ||
serializer_class = serializers.FileSerializer | ||
|
@@ -60,3 +67,10 @@ class UtilsFileDeleteAPI(WebTokenAuthentication, generics.DestroyAPIView): | |
lookup_field = 'uuid' | ||
lookup_url_kwarg = 'pk' | ||
|
||
def delete(self, request, *args, **kwargs): | ||
obj = self.get_object() | ||
if not obj.pushmission.exists(): | ||
return super(UtilsFileDeleteAPI, self).delete(request, *args, **kwargs) | ||
else: | ||
return Response({'detail': '该文件已经属于某个任务无法被删除'}, status=status.HTTP_406_NOT_ACCEPTABLE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.