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

Commit

Permalink
Merge branch 'rc/0.3.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
carsongee committed Jul 2, 2015
2 parents 49d81d5 + f6659e1 commit 7ec08ad
Show file tree
Hide file tree
Showing 44 changed files with 14,663 additions and 358 deletions.
4 changes: 3 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"preset": "google"
"preset": "google",
"validateQuoteMarks": null,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties"
}
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ ADD . /src
WORKDIR /src
RUN chown -R mitodl:mitodl /src

# Install node packages and add to PATH
# Link nodejs to node since npm expects node
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN npm install -g --prefix /node
ENV PATH /node/lib/node_modules/lore/node_modules/.bin:$PATH

# Install development packages globally for things like
# bower.
RUN mkdir /node
ADD package.json /node/package.json
RUN cd /node && npm install

# Install productions deps for runtime items like jsx
RUN npm install --production
ENV PATH /src/node_modules/.bin:/node/node_modules/.bin:$PATH

# Set pip cache folder, as it is breaking pip when it is on a shared volume
ENV XDG_CACHE_HOME /tmp/.cache
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LORE
:target: https://coveralls.io/r/mitodl/lore
.. image:: https://img.shields.io/github/issues/mitodl/lore.svg
:target: https://github.com/mitodl/lore/issues
.. image:: https://img.shields.io/requires/github/mitodl/lore.svg
:target: https://requires.io/github/mitodl/lore/requirements
.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg
:target: https://github.com/mitodl/lore/blob/master/LICENSE

Expand Down
16 changes: 16 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Release Notes
-------------

Version 0.3.0
=============

- Added UI to add and remove repository members.
- Added form for adding new vocabularies.
- Added manage taxonomies panel and button
- REST for repo members
- Implemented taxonomy model delete cascading.
- Renamed "Copy to Clipboard" to "Select XML"
- Setup JSX processing requirements.
- Fixed mis-resolutioned learning resource type icons.
- Converted several large HTML blocks into include files.
- Switched from using main.js for everything to multiple modules.
- Installed lodash.
- Added CSRF jQuery initialization code.

Version 0.2.0
=============

Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ web:
build: .
command: >
/bin/bash -c '
sleep 5;
sleep 3;
npm install --production;
python manage.py migrate;
python manage.py runserver 0.0.0.0:$PORT'
volumes:
Expand Down Expand Up @@ -40,7 +41,7 @@ celery:
image: lore_web
command: >
/bin/bash -c '
sleep 5;
sleep 3;
celery -A lore worker -l debug'
volumes_from:
- web
Expand Down
25 changes: 19 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ module.exports = function(config) {

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['requirejs', 'qunit'],
// phantom-js doesn't support function.bind in 1.x so we need the shim
frameworks: ['phantomjs-shim', 'requirejs', 'qunit'],

// list of files / patterns to load in the browser
files: [
'ui/jstests/test-main.js',
'ui/jstests/test-listing.js',
{
pattern: 'ui/static/ui/js/**/*.js',
pattern: 'ui/static/bower/react/react.js',
included: false
},
{
pattern: 'ui/jstests/**/*.js',
pattern: 'ui/static/ui/js/**/*.js*',
included: false
},
{
pattern: 'ui/jstests/**/*.js*',
included: false
}
],
Expand All @@ -31,8 +36,16 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'ui/static/ui/js/**/*.js': ['coverage'],
'ui/jstests/**/*.js': ['coverage']
'**/*.jsx': ['react'],
'ui/static/ui/js/**/*.js*': ['coverage'],
'ui/jstests/**/*.js*': ['coverage']
},

reactPreprocessor: {
transformPath: function(path) {
// need to override this since the default behavior is jsx -> js
return path;
}
},

// test results reporter to use
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations

# pylint: skip-file

class Migration(migrations.Migration):

dependencies = [
('learningresources', '0007_remove_old_date_fields'),
]

operations = [
migrations.RemoveField(
model_name='staticasset',
name='learning_resources',
),
]
1 change: 0 additions & 1 deletion learningresources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class StaticAsset(BaseModel):
Holds static assets for a course (css, html, javascript, images, etc)
"""
course = models.ForeignKey(Course)
learning_resources = models.ManyToManyField('LearningResource', blank=True)
asset = models.FileField(upload_to=static_asset_basepath)


Expand Down
3 changes: 2 additions & 1 deletion 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.2.0'
VERSION = '0.3.0'

CONFIG_PATHS = [
os.environ.get('LORE_CONFIG', ''),
Expand Down Expand Up @@ -189,6 +189,7 @@ def get_var(name, default):
)
COMPRESS_PRECOMPILERS = (
('text/requirejs', 'requirejs.RequireJSCompiler'),
('text/jsx', 'node_modules/.bin/jsx < {infile} > {outfile}')
)

# Media and storage settings
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
"name": "lore",
"version": "0.0.0",
"dependencies": {
"bower": "1.4.1"
"react-tools": "~0.13.3"
},
"devDependencies": {
"bower": "1.4.1",
"coveralls": "~2.11.2",
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"karma": "^0.12.36",
"karma-cli": "0.0.4",
"karma-coverage": "^0.4.2",
"karma-phantomjs-launcher": "^0.2.0",
"karma-phantomjs-shim": "~1.0.0",
"karma-qunit": "^0.1.4",
"karma-react-preprocessor": "0.0.4",
"karma-requirejs": "^0.2.2",
"phantomjs": "^1.9.17",
"qunit": "^0.7.6",
"qunitjs": "^1.18.0",
"requirejs": "^2.1.18",
"coveralls": "~2.11.2"
"requirejs": "^2.1.18"
}
}
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ generated-members =
status_code

[MESSAGES CONTROL]
disable = no-member, old-style-class, no-init, too-few-public-methods
disable = no-member, old-style-class, no-init, too-few-public-methods, abstract-method
22 changes: 19 additions & 3 deletions rest/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@

from __future__ import unicode_literals

from django.http import Http404
from guardian.shortcuts import get_perms
from rest_framework.permissions import (
BasePermission,
SAFE_METHODS,
)
from django.http import Http404
from guardian.shortcuts import get_perms

from learningresources.models import Repository
from learningresources.api import (
get_repo,
PermissionDenied,
NotFound,
)
from roles.permissions import RepoPermission
from taxonomy.api import (
get_vocabulary,
get_term,
)
from roles.permissions import RepoPermission


# pylint: disable=protected-access
Expand Down Expand Up @@ -114,3 +114,19 @@ def has_permission(self, request, view):
RepoPermission.manage_taxonomy[0]
in get_perms(request.user, repo)
)


class ManageRepoMembersPermission(BasePermission):
"""Checks manage_repo_users permission"""

def has_permission(self, request, view):
try:
repo = get_repo(view.kwargs['repo_slug'], request.user.id)
except NotFound:
raise Http404() # pragma: no cover
except PermissionDenied:
return False
if request.method in SAFE_METHODS:
return True
return RepoPermission.manage_repo_users[0] in get_perms(
request.user, repo)
54 changes: 51 additions & 3 deletions rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@

from __future__ import unicode_literals

from django.contrib.auth.models import User
from rest_framework.generics import get_object_or_404
from rest_framework.serializers import (
Serializer,
ModelSerializer,
HiddenField,
CurrentUserDefault,
CreateOnlyDefault,
CharField,
ChoiceField,
ValidationError,
)
from rest_framework.generics import get_object_or_404

from taxonomy.models import Vocabulary, Term
from learningresources.models import Repository
from .util import LambdaDefault, RequiredBooleanField
from rest.util import LambdaDefault, RequiredBooleanField
from roles.permissions import BaseGroupTypes
from taxonomy.models import Vocabulary, Term


class RepositorySerializer(ModelSerializer):
Expand Down Expand Up @@ -97,3 +103,45 @@ class Meta:
'id',
'slug',
)


class GroupSerializer(Serializer):
"""
Serializer for base_group_type
"""
group_type = ChoiceField(
choices=BaseGroupTypes.all_base_groups()
)

def validate_group_type(self, value):
"""Validate group_type"""
# pylint: disable=no-self-use
if value not in BaseGroupTypes.all_base_groups(): # pragma: no cover
raise ValidationError(
'group "{group}" is not valid'.format(group=value)
)
return value


class UserSerializer(Serializer):
"""
Serializer for user
"""
username = CharField()

def validate_username(self, value):
"""Validate username"""
# pylint: disable=no-self-use
try:
User.objects.get(username=value)
except User.DoesNotExist: # pragma: no cover
raise ValidationError(
'user "{user}" is not available'.format(user=value)
)
return value


class UserGroupSerializer(UserSerializer, GroupSerializer):
"""
Serializer for username base_group_type association
"""

0 comments on commit 7ec08ad

Please sign in to comment.