Gitlab CSE Unil

Commit 257ac42d authored by Julien Furrer's avatar Julien Furrer
Browse files

PEP 8 conforming

parent bc2aced5
# coding=utf-8
from __future__ import unicode_literals
from django.contrib import admin
from eav.admin import BaseEntityAdmin, BaseSchemaAdmin
# from sorl.thumbnail.admin import AdminImageMixin
from eav.admin import BaseEntityAdmin
from adim.models import AnObj, Annotation # AOSchema, AOType, AOAttribute, AOChoice
# from adim.forms import AnObjForm
class AnObjAdmin(BaseEntityAdmin):
pass
......
......@@ -9,4 +9,3 @@ BaseDynamicEntityForm.FIELD_CLASSES.update({'image': ImageField})
class AnObjForm(BaseDynamicEntityForm):
model = AnObj
......@@ -163,7 +163,7 @@ class AnObj(models.Model):
Add members through Membership, with specified publish mode
"""
publish_mode = kwargs.get('publish_mode', 0)
memberships = []
# memberships = []
for user in args:
AnObjMembership.objects.get_or_create(anobj=self, user=user, defaults={'publish_mode': publish_mode})
#
......
# coding=utf-8
from __future__ import unicode_literals
# import json
from django.db import models
from django.utils.translation import ugettext as _
from django.conf import settings
......@@ -32,5 +31,4 @@ class Annotation(models.Model):
# except (TypeError, ValueError):
# item = None
#
# super(Annotation, self).save(*args, **kwargs)
# super(Annotation, self).save(*args, **kwargs)
\ No newline at end of file
......@@ -3,7 +3,6 @@ from __future__ import unicode_literals
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from .models import AnObjMembership
import json
SHARING_MODE_NONE = 0
SHARING_MODE_MANUAL = 1
......
# coding=utf-8
from __future__ import unicode_literals
from django.conf import settings
from django.contrib.auth import get_user_model
from rest_framework import serializers
from rest_framework.fields import Field
from adim.models import AnObj, Annotation
# from sorl.thumbnail import get_thumbnail
import json
from django.core.cache import cache
ANOBJ_THUMB_CACHE_BASE_KEY = 'anobj_thumb_url'
#from rest_framework.pagination import PaginationSerializer
class UserSerializer(serializers.ModelSerializer):
# full_name = serializers.Field(source='get_full_name')
......@@ -43,7 +36,7 @@ class AnnotationSerializer(serializers.ModelSerializer):
class BaseAnObjSerializer(serializers.ModelSerializer):
#owner_name = serializers.ReadOnlyField(source='owner.username')
# owner_name = serializers.ReadOnlyField(source='owner.username')
owner_name = serializers.SerializerMethodField()
annotations = serializers.SerializerMethodField()
# members = serializers.SerializerMethodField('get_members')
......@@ -53,8 +46,8 @@ class BaseAnObjSerializer(serializers.ModelSerializer):
# attrs = serializers.SerializerMethodField('attrs_as_dict')
# image_url = serializers.Field(source='image.url')
#image_thumb = serializers.Field(source='thumb_url')
#image_thumb = serializers.SerializerMethodField('get_image_thumb')
# image_thumb = serializers.Field(source='thumb_url')
# image_thumb = serializers.SerializerMethodField('get_image_thumb')
class Meta:
model = AnObj
......
......@@ -6,7 +6,6 @@ from rest_framework.routers import DefaultRouter
from rest_framework_nested import routers
from rest_framework import urls as rest_framework_urls
from adim.serializers import SharedAnObjSerializer
from adim.views import AnObjViewSet, SharedAnObjViewSet, AnnotationViewSet, SharedAnnotationViewSet, UserViewSet
......
# coding=utf-8
from __future__ import unicode_literals
import json
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.core.exceptions import PermissionDenied
from django.http.response import HttpResponseForbidden, Http404
from django.conf import settings
from django.http.response import Http404
from django.db.models import Q
from django.shortcuts import get_object_or_404
......@@ -13,12 +10,9 @@ from adim.models import AnObj, AnObjMembership, Annotation
from adim.serializers import AnObjSerializer, SharedAnObjSerializer, AnObjListSerializer, \
AnnotationSerializer, UserSerializer
from adim.permissions import has_anobj_access
from rest_framework import generics, viewsets
from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework.decorators import detail_route, list_route
from rest_framework.views import APIView
from rest_framework.parsers import FileUploadParser
from rest_framework.decorators import detail_route
class AnObjViewSet(viewsets.ModelViewSet):
......@@ -275,5 +269,3 @@ class SharedAnnotationViewSet(viewsets.ReadOnlyModelViewSet):
Q(owner__anobjmembership__anobj=anobj)
)
return Annotation.objects.filter(q).exclude(owner=self.request.user)
......@@ -8,5 +8,4 @@ class UploadImageFileForm(forms.Form):
This form is used to validate the image files submitted
for upload
"""
image_file = forms.ImageField(allow_empty_file=False)
image_file = forms.ImageField(allow_empty_file=False)
......@@ -17,8 +17,7 @@ from django.contrib.auth.models import User
from django.views.decorators.http import require_POST
from django.views.decorators.cache import cache_control
from adim.models import AnObj, AnObjMembership
# from adim.models.annotables import PUBLISHING_MODES
from adim.permissions import check_anobj_permission, get_permission_class, has_anobj_access, SHARING_MODE_NONE
from adim.permissions import get_permission_class, has_anobj_access, SHARING_MODE_NONE
from .forms import UploadImageFileForm
from sendfile import sendfile
......@@ -354,7 +353,7 @@ def suggest_users(request):
if not tokens:
return HttpResponse(content=json.dumps(matching_users), content_type="application/json")
## Search for local users
# -- Search for local users
q = Q()
for token in tokens:
q = q & Q(username__icontains=token)
......@@ -363,7 +362,7 @@ def suggest_users(request):
matching_users.append({'username': user.username, 'id': user.id})
usernames.append(user.username)
## Search for ldap users
# -- Search for ldap users
if len(matching_users) < settings.ADIM_SUGGESTION['LIMIT']:
cache_key = "ldapusers_" + "_".join(tokens)
ldap_users = cache.get(cache_key)
......@@ -399,4 +398,3 @@ def suggest_users(request):
]
return HttpResponse(content=json.dumps(matching_users), content_type="application/json")
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