diff --git a/pandora/annotation/management/commands/import_srt.py b/pandora/annotation/management/commands/import_srt.py index cb647fdc..7eeecc14 100644 --- a/pandora/annotation/management/commands/import_srt.py +++ b/pandora/annotation/management/commands/import_srt.py @@ -1,19 +1,22 @@ # -*- coding: utf-8 -*- from __future__ import print_function +from django.conf import settings +from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand from django.db import transaction -from django.conf import settings import ox import app.monkey_patch from item.models import Item -from user.models import User from ... import models +User = get_user_model() + + class Command(BaseCommand): """ import annotations diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 53f162a8..1327f3bd 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -7,7 +7,7 @@ import unicodedata from django.utils.encoding import python_2_unicode_compatible from django.db import models, transaction from django.db.models import Q -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.conf import settings from django.db.models.signals import pre_delete @@ -20,6 +20,8 @@ from item.utils import sort_string, get_by_key from . import managers from . import utils +User = get_user_model() + def get_super_matches(obj, model): super_matches = [] name_lower = obj.name.lower() diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index 180198d3..88087b0f 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import division, print_function, absolute_import -import ox - from django.conf import settings +from django.contrib.auth import get_user_model from django.db import transaction + +import ox from celery.task import task from .models import Annotation @@ -14,7 +15,8 @@ from .models import Annotation def add_annotations(data): from item.models import Item from entity.models import Entity - from user.models import User + User = get_user_model() + item = Item.objects.get(public_id=data['item']) layer_id = data['layer'] layer = list(filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])) diff --git a/pandora/app/config.py b/pandora/app/config.py index f559aabf..e7b39884 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -12,7 +12,7 @@ from glob import glob from six.moves import _thread as thread from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model import ox.jsonc from ox.utils import json @@ -20,6 +20,7 @@ from ox.utils import json from archive.extract import supported_formats from item.utils import get_by_id +User = get_user_model() _win = (sys.platform == "win32") diff --git a/pandora/app/monkey_patch.py b/pandora/app/monkey_patch.py index 08065973..8c2bead5 100644 --- a/pandora/app/monkey_patch.py +++ b/pandora/app/monkey_patch.py @@ -1,9 +1,13 @@ # -*- coding: utf-8 -*- from __future__ import division, print_function, absolute_import -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model + from django.core.validators import MaxLengthValidator +User = get_user_model() + # load config from json from . import config config.init() diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 4c756508..0e0d5c84 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -9,7 +9,7 @@ import time from six import string_types, PY2 from django.conf import settings -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.db import models from django.db.models.signals import pre_delete from django.utils.encoding import python_2_unicode_compatible @@ -28,6 +28,8 @@ from .chunk import save_chunk from . import extract from . import managers +User = get_user_model() + if not PY2: unicode = str diff --git a/pandora/changelog/models.py b/pandora/changelog/models.py index 31b955a2..bad1a858 100644 --- a/pandora/changelog/models.py +++ b/pandora/changelog/models.py @@ -3,7 +3,7 @@ from __future__ import division, print_function, absolute_import from datetime import datetime -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.db import models from django.utils.encoding import python_2_unicode_compatible from oxdjango.fields import JSONField @@ -14,6 +14,8 @@ import websocket from . import managers +User = get_user_model() + ''' FIXME: remove this table more migrate to new ChangeLog ''' diff --git a/pandora/document/models.py b/pandora/document/models.py index c5b75fad..fdf58874 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -10,7 +10,8 @@ from six import PY2, string_types from six.moves.urllib.parse import quote, unquote from django.db import models, transaction from django.db.models import Q, Sum, Max -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from django.db.models.signals import pre_delete from django.conf import settings from django.utils.encoding import python_2_unicode_compatible @@ -30,6 +31,8 @@ from archive.chunk import save_chunk from . import managers from . import utils +User = get_user_model() + if not PY2: unicode = str diff --git a/pandora/documentcollection/models.py b/pandora/documentcollection/models.py index 7a41e5d3..774ac8f7 100644 --- a/pandora/documentcollection/models.py +++ b/pandora/documentcollection/models.py @@ -8,7 +8,8 @@ from glob import glob from django.db import models from django.db.models import Max -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from django.conf import settings from django.utils.encoding import python_2_unicode_compatible from oxdjango.fields import JSONField @@ -20,6 +21,8 @@ from user.utils import update_groups from . import managers +User = get_user_model() + def get_path(f, x): return f.path(x) diff --git a/pandora/edit/models.py b/pandora/edit/models.py index 75a6987a..39c4fc19 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -13,7 +13,9 @@ import ox from django.conf import settings from django.db import models, transaction from django.db.models import Max -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model + from django.utils.encoding import python_2_unicode_compatible from oxdjango.fields import JSONField @@ -27,6 +29,9 @@ from user.utils import update_groups from . import managers + +User = get_user_model() + def get_path(f, x): return f.path(x) def get_icon_path(f, x): return get_path(f, 'icon.jpg') diff --git a/pandora/entity/models.py b/pandora/entity/models.py index b094e9bf..80ab9b5e 100644 --- a/pandora/entity/models.py +++ b/pandora/entity/models.py @@ -10,7 +10,8 @@ from six import string_types from six.moves.urllib.parse import quote, unquote from django.db import models, transaction from django.db.models import Max -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model + from django.db.models.signals import pre_delete, post_init from django.conf import settings from django.utils.encoding import python_2_unicode_compatible @@ -25,6 +26,7 @@ from document.models import Document from . import managers +User = get_user_model() @python_2_unicode_compatible class Entity(models.Model): diff --git a/pandora/event/models.py b/pandora/event/models.py index 01ac66dc..1e992557 100644 --- a/pandora/event/models.py +++ b/pandora/event/models.py @@ -2,7 +2,8 @@ from __future__ import division, print_function, absolute_import from django.db import models, transaction -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model + from django.utils.encoding import python_2_unicode_compatible import ox @@ -16,6 +17,7 @@ from title.models import get_title_sort from . import managers +User = get_user_model() @python_2_unicode_compatible class Event(models.Model): diff --git a/pandora/item/models.py b/pandora/item/models.py index 7b901e5c..effd64f0 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -17,7 +17,9 @@ from six.moves.urllib.parse import quote from django.db import models, transaction, connection from django.db.models import Q, Sum, Max from django.conf import settings -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model + from django.db.models.signals import pre_delete from django.utils import datetime_safe from django.utils.encoding import python_2_unicode_compatible @@ -43,6 +45,7 @@ from title.models import get_title_sort from user.utils import update_groups import archive.models +User = get_user_model() if not PY2: unicode = str diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index 452aac25..9af7fc4b 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -8,7 +8,8 @@ from glob import glob from django.db import models from django.db.models import Max -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from django.conf import settings from django.utils.encoding import python_2_unicode_compatible from oxdjango.fields import JSONField @@ -20,6 +21,7 @@ from user.utils import update_groups from . import managers +User = get_user_model() def get_path(f, x): return f.path(x) def get_icon_path(f, x): return get_path(f, 'icon.jpg') diff --git a/pandora/log/models.py b/pandora/log/models.py index e730947d..a4cde6c0 100644 --- a/pandora/log/models.py +++ b/pandora/log/models.py @@ -2,12 +2,16 @@ from __future__ import division, print_function, absolute_import from django.db import models -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.utils.encoding import python_2_unicode_compatible + import ox from . import managers +User = get_user_model() + + @python_2_unicode_compatible class Log(models.Model): created = models.DateTimeField(auto_now_add=True, db_index=True) diff --git a/pandora/place/models.py b/pandora/place/models.py index f8cf3840..318a3d15 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -2,7 +2,8 @@ from __future__ import division, print_function, absolute_import from django.db import models, transaction -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model + from django.utils.encoding import python_2_unicode_compatible import ox from oxdjango import fields @@ -12,6 +13,7 @@ from item.models import Item from . import managers +User = get_user_model() @python_2_unicode_compatible class Place(models.Model): diff --git a/pandora/taskqueue/models.py b/pandora/taskqueue/models.py index ea85fcc2..839aff39 100644 --- a/pandora/taskqueue/models.py +++ b/pandora/taskqueue/models.py @@ -6,7 +6,7 @@ from time import time from celery.backends import default_backend from celery.utils import get_full_cls_name -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.conf import settings from django.db import models from django.db.models import Q @@ -15,6 +15,7 @@ import celery.task.control import kombu.five import ox +User = get_user_model() def get_tasks(username): from item.models import Item diff --git a/pandora/text/models.py b/pandora/text/models.py index d2451a19..fc9e7291 100644 --- a/pandora/text/models.py +++ b/pandora/text/models.py @@ -9,7 +9,7 @@ from glob import glob from six.moves.urllib.parse import quote from django.db import models from django.db.models import Max -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.conf import settings from django.db.models.signals import pre_delete from django.utils.encoding import python_2_unicode_compatible @@ -21,6 +21,7 @@ from archive.chunk import save_chunk from . import managers +User = get_user_model() def get_path(i, x): return i.path(x) def get_icon_path(i, x): return get_path(i, 'icon.jpg') diff --git a/pandora/user/models.py b/pandora/user/models.py index 44cd0fde..683295c9 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -4,7 +4,8 @@ from __future__ import division, print_function, absolute_import import copy from datetime import datetime -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from django.db import models from django.db.models import Max from django.conf import settings @@ -23,6 +24,7 @@ from . import managers from . import tasks from .utils import get_ip, get_location +User = get_user_model() @python_2_unicode_compatible class SessionData(models.Model): diff --git a/pandora/user/views.py b/pandora/user/views.py index 89edcdcf..406d24f5 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -13,7 +13,8 @@ from django.core.mail import send_mail, BadHeaderError, EmailMessage from django.shortcuts import redirect from django.db import transaction from django.db.models import Max -from django.contrib.auth.models import User, Group +from django.contrib.auth.models import Group +from django.contrib.auth import get_user_model from django.contrib.sessions.models import Session from oxdjango.shortcuts import render_to_json_response, json_response, get_object_or_404_json @@ -30,6 +31,7 @@ from . import models from .decorators import capability_required_json from .utils import rename_user +User = get_user_model() def get_user_or_404(data): if 'id' in data: