当前位置: 首页>>代码示例>>Python>>正文


Python settings.AUTH_USER_MODEL属性代码示例

本文整理汇总了Python中django.conf.settings.AUTH_USER_MODEL属性的典型用法代码示例。如果您正苦于以下问题:Python settings.AUTH_USER_MODEL属性的具体用法?Python settings.AUTH_USER_MODEL怎么用?Python settings.AUTH_USER_MODEL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


在下文中一共展示了settings.AUTH_USER_MODEL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def settings(self):
        if self.cached_settings:
            return self.cached_settings
        else:
            from django.conf import settings
            allowed_configurations = {
                'CONTENT_TYPE_CLASS': ContentType,
                'USER_CLASS': settings.AUTH_USER_MODEL,
                'PERMISSION_CLASS': Permission,
                'GROUP_CLASS': Group,
                'INJECT_MODEL_ADMIN': False
            }
            river_settings = {}
            for key, default in allowed_configurations.items():
                river_settings[key] = getattr(settings, self.get_with_prefix(key), default)

            river_settings['IS_MSSQL'] = connection.vendor == 'microsoft'
            self.cached_settings = river_settings

            return self.cached_settings 
开发者ID:javrasya,项目名称:django-river,代码行数:22,代码来源:config.py

示例2: test_check_custom_user_model_default_admin

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def test_check_custom_user_model_default_admin(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), UserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            expected_warnings = [
                Warning(
                    'django-hijack-admin does not work out the box with a custom user model.',
                    hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                    obj=settings.AUTH_USER_MODEL,
                    id='hijack_admin.W001',
                )
            ]
            self.assertEqual(warnings, expected_warnings)

            admin.site.unregister(get_user_model()) 
开发者ID:arteria,项目名称:django-hijack-admin,代码行数:19,代码来源:test_checks.py

示例3: setUp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def setUp(self):
        """
        Set up the following claim senarios
            user1: asks 50
            user2: offers 25
            user3: offers 25
            user1 claims
        """
        self.url = 'http://github.com/codesy/codesy/issues/37'
        self.issue = mommy.make(Issue, url=self.url)

        self.user1 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user1@test.com')
        self.user2 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user2@test.com')
        self.user3 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user3@test.com')
        self.bid1 = mommy.make(Bid, user=self.user1,
                               ask=50, offer=0, url=self.url, issue=self.issue)
        self.bid2 = mommy.make(Bid, user=self.user2,
                               ask=0, offer=25, url=self.url, issue=self.issue)
        self.bid3 = mommy.make(Bid, user=self.user3,
                               ask=0, offer=25, url=self.url, issue=self.issue)
        self.claim = mommy.make(Claim, user=self.user1, issue=self.issue) 
开发者ID:codesy,项目名称:codesy,代码行数:26,代码来源:__init__.py

示例4: test_send_mail_to_matching_askers

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def test_send_mail_to_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        bid1_subject = "[codesy] There's $50 waiting for you!"
        bid2_subject = "[codesy] There's $100 waiting for you!"
        mock_send_mail.expects_call().with_args(
            bid1_subject,
            arg.any(),
            arg.any(),
            ['user1@test.com']
        )
        mock_send_mail.next_call().with_args(
            bid2_subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
开发者ID:codesy,项目名称:codesy,代码行数:23,代码来源:model_tests.py

示例5: test_only_send_mail_to_unsent_matching_askers

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def test_only_send_mail_to_unsent_matching_askers(self, mock_send_mail):
        user = mommy.make(settings.AUTH_USER_MODEL)
        self.bid1.ask_match_sent = timezone.now()
        self.bid1.save()
        subject = "[codesy] There's $100 waiting for you!"

        mock_send_mail.expects_call().with_args(
            subject,
            arg.any(),
            arg.any(),
            ['user2@test.com']
        )

        offer_bid = mommy.make(
            Bid, offer=100, user=user, ask=1000, url=self.url
        )
        offer_bid.save() 
开发者ID:codesy,项目名称:codesy,代码行数:19,代码来源:model_tests.py

示例6: setUp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def setUp(self):
        """
        Add a final bid and a user2 claim to the MarketWithBidsTestCase,
        so the final market for the bug is now:
            url: http://github.com/codesy/codesy/issues/37
            user1: ask 50,  offer 0  (ask is met)
            user2: ask 100, offer 10
            user3: ask 0,   offer 30
            user4: ask 200, offer 10
        And user1 is making the claim
        """
        super(NotifyMatchingOfferersTest, self).setUp()
        self.user4 = mommy.make(settings.AUTH_USER_MODEL,
                                email='user4@test.com')
        self.bid4 = mommy.make(Bid, user=self.user4,
                               ask=200, offer=10, url=self.url)
        self.evidence = ('https://github.com/codesy/codesy/commit/'
                         '4f1bcd014ec735918bebd1c386e2f99a7f83ff64') 
开发者ID:codesy,项目名称:codesy,代码行数:20,代码来源:model_tests.py

示例7: setUp

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def setUp(self):
        self.view = ClaimStatusView()
        self.url = 'http://github.com/codesy/codesy/issues/37'
        self.issue = mommy.make(Issue, url=self.url)
        self.user1 = mommy.make(
            settings.AUTH_USER_MODEL, email='user1@test.com'
        )
        self.bid1 = mommy.make(
            Bid, user=self.user1, url=self.url, issue=self.issue, offer=0
        )
        self.user2 = mommy.make(
            settings.AUTH_USER_MODEL, email='user2@test.com'
        )
        self.bid2 = mommy.make(
            Bid, user=self.user2, url=self.url, issue=self.issue, offer=10
        )
        self.user3 = mommy.make(
            settings.AUTH_USER_MODEL, email='user3@test.com'
        )

        self.claim = mommy.make(Claim, user=self.user1, issue=self.issue) 
开发者ID:codesy,项目名称:codesy,代码行数:23,代码来源:view_tests.py

示例8: match_user

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def match_user(self, user: AUTH_USER_MODEL) -> bool:
        """Return True if the user passes the various user filters."""
        # treat no user (i.e. has not been added) as AnonymousUser()
        user = user or AnonymousUser()

        if self.user_filter_type == RuleSet.USER_FILTER_ALL:
            return True

        if self.user_filter_type == RuleSet.USER_FILTER_AUTH:
            return user.is_authenticated

        if self.user_filter_type == RuleSet.USER_FILTER_GROUP:
            group = self.user_group_filter.strip()
            return user.groups.filter(name__iexact=group).exists()

        # if we're still going, then it's a no. it's also an invalid
        # user_filter_type, so we may want to think about a warning
        return False 
开发者ID:yunojuno,项目名称:django-request-profiler,代码行数:20,代码来源:models.py

示例9: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def __init__(self, real_apps, models, ignore_swappable=False):
        # Any apps in self.real_apps should have all their models included
        # in the render. We don't use the original model instances as there
        # are some variables that refer to the Apps object.
        # FKs/M2Ms from real apps are also not included as they just
        # mess things up with partial states (due to lack of dependencies)
        self.real_models = []
        for app_label in real_apps:
            app = global_apps.get_app_config(app_label)
            for model in app.get_models():
                self.real_models.append(ModelState.from_model(model, exclude_rels=True))
        # Populate the app registry with a stub for each application.
        app_labels = {model_state.app_label for model_state in models.values()}
        app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))]
        super(StateApps, self).__init__(app_configs)

        self.render_multiple(list(models.values()) + self.real_models)

        # There shouldn't be any operations pending at this point.
        pending_models = set(self._pending_operations)
        if ignore_swappable:
            pending_models -= {make_model_tuple(settings.AUTH_USER_MODEL)}
        if pending_models:
            raise ValueError(self._pending_models_error(pending_models)) 
开发者ID:drexly,项目名称:openhgsenti,代码行数:26,代码来源:state.py

示例10: add_default_menu_items

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def add_default_menu_items(self):
        menu_setting = 'OPENWISP_DEFAULT_ADMIN_MENU_ITEMS'
        items = [
            {'model': settings.AUTH_USER_MODEL},
            {'model': get_model_name('openwisp_users', 'Organization')},
        ]
        if not hasattr(settings, menu_setting):
            setattr(settings, menu_setting, items)
        else:
            current_menu = getattr(settings, menu_setting)
            current_menu += items 
开发者ID:openwisp,项目名称:openwisp-users,代码行数:13,代码来源:apps.py

示例11: check_custom_user_model

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def check_custom_user_model(app_configs, **kwargs):
    warnings = []
    if (settings.AUTH_USER_MODEL != DEFAULT_AUTH_USER_MODEL and
            not _using_hijack_admin_mixin()):
        warnings.append(
            Warning(
                'django-hijack-admin does not work out the box with a custom user model.',
                hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                obj=settings.AUTH_USER_MODEL,
                id='hijack_admin.W001',
            )
        )
    return warnings 
开发者ID:arteria,项目名称:django-hijack-admin,代码行数:15,代码来源:checks.py

示例12: __init__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def __init__(self, real_apps, models, ignore_swappable=False):
        # Any apps in self.real_apps should have all their models included
        # in the render. We don't use the original model instances as there
        # are some variables that refer to the Apps object.
        # FKs/M2Ms from real apps are also not included as they just
        # mess things up with partial states (due to lack of dependencies)
        self.real_models = []
        for app_label in real_apps:
            app = global_apps.get_app_config(app_label)
            for model in app.get_models():
                self.real_models.append(ModelState.from_model(model, exclude_rels=True))
        # Populate the app registry with a stub for each application.
        app_labels = {model_state.app_label for model_state in models.values()}
        app_configs = [AppConfigStub(label) for label in sorted(real_apps + list(app_labels))]
        super(StateApps, self).__init__(app_configs)

        self.render_multiple(list(models.values()) + self.real_models)

        # If there are some lookups left, see if we can first resolve them
        # ourselves - sometimes fields are added after class_prepared is sent
        for lookup_model, operations in self._pending_lookups.items():
            try:
                model = self.get_model(lookup_model[0], lookup_model[1])
            except LookupError:
                app_label = "%s.%s" % (lookup_model[0], lookup_model[1])
                if app_label == settings.AUTH_USER_MODEL and ignore_swappable:
                    continue
                # Raise an error with a best-effort helpful message
                # (only for the first issue). Error message should look like:
                # "ValueError: Lookup failed for model referenced by
                # field migrations.Book.author: migrations.Author"
                msg = "Lookup failed for model referenced by field {field}: {model[0]}.{model[1]}"
                raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
            else:
                do_pending_lookups(model) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:37,代码来源:state.py

示例13: get_user_model

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def get_user_model():
    """
    Returns the User model that is active in this project.
    """
    try:
        return django_apps.get_model(settings.AUTH_USER_MODEL)
    except ValueError:
        raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form 'app_label.model_name'")
    except LookupError:
        raise ImproperlyConfigured(
            "AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
        ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:14,代码来源:__init__.py

示例14: skipIfCustomUser

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def skipIfCustomUser(test_func):
    """
    Skip a test if a custom user model is in use.
    """
    return skipIf(settings.AUTH_USER_MODEL != 'auth.User', 'Custom user model in use')(test_func) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:utils.py

示例15: user

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import AUTH_USER_MODEL [as 别名]
def user() -> settings.AUTH_USER_MODEL:
    return UserFactory() 
开发者ID:ecds,项目名称:readux,代码行数:4,代码来源:conftest.py


注:本文中的django.conf.settings.AUTH_USER_MODEL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。