From 6296be870bd260c3fb733c02ddbf4041bd2f2b6b Mon Sep 17 00:00:00 2001 From: j Date: Sun, 29 Jul 2018 21:12:56 +0100 Subject: [PATCH] use get_user_model --- pandora/annotation/management/commands/import_srt.py | 7 +++++-- pandora/annotation/models.py | 4 +++- pandora/annotation/tasks.py | 8 +++++--- pandora/app/config.py | 3 ++- pandora/app/monkey_patch.py | 6 +++++- pandora/archive/models.py | 4 +++- pandora/changelog/models.py | 4 +++- pandora/document/models.py | 5 ++++- pandora/documentcollection/models.py | 5 ++++- pandora/edit/models.py | 7 ++++++- pandora/entity/models.py | 4 +++- pandora/event/models.py | 4 +++- pandora/item/models.py | 5 ++++- pandora/itemlist/models.py | 4 +++- pandora/log/models.py | 6 +++++- pandora/place/models.py | 4 +++- pandora/taskqueue/models.py | 3 ++- pandora/text/models.py | 3 ++- pandora/user/models.py | 4 +++- pandora/user/views.py | 4 +++- 20 files changed, 71 insertions(+), 23 deletions(-) diff --git a/pandora/annotation/management/commands/import_srt.py b/pandora/annotation/management/commands/import_srt.py index cb647fdc2..7eeecc14d 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 53f162a8e..1327f3bdb 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 180198d34..88087b0f2 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 f559aabf8..e7b398841 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 080659730..8c2bead5a 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 4c7565087..0e0d5c84f 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 31b955a2a..bad1a858f 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 c5b75fada..fdf58874d 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 7a41e5d39..774ac8f75 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 75a6987a3..39c4fc195 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 b094e9bfe..80ab9b5e7 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 01ac66dc4..1e9925570 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 7b901e5c6..effd64f0e 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 452aac253..9af7fc4b1 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 e730947da..a4cde6c04 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 f8cf38404..318a3d159 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 ea85fcc28..839aff396 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 d2451a199..fc9e72913 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 44cd0fde4..683295c9c 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 89edcdcf7..406d24f59 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: