Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3bcd5ceb
Commit
3bcd5ceb
authored
Apr 15, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push `has` down into FieldDataCache from DjangoKeyValueStore
parent
9338b6a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
lms/djangoapps/courseware/model_data.py
+21
-7
No files found.
lms/djangoapps/courseware/model_data.py
View file @
3bcd5ceb
...
...
@@ -165,14 +165,8 @@ class DjangoKeyValueStore(KeyValueStore):
if
key
.
scope
not
in
self
.
_allowed_scopes
:
raise
InvalidScopeError
(
key
)
field_object
=
self
.
_field_data_cache
.
find
(
key
)
if
field_object
is
None
:
return
False
return
self
.
_field_data_cache
.
has
(
key
)
if
key
.
scope
==
Scope
.
user_state
:
return
key
.
field_name
in
json
.
loads
(
field_object
.
state
)
else
:
return
True
new_contract
(
"DjangoKeyValueStore"
,
DjangoKeyValueStore
)
new_contract
(
"DjangoKeyValueStore_Key"
,
DjangoKeyValueStore
.
Key
)
...
...
@@ -663,6 +657,26 @@ class FieldDataCache(object):
else
:
field_object
.
delete
()
@contract
(
key
=
DjangoKeyValueStore
.
Key
,
returns
=
bool
)
def
has
(
self
,
key
):
"""
Return whether the specified `key` is set.
Arguments:
key (`DjangoKeyValueStore.Key`): The field value to delete
Returns: bool
"""
field_object
=
self
.
find
(
key
)
if
field_object
is
None
:
return
False
if
key
.
scope
==
Scope
.
user_state
:
return
key
.
field_name
in
json
.
loads
(
field_object
.
state
)
else
:
return
True
def
find
(
self
,
key
):
'''
Look for a model data object using an DjangoKeyValueStore.Key object
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment