Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #877 from mitodl/hotfix/0.15.1
Browse files Browse the repository at this point in the history
hotfix/0.15.1
  • Loading branch information
pdpinch committed Jan 26, 2016
2 parents 9ec8ee5 + 2fadcad commit 51670ee
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 73 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ WORKDIR /tmp
COPY apt.txt /tmp/apt.txt
RUN apt-get update &&\
apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ") &&\
ln -s /usr/bin/nodejs /usr/bin/node &&\
pip install pip --upgrade
ln -s /usr/bin/nodejs /usr/bin/node

# Install pip
RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py > get-pip.py &&\
python3 get-pip.py &&\
python get-pip.py

# Add non-root user.
RUN adduser --disabled-password --gecos "" mitodl
Expand Down
12 changes: 12 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Release Notes
-------------

Version 0.15.1
==============

- Version locked ``doc_requirements`` packages.

Version 0.15.0
==============

- Added sorting by relevance ``(_score)``.
- Fixed requests installation.
- Fixed new pylint 1.5.0 violations.

Version 0.14.1
==============

Expand Down
3 changes: 1 addition & 2 deletions apt.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Core requirements

curl
git
libpq-dev
python-pip
python3-pip
python-dev
python3-dev
npm
Expand Down
6 changes: 3 additions & 3 deletions doc_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r requirements.txt
sphinx>=1.3.1
sphinx_bootstrap_theme>=0.4.5
sphinxcontrib-napoleon>=0.3.5
sphinx==1.3.1
sphinx_bootstrap_theme==0.4.5
sphinxcontrib-napoleon==0.3.5
6 changes: 2 additions & 4 deletions exporter/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
from learningresources.api import (
update_description_path,
create_static_asset,
create_resource,
create_course,
)
from exporter.api import (
export_resources_to_directory,
export_resources_to_tarball,
)
from exporter.tasks import export_resources
from learningresources.api import (
create_resource,
create_course,
)
from importer.tasks import import_file


Expand Down
5 changes: 3 additions & 2 deletions importer/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

from __future__ import unicode_literals

from bs4 import BeautifulSoup
from shutil import rmtree
import logging
from tempfile import mkdtemp
from os.path import join, exists
from os import listdir

from bs4 import BeautifulSoup

from archive import Archive, ArchiveException
from django.core.files.storage import default_storage
from django.db import transaction
Expand Down Expand Up @@ -194,7 +195,7 @@ def import_children(course, element, parent, parent_dpath):
# temp variable to store static assets for bulk insert
static_assets_to_save = set()
target = "/static/"
if element.tag == "video":
if element.tag == "video": # pylint: disable=too-many-nested-blocks
subname = get_video_sub(element)
if subname != "":
assets = StaticAsset.objects.filter(
Expand Down
2 changes: 1 addition & 1 deletion importer/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mock
from lxml import etree

from xbundle import XBundle
from importer.api import (
import_course_from_file,
import_course_from_path,
Expand All @@ -33,7 +34,6 @@
)
from learningresources.tests.base import LoreTestCase
from lore import settings
from xbundle import XBundle

log = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions learningresources/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from __future__ import unicode_literals

import logging
import tempfile

from django.core.files import File
from django.core.files.storage import default_storage
from django.core.management import call_command
from django.db.utils import IntegrityError
import tempfile

from mock import patch

from importer.api import import_course_from_file
from learningresources import api
Expand All @@ -19,7 +21,6 @@
LearningResource,
static_asset_basepath,
)
from mock import patch
from .base import LoreTestCase

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion learningresources/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_unicode(self):
name="first"
)

self.assertEquals("first", str(first))
self.assertEqual("first", str(first))

def test_repo_slug(self):
"""Test behavior saving a repository slug"""
Expand Down
2 changes: 1 addition & 1 deletion learningresources/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_sub_language(self):
("de", "de_subs_CCxmtcICYNc.srt.sjson"),
)
for lang, sub in values:
self.assertEquals(sub, _subs_filename("CCxmtcICYNc", lang))
self.assertEqual(sub, _subs_filename("CCxmtcICYNc", lang))

def test_get_sub_name(self):
"""Test getting subtitle names."""
Expand Down
4 changes: 2 additions & 2 deletions lore/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.core.exceptions import ImproperlyConfigured
import yaml

VERSION = '0.14.1'
VERSION = '0.15.1'

CONFIG_PATHS = [
os.environ.get('LORE_CONFIG', ''),
Expand Down Expand Up @@ -415,5 +415,5 @@ def get_var(name, default):
GOOGLE_ANALYTICS_ID = get_var('LORE_GOOGLE_ANALYTICS_ID', None)

# This is needed to connect the signals properly.
# pylint: disable=unused-import
# pylint: disable=unused-import,wrong-import-position
import search.signals # noqa
1 change: 1 addition & 0 deletions rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,4 @@ class RepositorySearchSerializer(Serializer):
description = CharField()
description_path = CharField()
preview_url = CharField()
score = FloatField()
39 changes: 28 additions & 11 deletions rest/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from search.utils import recreate_index
from taxonomy.models import Term, Vocabulary, make_vocab_key

# pylint: disable=too-many-statements


class TestSearch(RESTTestCase):
"""
Expand All @@ -29,6 +31,9 @@ class TestSearch(RESTTestCase):
def assert_result_equal(self, result, resource):
"""Helper method to assert result == resource."""

# remove the score from the result because
# it is meaningless for the tests
del result['score']
self.assertEqual(
{
'course': resource.course.course_number,
Expand Down Expand Up @@ -166,30 +171,42 @@ def test_sortby(self):
resource1.xa_avg_grade = 2.0
resource1.xa_nr_attempts = 4
resource1.xa_nr_views = 1000
resource1.title = '22222'
resource1.title = '22222 aaaa bbbb'
resource1.save()

resource2.xa_avg_grade = 4.0
resource2.xa_nr_attempts = 1
resource2.xa_nr_views = 100
resource2.title = '11111'
resource2.title = '11111 aaaa'
resource2.save()

resource3.xa_avg_grade = 2.0
resource3.xa_nr_attempts = 4
resource3.xa_nr_views = 1000
resource3.title = '00000'
resource3.title = '00000 bbbb'
resource3.save()

# Default sorting should be by nr_views, descending, then id ascending.
# Default sorting should be by relevance and score
# is null without an actual search
default_results = self.get_results()['results']
self.assertEqual(default_results[0]['id'], resource1.id)
self.assertEqual(default_results[1]['id'], resource3.id)
self.assertEqual(default_results[2]['id'], resource2.id)

nr_views_results = self.get_results(
sortby=LoreSortingFields.SORT_BY_NR_VIEWS[0])['results']
self.assertEqual(default_results, nr_views_results)
for default_result in default_results:
self.assertIsNone(default_result['score'])

# same thing if the sort by relevance is specified
relevance_results = self.get_results(
sortby=LoreSortingFields.SORT_BY_RELEVANCE[0])['results']
for relevance_result in relevance_results:
self.assertIsNone(relevance_result['score'])

# make a specific search
relevance_results = self.get_results('aaaa')['results']
for relevance_result in relevance_results:
self.assertIsNotNone(relevance_result['score'])
self.assertEqual(len(relevance_results), 2)
self.assertGreaterEqual(
relevance_results[0]['score'],
relevance_results[1]['score']
)

avg_grade_results = self.get_results(
sortby=LoreSortingFields.SORT_BY_AVG_GRADE[0])['results']
Expand Down
11 changes: 6 additions & 5 deletions rest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
from rest_framework.viewsets import GenericViewSet
from statsd.defaults.django import statsd

from learningresources.api import (
PermissionDenied,
NotFound,
)
from roles.permissions import GroupTypes, BaseGroupTypes
from roles.api import (
assign_user_to_repo_group,
Expand Down Expand Up @@ -77,6 +73,11 @@
from search.api import construct_queryset
from search.tasks import index_resources
from taxonomy.models import Vocabulary

from learningresources.api import (
PermissionDenied,
NotFound,
)
from learningresources.models import (
Repository,
Course,
Expand Down Expand Up @@ -654,7 +655,7 @@ def get_queryset(self):
exports = []
return [{"id": lr_id} for lr_id in exports]

def create(self, request, *args, **kwargs):
def create(self, request, *args, **kwargs): # noqa pylint: disable=unused-argument
try:
lr_id = int(request.data['id'])
except ValueError:
Expand Down
4 changes: 2 additions & 2 deletions roles/tests/test_user_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class FooObject(object):
def __init__(self, foo_var):
self.foo_var = foo_var

user_group2 = FooObject('bar')
self.assertFalse(user_group1.__eq__(user_group2))
foo_object = FooObject('bar')
self.assertFalse(user_group1.__eq__(foo_object))

def test_user_group_hash(self):
"""Test for UserGroup __hash__"""
Expand Down
6 changes: 4 additions & 2 deletions search/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class LoreSortingFields(object):
SORT_BY_NR_ATTEMPTS = ('nr_attempts', 'Number of Attempts (desc)', '-')
SORT_BY_AVG_GRADE = ('avg_grade', 'Average Grade (desc)', '-')
SORT_BY_TITLE = ('titlesort', 'Title (asc)', '')
SORT_BY_RELEVANCE = ('_score', 'Relevance', '')

DEFAULT_SORTING_FIELD = SORT_BY_NR_VIEWS[0]
DEFAULT_SORTING_FIELD = SORT_BY_RELEVANCE[0]

# base sorting field in case the applied sorting is working on equal values
BASE_SORTING_FIELD = 'id'
Expand All @@ -29,7 +30,8 @@ def all_sorting_options(cls):
cls.SORT_BY_NR_VIEWS,
cls.SORT_BY_NR_ATTEMPTS,
cls.SORT_BY_AVG_GRADE,
cls.SORT_BY_TITLE
cls.SORT_BY_TITLE,
cls.SORT_BY_RELEVANCE,
]

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion search/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from __future__ import unicode_literals

from lore.celery import async
from statsd.defaults.django import statsd
from lore.celery import async


@async.task
Expand Down
Loading

0 comments on commit 51670ee

Please sign in to comment.