lint: fix many pylint warnings.

This commit is contained in:
Tom Hacohen 2020-02-26 14:21:14 +02:00
parent 358c59f6d7
commit 0beaaf5bf9
2 changed files with 8 additions and 11 deletions

View File

@ -83,7 +83,8 @@ class CollectionItemRevisionSerializer(CollectionItemRevisionBaseSerializer):
class Meta(CollectionItemRevisionBaseSerializer.Meta):
fields = CollectionItemRevisionBaseSerializer.Meta.fields + ('chunksUrls', )
# FIXME: currently the user is exposed in the url. We don't want that, and we can probably avoid that but still save it under the user.
# FIXME: currently the user is exposed in the url. We don't want that, and we can probably avoid that but still
# save it under the user.
# We would probably be better off just let the user calculate the urls from the uid and a base url for the snapshot.
# E.g. chunkBaseUrl: "/media/bla/bla/" or chunkBaseUrl: "https://media.etesync.com/bla/bla"
def get_chunks_urls(self, obj):
@ -108,6 +109,7 @@ class CollectionItemRevisionInlineSerializer(CollectionItemRevisionBaseSerialize
return ret
class CollectionItemSerializer(serializers.ModelSerializer):
content = CollectionItemRevisionSerializer(read_only=True, many=False)

View File

@ -12,15 +12,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.conf import settings
from django.contrib.auth import login, get_user_model
from django.contrib.auth import get_user_model
from django.db import IntegrityError, transaction
from django.db.models import Q
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseBadRequest, HttpResponse, Http404
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from rest_framework import status
from rest_framework import viewsets
@ -29,13 +24,12 @@ from rest_framework.decorators import action as action_decorator
from rest_framework.response import Response
from . import app_settings, paginators
from .models import Collection, CollectionItem, CollectionItemChunk
from .models import Collection, CollectionItem
from .serializers import (
CollectionSerializer,
CollectionItemSerializer,
CollectionItemInlineSerializer,
CollectionItemRevisionSerializer,
CollectionItemRevisionInlineSerializer,
CollectionItemChunkSerializer
)
@ -187,7 +181,8 @@ class CollectionItemChunkViewSet(viewsets.ViewSet):
serializer = self.serializer_class(data=request.data)
if serializer.is_valid():
try:
# FIXME: actually generate the correct order value. Or alternatively have it null at first and only set it when ommitting to a snapshot
# FIXME: actually generate the correct order value. Or alternatively have it null at first and only
# set it when ommitting to a snapshot
serializer.save(item=col_it, order='abc')
except IntegrityError:
content = {'code': 'integrity_error'}