Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-basetheme-bootstrap
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bryan BRANCOTTE
django-basetheme-bootstrap
Commits
437e01c3
You need to sign in or sign up before continuing.
Commit
437e01c3
authored
6 years ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
BUGFIX when asking for Anonymous user preferences
parent
12010c45
No related branches found
No related tags found
No related merge requests found
Pipeline
#11964
passed
6 years ago
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
basetheme_bootstrap/tests.py
+5
-0
5 additions, 0 deletions
basetheme_bootstrap/tests.py
basetheme_bootstrap/user_preferences.py
+2
-0
2 additions, 0 deletions
basetheme_bootstrap/user_preferences.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
8 additions
and
1 deletion
basetheme_bootstrap/tests.py
+
5
−
0
View file @
437e01c3
...
...
@@ -2,12 +2,14 @@ import os
from
django.conf
import
settings
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
AnonymousUser
from
django.core.cache
import
cache
from
django.core.exceptions
import
ValidationError
from
django.test
import
TestCase
,
RequestFactory
,
override_settings
from
django.urls
import
reverse
from
basetheme_bootstrap
import
user_preferences
from
basetheme_bootstrap.user_preferences
import
get_user_preferences_for_user
class
AboutPageTests
(
TestCase
):
...
...
@@ -337,6 +339,9 @@ class UserPreferencesTests(TestCase):
pref
.
user
=
None
self
.
assertRaises
(
ValidationError
,
pref
.
save
)
def
test_AnonymousUser_do_not_crash
(
self
):
get_user_preferences_for_user
(
AnonymousUser
())
def
test_caching_disabled_status_when_it_is_the_case
(
self
):
user_preferences
.
get_user_preference_class
()
self
.
assertTrue
(
...
...
This diff is collapsed.
Click to expand it.
basetheme_bootstrap/user_preferences.py
+
2
−
0
View file @
437e01c3
...
...
@@ -55,6 +55,8 @@ class UserPreferencesAbstractModel(models.Model):
def
get_for_user
(
cls
,
user
):
try
:
pref
=
cls
.
objects
.
get
(
user
=
user
)
except
TypeError
:
return
cls
.
get_for_user
(
None
)
except
cls
.
DoesNotExist
:
pref
,
_
=
cls
.
objects
.
get_or_create
(
user
=
None
)
if
user
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
437e01c3
...
...
@@ -7,7 +7,7 @@ readme = open('README.rst').read()
setup
(
name
=
'
django-basetheme-bootstrap
'
,
version
=
'
0.1.
1
'
,
version
=
'
0.1.
2
'
,
description
=
'
Django Basetheme Bootstrap
'
,
long_description
=
readme
,
author
=
'
Bryan Brancotte
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment