Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Common: Switch from mitx.db to edx.db for sqlite databases. This will effectivel
reset state for local instances of the code, unless you manually rename your
mitx.db file to edx.db.

Common: significant performance improvement for authorization checks and location translations.
Ensure all auth checks, check all possible permutations of the auth key (Instructor dashboard
now shows when it should for all courses in lms).
Made queries for Studio dashboard 2 orders of magnitude faster (and fewer).

Blades: Video Transcripts: Fix clear and download buttons. BLD-438.

Common: Switch over from MITX_FEATURES to just FEATURES. To override items in
Expand Down
14 changes: 5 additions & 9 deletions cms/djangoapps/auth/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_all_course_role_groupnames(location, role, use_filter=True):
# filter to the ones which exist
default = groupnames[0]
if use_filter:
groupnames = [group for group in groupnames if Group.objects.filter(name=group).exists()]
groupnames = [group.name for group in Group.objects.filter(name__in=groupnames)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the syntax for name__in?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field__in = listvalues translates to a sql where field in listvalues Something @cpennington pointed out to me and correctly suggested we use.

return groupnames, default


Expand Down Expand Up @@ -203,12 +203,8 @@ def remove_user_from_course_group(caller, user, location, role):

# see if the user is actually in that role, if not then we don't have to do anything
groupnames, _ = get_all_course_role_groupnames(location, role)
for groupname in groupnames:
groups = user.groups.filter(name=groupname)
if groups:
# will only be one with that name
user.groups.remove(groups[0])
user.save()
user.groups.remove(*user.groups.filter(name__in=groupnames))
user.save()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.groups.remove(*user.groups.filter(name__in=groupnames))?



def remove_user_from_creator_group(caller, user):
Expand Down Expand Up @@ -243,7 +239,7 @@ def is_user_in_course_group_role(user, location, role, check_staff=True):
if check_staff and user.is_staff:
return True
groupnames, _ = get_all_course_role_groupnames(location, role)
return any(user.groups.filter(name=groupname).exists() for groupname in groupnames)
return user.groups.filter(name__in=groupnames).exists()

return False

Expand All @@ -266,7 +262,7 @@ def is_user_in_creator_group(user):

# Feature flag for using the creator group setting. Will be removed once the feature is complete.
if settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
return user.groups.filter(name=COURSE_CREATOR_GROUP_NAME).count() > 0
return user.groups.filter(name=COURSE_CREATOR_GROUP_NAME).exists()

return True

Expand Down
5 changes: 2 additions & 3 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from django.test.utils import override_settings
from django.conf import settings
from django.core.urlresolvers import reverse
from path import path
from tempdir import mkdtemp_clean
from fs.osfs import OSFS
Expand Down Expand Up @@ -427,7 +426,7 @@ def test_static_tab_deletion(self):

course = module_store.get_item(course_location)
num_tabs = len(course.tabs)
last_tab = course.tabs[num_tabs - 1]
last_tab = course.tabs[-1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pythonic last ele mechanism. Not important.

url_slug = last_tab['url_slug']
delete_url = self._get_tab_locator(course, last_tab).url_reverse('xblock')

Expand All @@ -446,7 +445,7 @@ def tab_matches(tab):

def _get_tab_locator(self, course, tab):
""" Returns the locator for a given tab. """
tab_location = 'i4x://MITx/999/static_tab/{0}'.format(tab['url_slug'])
tab_location = 'i4x://edX/999/static_tab/{0}'.format(tab['url_slug'])
return loc_mapper().translate_location(
course.location.course_id, Location(tab_location), False, True
)
Expand Down
3 changes: 2 additions & 1 deletion cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def course_listing(request):
"""
List all courses available to the logged in user
"""
courses = modulestore('direct').get_items(Location('i4x', None, None, 'course', None))
# there's an index on category which will be used if none of its antecedents are set
courses = modulestore('direct').get_items(Location(None, None, None, 'course', None))

# filter out courses that we don't have access too
def course_filter(course):
Expand Down
7 changes: 6 additions & 1 deletion cms/envs/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@
'LOCATION': '/var/tmp/mongo_metadata_inheritance',
'TIMEOUT': 300,
'KEY_FUNCTION': 'util.memcache.safe_key',
}
},
'loc_cache': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'edx_location_mem_cache',
},

}

# Make the keyedcache startup warnings go away
Expand Down
7 changes: 6 additions & 1 deletion cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@
'LOCATION': '/var/tmp/mongo_metadata_inheritance',
'TIMEOUT': 300,
'KEY_FUNCTION': 'util.memcache.safe_key',
}
},
'loc_cache': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'edx_location_mem_cache',
},

}

# hide ratelimit warnings while running tests
Expand Down
6 changes: 5 additions & 1 deletion common/lib/xmodule/xmodule/modulestore/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ def loc_mapper():
global _loc_singleton
# pylint: disable=W0212
if _loc_singleton is None:
try:
loc_cache = get_cache('loc_cache')
except InvalidCacheBackendError:
loc_cache = get_cache('default')
# instantiate
_loc_singleton = LocMapperStore(**settings.DOC_STORE_CONFIG)
_loc_singleton = LocMapperStore(loc_cache, **settings.DOC_STORE_CONFIG)
# inject into split mongo modulestore
if 'split' in _MODULESTORES:
_MODULESTORES['split'].loc_mapper = _loc_singleton
Expand Down
Loading