Gitlab CSE Unil

Commit 57ae707b authored by M. Chardon's avatar M. Chardon
Browse files

migration sur python3

parent fcdc9cad
# coding=utf-8
from annotables import AnObj, AnObjMembership, EnvParam
from annotations import Annotation
from .annotables import AnObj, AnObjMembership, EnvParam
from .annotations import Annotation
__all__ = (
'AnObj', 'AnObjMembership', 'Annotation', 'EnvParam'
......
......@@ -16,7 +16,7 @@ from adim_utils.decorators import cache
__all__ = ('AnObj', 'AnObjMembership', 'EnvParam')
# code from from uuid._random_getnode()
RANDOM_NODE = random.randrange(0, 1 << 48L) | 0x010000000000L
RANDOM_NODE = random.randrange(0, 1 << 48) | 0x010000000000
# Destination path for uploaded images, relative to MEDIA_ROOT
AO_IMAGES_PATH = 'ao_images'
......@@ -138,19 +138,6 @@ class AnObj(models.Model):
"""
return user_id in self.owners.all().values_list('id', flat=True)
# def _create_thumbnail(self):
# if not self.image:
# return
#
# th_path = os.path.splitext(self.image.path)[0] + "__.png"
# if os.path.exists(th_path):
# return th_path
#
# im = Image.open(self.image.path)
# im.thumbnail(settings.ADIM_THUMB_SIZE)
# im.save(th_path)
# return th_path
@property
def thumb_url(self):
if not self._thumb_url:
......
......@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import models
from django.utils.translation import ugettext as _
from django.conf import settings
from annotables import AnObj
from .annotables import AnObj
class Annotation(models.Model):
......@@ -24,11 +24,3 @@ class Annotation(models.Model):
class Meta:
app_label = "adim"
ordering = ('owner__id', '-order', 'modification_date')
# def save(self, *args, **kwargs):
# try:
# item = json.loads(self.item)
# except (TypeError, ValueError):
# item = None
#
# super(Annotation, self).save(*args, **kwargs)
\ No newline at end of file
......@@ -3,8 +3,6 @@ from __future__ import unicode_literals
from django import forms
from django.forms.utils import ErrorDict
from utils.validators import validate_json_file
class UploadImageFileForm(forms.Form):
......@@ -12,7 +10,8 @@ class UploadImageFileForm(forms.Form):
This form is used to validate the image files submitted
for upload
"""
image_file = forms.ImageField(allow_empty_file=False, validators=[validate_json_file])
## TODO find a validator for this image
image_file = forms.ImageField(allow_empty_file=False)
name = forms.CharField(max_length=125, required=False)
sharing_opts = None
allow_public_publishing = None
......
......@@ -139,9 +139,9 @@ module.exports = function (grunt) {
},
{
expand: true,
cwd: "lib/material-design-icons/iconfont",
src: ["**"],
dest: '../fonts/'
cwd: "lib/bootstrap/dist/css",
src: ["bootstrap.min.css.map"],
dest: '../css/'
},
{
expand: true,
......
......@@ -6,7 +6,7 @@ from django.conf import settings
def add_border(img, save=False):
if type(img) == str or type(img) == unicode:
if type(img) == str:
try:
thumb_image = Image.open(img)
thumb_path = img
......
......@@ -29,7 +29,7 @@ def activate_virtualenv(this_file=None, virtualenv_path=None, settings_module=No
if not os.path.isfile(this_file):
raise ValueError("File not found: {}".format(this_file))
execfile(this_file, dict(__file__=this_file))
exec(compile(open(this_file, "rb").read(), this_file, 'exec'), dict(__file__=this_file))
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.append(base_dir)
......
......@@ -23,7 +23,7 @@ def cache(seconds=300):
# from https://djangosnippets.org/snippets/564/raw/
def do_cache(f):
def x(*args, **kwargs):
key = sha1(str(f.__module__) + str(f.__name__) + str(args) + str(kwargs)).hexdigest()
key = sha1((str(f.__module__) + str(f.__name__) + str(args) + str(kwargs)).encode('utf-8')).hexdigest()
result = _djcache.get(key)
if result is None:
result = f(*args, **kwargs)
......@@ -36,7 +36,7 @@ def cache(seconds=300):
def clear_function_cache(f, *args, **kwargs):
f_str = str(f.__module__) + str(f.__name__) if callable(f) else f
try:
key = sha1(f_str + unicode(args) + str(kwargs)).hexdigest()
key = sha1(f_str + str(args) + str(kwargs)).hexdigest()
except UnicodeDecodeError:
key = ""
_djcache.delete(key)
\ No newline at end of file
-r base.txt
django-guardian==1.4.9
Pygments==2.2.0
Werkzeug==0.14.1
django-guardian==1.5.0
Pygments==2.3.1
Werkzeug==0.15.2
django-extensions==2.1.6
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