Gitlab CSE Unil

Commit 10de0c36 authored by M. Chardon's avatar M. Chardon
Browse files

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	adim_project/adim_ttp/utils.py
parents 45945331 7969c422
......@@ -25,9 +25,9 @@ See this <a href="https://gitlabriset.unil.ch/Marion.Chardon/ADIM/wikis/home">wi
## Technologies
The main used technologies are :
- Python 2.7
- Django 1.11
- Jquery 3.3
- Python 3.5
- Django 2.2
- Jquery 3.4
- Bootstrap 4.0
## Installation
......
......@@ -51,17 +51,17 @@ class Command(BaseCommand):
if len(files_to_remove) == 0:
if self.verbosity >= 1:
print "No files to remove."
print("No files to remove.")
sys.exit(0)
if self.verbosity >= 1:
print "List of files to be deleted: "
print "---------------------------"
print "\n".join(f.replace(settings.MEDIA_ROOT, ' .') for f in files_to_remove)
print "\n"
print("List of files to be deleted: ")
print("---------------------------")
print("\n".join(f.replace(settings.MEDIA_ROOT, ' .') for f in files_to_remove))
print("\n")
message = "Continue and delete {} files ? [yes/NO] ".format(len(files_to_remove))
if self.interactive and raw_input(message) != 'yes':
if self.interactive and input(message) != 'yes':
raise CommandError("Removing unused files cancelled.")
if not self.dry_run:
......@@ -70,8 +70,7 @@ class Command(BaseCommand):
os.unlink(f)
except OSError:
if self.verbosity >= 1:
print "# Unable to delete file {}\n -> {}".format(f, sys.exc_info()[1][1])
print("# Unable to delete file {}\n -> {}".format(f, sys.exc_info()[1][1]))
if self.verbosity >= 1:
print "Done."
print("Done.")
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import adim.models.annotables
import jsonfield.fields
from django.conf import settings
import autoslug.fields
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Annotation',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('item', models.TextField(verbose_name='Paper.js item')),
('order', models.IntegerField(default=0, verbose_name='ordre')),
('comment', models.CharField(default='', max_length=512, verbose_name='comment', blank=True)),
('creation_date', models.DateTimeField(auto_now_add=True)),
('modification_date', models.DateTimeField(auto_now=True)),
],
options={
'ordering': ('owner__id', '-order', 'modification_date'),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AnObj',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('uuid', models.CharField(unique=True, max_length=32, blank=True)),
('name', models.CharField(max_length=125)),
('locked', models.BooleanField(default=False, verbose_name='locked')),
('sharing_mode', models.IntegerField(default=0, verbose_name='sharing mode', blank=True)),
('sharing_opts', jsonfield.fields.JSONField(default='{}', verbose_name='sharing options', blank=True)),
('allow_public_publishing', models.BooleanField(default=False, verbose_name='allow public publishing')),
('image', models.ImageField(upload_to=adim.models.annotables.get_image_path, null=True, verbose_name='image', blank=True)),
('image_url', models.CharField(default='', max_length=512, null=True, verbose_name='image url', blank=True)),
('_thumb_url', models.CharField(max_length=512, null=True, blank=True)),
],
options={
'ordering': ['-id'],
'verbose_name': 'Annotable Object',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AnObjMembership',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('publish_mode', models.IntegerField(default=0, choices=[(0, 'private'), (1, 'owner only'), (2, 'all members')])),
('anobj', models.ForeignKey(to='adim.AnObj')),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Annotable Object Membership',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AOAttribute',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('entity_id', models.IntegerField()),
('value_text', models.TextField(null=True, blank=True)),
('value_float', models.FloatField(null=True, blank=True)),
('value_date', models.DateField(null=True, blank=True)),
('value_bool', models.NullBooleanField()),
('value_range_min', models.FloatField(null=True, blank=True)),
('value_range_max', models.FloatField(null=True, blank=True)),
('value_image', models.ImageField(null=True, upload_to='ao', blank=True)),
],
options={
'verbose_name': 'Annotable Object Attribute',
'verbose_name_plural': 'Annotable Object Attributes',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AOChoice',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=100)),
],
options={
'verbose_name': 'Annotable Object Choice',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AOSchema',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(help_text='user-friendly attribute name', max_length=250, verbose_name='title')),
('name', autoslug.fields.AutoSlugField(max_length=250, verbose_name='name', blank=True)),
('help_text', models.CharField(help_text='short description for administrator', max_length=250, verbose_name='help text', blank=True)),
('datatype', models.CharField(max_length=5, verbose_name='data type', choices=[(b'text', 'text'), (b'float', 'number'), (b'date', 'date'), (b'bool', 'boolean'), (b'one', 'choice'), (b'many', 'multiple choices'), (b'range', 'numeric range')])),
('required', models.BooleanField(default=False, verbose_name='required')),
('searched', models.BooleanField(default=False, verbose_name='include in search')),
('filtered', models.BooleanField(default=False, verbose_name='include in filters')),
('sortable', models.BooleanField(default=False, verbose_name='allow sorting')),
],
options={
'verbose_name': 'Annotable Object Schema',
'verbose_name_plural': 'Annotable Object Schemata',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='AOType',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=128)),
('title', models.CharField(default='', max_length=512, blank=True)),
],
options={
'verbose_name': 'Annotable Object Type',
},
bases=(models.Model,),
),
migrations.AddField(
model_name='aoschema',
name='ao_types',
field=models.ManyToManyField(to='adim.AOType', null=True, blank=True),
preserve_default=True,
),
migrations.AddField(
model_name='aochoice',
name='schema',
field=models.ForeignKey(related_name='choices', to='adim.AOSchema'),
preserve_default=True,
),
migrations.AddField(
model_name='aoattribute',
name='choice',
field=models.ForeignKey(blank=True, to='adim.AOChoice', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='aoattribute',
name='entity_type',
field=models.ForeignKey(to='contenttypes.ContentType'),
preserve_default=True,
),
migrations.AddField(
model_name='aoattribute',
name='schema',
field=models.ForeignKey(related_name='attrs', to='adim.AOSchema'),
preserve_default=True,
),
migrations.AddField(
model_name='anobj',
name='ao_type',
field=models.ForeignKey(verbose_name='type', blank=True, to='adim.AOType', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='anobj',
name='members',
field=models.ManyToManyField(related_name='shared_anobjs', to=settings.AUTH_USER_MODEL, through='adim.AnObjMembership', blank=True, null=True, verbose_name='members'),
preserve_default=True,
),
migrations.AddField(
model_name='anobj',
name='owner',
field=models.ForeignKey(related_name='anobjs', verbose_name='owner', to=settings.AUTH_USER_MODEL),
preserve_default=True,
),
migrations.AddField(
model_name='annotation',
name='annotable',
field=models.ForeignKey(related_name='annotations', verbose_name='annotable', to='adim.AnObj'),
preserve_default=True,
),
migrations.AddField(
model_name='annotation',
name='owner',
field=models.ForeignKey(verbose_name='owner', to=settings.AUTH_USER_MODEL),
preserve_default=True,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('adim', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='anobj',
name='ao_type',
),
migrations.AlterField(
model_name='anobj',
name='members',
field=models.ManyToManyField(related_name='shared_anobjs', verbose_name='members', to=settings.AUTH_USER_MODEL, through='adim.AnObjMembership', blank=True),
),
migrations.AlterField(
model_name='aoschema',
name='ao_types',
field=models.ManyToManyField(to='adim.AOType', blank=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('adim', '0002_auto_20150417_1302'),
]
operations = [
migrations.AddField(
model_name='anobj',
name='owners',
field=models.ManyToManyField(related_name='owned_anobjs', verbose_name='owners', to=settings.AUTH_USER_MODEL, blank=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def init_owners(apps, schema_editor):
"""
Initialize new `owners` field by adding the current `owner` to it
:param apps:
:param schema_editor:
:return:
"""
AnObj = apps.get_model("adim", "AnObj")
for anobj in AnObj.objects.all():
if len(anobj.owners.all()) == 0:
anobj.owners.add(anobj.owner)
class Migration(migrations.Migration):
dependencies = [
('adim', '0003_anobj_owners'),
]
operations = [
migrations.RunPython(init_owners),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0004_auto_20150424_1209'),
]
operations = [
migrations.AddField(
model_name='anobj',
name='env',
field=models.CharField(blank=True, max_length=64, choices=[('', 'Standard'), ('cimaf', 'CIMAF')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0005_anobj_env'),
]
operations = [
migrations.CreateModel(
name='EnvParam',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('cimaf_cut_pos', models.IntegerField(null=True, blank=True)),
('cimaf_cut_margin', models.IntegerField(null=True, blank=True)),
('anobj', models.OneToOneField(to='adim.AnObj')),
],
options={
'verbose_name': 'Environment params',
},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0006_envparam'),
]
operations = [
migrations.AddField(
model_name='envparam',
name='categories_set',
field=models.CharField(max_length=64, blank=True),
),
migrations.AlterField(
model_name='anobj',
name='env',
field=models.CharField(blank=True, max_length=64, choices=[('', 'Standard'), ('cimaf', 'CIMAF'), ('playground', 'Pour Voir')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0007_auto_20150714_0815'),
]
operations = [
migrations.RenameField(
model_name='envparam',
old_name='categories_set',
new_name='category_set_name',
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0008_auto_20150714_0817'),
]
operations = [
migrations.AlterModelOptions(
name='envparam',
options={'verbose_name': 'Environment params', 'permissions': (('set_env_cimaf', 'Set CIMAF environment'),)},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0009_auto_20150715_1144'),
]
operations = [
migrations.AlterModelOptions(
name='envparam',
options={'verbose_name': 'Environment params', 'permissions': (('set_env_cimaf', 'Set CIMAF environment'), ('set_env_playground', 'Set PlayGround environment'))},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0010_auto_20150715_1252'),
]
operations = [
migrations.AlterField(
model_name='anobj',
name='env',
field=models.CharField(blank=True, max_length=64, choices=[('', 'Standard'), ('cimaf', 'CIMAF'), ('anodate', 'Datation')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0011_auto_20150716_0911'),
]
operations = [
migrations.AlterModelOptions(
name='envparam',
options={'verbose_name': 'Environment params', 'permissions': (('set_env_cimaf', 'Set CIMAF environment'), ('set_env_anodate', 'Set Anodate environment'))},
),
]
# 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
......@@ -183,13 +183,21 @@ class ATTP(PermissionClass):
uuid=anobj.uuid[:12]
)
status = cache.get(key)
#if status is None: