Skip to content
This repository was archived by the owner on Jan 28, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
8407971
Used different haystack index for tests to prevent conflict with web …
Jul 20, 2015
44f5c3c
Implemented learning resource panel updating on every panel open
Jul 17, 2015
d103a5b
Merge pull request #386 from mitodl/rc/0.5.0
pwilkins Jul 20, 2015
b76aaea
Merge pull request #378 from mitodl/bugfix/gs/learning_resource_panel
giocalitri Jul 20, 2015
278bcc7
Merge pull request #393 from mitodl/fix/gs/use_separate_test_index
giocalitri Jul 20, 2015
2cf145c
Added sorting to search results
Jul 16, 2015
72049c3
Merge pull request #383 from mitodl/feature/gdm/349_sorting
ShawnMilo Jul 20, 2015
67d56e3
Implemented preview link for learning resource panel
Jul 13, 2015
a477a5e
Changed vocabulary term indexing from string to integer.
ShawnMilo Jul 21, 2015
ebb5bfe
Merge pull request #397 from mitodl/bug/skm/384_nonalpha
noisecapella Jul 21, 2015
e4e211c
Merge pull request #352 from mitodl/feature/gs/preview
pwilkins Jul 21, 2015
6b21d32
Grouped REST tests by common endpoint
Jul 20, 2015
1c509c6
Fixed preview link not showing up in list view
Jul 21, 2015
5b85953
Merge pull request #396 from mitodl/refactor/gs/move_tests_around
giocalitri Jul 21, 2015
8ccad3b
Updated Haystack to 2.4.0
carsongee Jul 21, 2015
a8392b4
Merge pull request #399 from mitodl/bugfix/gs/preview
carsongee Jul 21, 2015
8b8c2fc
Refactored permission check for listing view
Jul 20, 2015
bd6f0fd
Merge pull request #392 from mitodl/improvement/gdm/permission_check_…
noisecapella Jul 22, 2015
b51f4a6
Merge pull request #400 from mitodl/feature/update_haystack
carsongee Jul 22, 2015
5d12e6f
Refactored code for reloading module into a function
Jul 22, 2015
4b77f31
Merge pull request #404 from mitodl/refactor/gs/reload_module
carsongee Jul 22, 2015
aed8720
Removed export view which isn't used anymore
Jul 23, 2015
3af7465
Merge pull request #406 from mitodl/refactor/gs/remove_export_view
giocalitri Jul 23, 2015
bc9787e
Added description path to listing page
Jul 21, 2015
cdf14ff
Extended tests for manage_taxonomies.jsx file
amir-qayyum-khan Jul 10, 2015
ce2341f
Merge pull request #405 from mitodl/feature/gdm/388_path_in_results
noisecapella Jul 24, 2015
b221aa7
Added docker support for running worker or Web process by environment
carsongee Jul 22, 2015
f074907
Merge pull request #328 from mitodl/test/aq/unit_tests_manage_taxonomies
noisecapella Jul 24, 2015
6bffff8
Changed response vocabulary name to match input and avoid key collision
Jul 24, 2015
e3ef115
Merge pull request #401 from mitodl/feature/cg/docker_cmd_by_env
ShawnMilo Jul 24, 2015
aa1718a
Added shopping cart for export
Jul 15, 2015
c911432
Merge pull request #371 from mitodl/feature/gs/export_shopping_cart
ShawnMilo Jul 27, 2015
9ba8bef
Created StatusBox component to hold messages and errors
Jul 24, 2015
bd16f94
Fix test failures due to pylint dependency chain
bdero Jul 27, 2015
75109fd
Merge pull request #420 from mitodl/feature/bdero/fix-test-deps
giocalitri Jul 27, 2015
0998e47
Merge pull request #415 from mitodl/refactor/gs/status_box
giocalitri Jul 27, 2015
716bcb1
Fixed bug where export checkboxes were not updated in sync with expor…
Jul 27, 2015
4f19dee
Removed console.error statement
Jul 27, 2015
1a543f7
Merge pull request #423 from mitodl/bugfix/gs/select_behavior
ShawnMilo Jul 28, 2015
d0f31a4
Fixed broken links in the footer
Ferdi Jul 28, 2015
142ab50
Merge pull request #426 from mitodl/features/fixfooter
Ferdi Jul 28, 2015
083a484
Changed vocabularies listing page to match the design
Ferdi Jul 27, 2015
43b01e8
Merge pull request #424 from mitodl/features/taxlistformatting
noisecapella Jul 28, 2015
77652b7
Merge pull request #410 from mitodl/refactor/gs/rename_output_slug
ShawnMilo Jul 28, 2015
96bba9b
Added test for ManageTaxonomies.loader
Jul 24, 2015
6869f1e
Incremented xbundle version
Jul 28, 2015
f23e4d2
Merge pull request #428 from mitodl/bugfix/gs/update_xbundle
noisecapella Jul 28, 2015
453a958
Merge pull request #414 from mitodl/test/gs/test_taxonomy_render
noisecapella Jul 28, 2015
168943a
Added field to Vocabulary to define if it can contain multiple terms
Jul 23, 2015
58d0a12
Merge pull request #421 from mitodl/feature/gdm/346_multiselect_terms
giocalitri Jul 28, 2015
bc17278
Merge pull request #430 from mitodl/refactor/gs/remove_console_error
pdpinch Jul 29, 2015
2dd4384
Avoided hitting the database for the search page.
ShawnMilo Jul 27, 2015
4bae2ca
Merge pull request #417 from mitodl/feature/skm/402_search_no_DB
ShawnMilo Jul 29, 2015
6a56600
Pinned all versions
carsongee Jul 29, 2015
af9f8b7
Made XML preview box for a LearningResource should be read only
amir-qayyum-khan Jul 30, 2015
e464455
Merge pull request #441 from mitodl/feature/aq/make_xml_read_only
pdpinch Jul 30, 2015
fe5bb20
Created ICheckbox React component
Jul 29, 2015
a646e41
Added Select2 to the JS libraries
Jul 28, 2015
1661f99
Added select2-bootstrap-theme bower component
Jul 29, 2015
11944bf
Added export functionality for learning resources
Jul 21, 2015
0cd8834
Added test for StaticAsset.loader
Jul 30, 2015
05f5b43
Merge pull request #444 from mitodl/feature/gdm/346_multiselect_terms…
giocalitri Jul 30, 2015
ff5d2dd
Removed export button for empty repositories
Jul 30, 2015
a232a6f
Merge pull request #437 from mitodl/feature/gs/icheck_react
noisecapella Jul 30, 2015
905cea0
Merge pull request #433 from mitodl/feature/pinning_reqs
pdpinch Jul 30, 2015
0baee85
Merge pull request #407 from mitodl/feature/gs/export_download
noisecapella Jul 30, 2015
67e1849
Merge pull request #445 from mitodl/test/gs/test_staticasset_loader
noisecapella Jul 30, 2015
633fecb
Merge pull request #446 from mitodl/feature/gs/no_export_for_empty_repo
giocalitri Jul 30, 2015
b4e3321
Modified learningresource panel to include multi select
Jul 28, 2015
31c1029
Merge pull request #447 from mitodl/feature/gdm/346_multiselect_terms#2
giocalitri Jul 31, 2015
5ad71d8
Fixed export button not appearing in certain situations
Jul 31, 2015
fbb7154
Merge pull request #456 from mitodl/bugfix/gs/remove_export_button
ShawnMilo Aug 3, 2015
78aa0f2
- Modified learningresource panel to include multi select.
pwilkins Jul 31, 2015
1753cff
Revert "Removed export button for empty repositories"
pwilkins Jul 31, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ deploy:
run:
- "sleep 15"
- "python manage.py migrate --noinput"
- "python manage.py update_index"
- "python manage.py sync_permissions"
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ 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

EXPOSE 8070
# Gather static
RUN ./manage.py collectstatic --noinput

USER mitodl
CMD uwsgi uwsgi.ini

# Set and expose port for uwsgi config
EXPOSE 8070
ENV PORT 8070
CMD if [ -n "$WORKER" ]; then celery -A lore worker; else uwsgi uwsgi.ini; fi
45 changes: 43 additions & 2 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
Release Notes
-------------

Version 0.6.0
=============

- Modified learningresource panel to include multi select.
- Fixed export button not appearing in certain situations.
- Added test for StaticAsset.loader.
- Added export functionality for learning resources.
- Added select2-bootstrap-theme bower component.
- Added Select2 to the JS libraries.
- Created ICheckbox React component.
- Made XML preview box for a LearningResource should be read only.
- Pinned all versions.
- Avoided hitting the database for the search page.
- Added field to Vocabulary to define if it can contain multiple terms.
- Incremented xbundle version.
- Added test for ManageTaxonomies.loader.
- Changed vocabularies listing page to match the design.
- Fixed broken links in the footer.
- Removed console.error statement.
- Fixed bug where export checkboxes were not updated in sync with
export count.
- Fix test failures due to pylint dependency chain.
- Created StatusBox component to hold messages and errors.
- Added shopping cart for export.
- Changed response vocabulary name to match input and avoid key collision.
- Added docker support for running worker or Web process by environment.
- Extended tests for manage_taxonomies.jsx file.
- Added description path to listing page.
- Removed export view which isn't used anymore.
- Refactored code for reloading module into a function.
- Refactored permission check for listing view.
- Updated Haystack to 2.4.0 - Removed automatic index update from deployment.
- Fixed preview link not showing up in list view.
- Grouped REST tests by common endpoint.
- Changed vocabulary term indexing from string to integer.
- Implemented preview link for learning resource panel.
- Added sorting to search results.
- Implemented learning resource panel updating on every panel open.
- Used different haystack index for tests to prevent conflict with
web application.

Version 0.5.0
=============

- Fixed display of vocabulary terms containing spaces.
- Fixed comparison of FileFields to strings.
- Fixed typo in search hint
- Added bootstrap style to vocabularly learning type checkboxes Closes #337
- Added bootstrap style to vocabulary learning type checkboxes Closes #337
- Changed search box description
- Fixed mutating of this.state which is forbidden
- Added static file parsing to HTML elements.
Expand Down Expand Up @@ -132,7 +173,7 @@ Version 0.1.0
- Added rest app with support for RESTful API
- Added initial authorization support
- Added login requirement for taxonomy app
- Switched to using django storage for course uploads
- Switched to using Django storage for course uploads
- Switched to using Haystack/ElasticSearch for listing page
- Protected course imports
- Protected export view
Expand Down
114 changes: 92 additions & 22 deletions apiary.apib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FORMAT: 1A
HOST: http://lore.odl.mit.edu/
HOST: http://lore.odl.mit.edu/api/v1/

# LORE

Expand All @@ -21,7 +21,7 @@ URL Structure is `https://{domain}/api/v1/{resource}/{resource_id}/`

*Example: `http://lore.odl.mit.edu/api/v1/repositories/physics-1/` will return a JSON representation of the repository with name "physics-1".*

*Example: `http://lore.odl.mit.edu/api/v1/repositories/physics-1/learningresources/1007/` will return a JSON representation
*Example: `http://lore.odl.mit.edu/api/v1/repositories/physics-1/learning_resources/1007/` will return a JSON representation
of the learning resource with ID=1007.*


Expand Down Expand Up @@ -134,15 +134,16 @@ Create a repository by providing its JSON representation.
"create_date": "2015-06-22"
}

## Group Learningresources
## Group LearningResources

## Learningresource Collection [/repositories/{repo_slug}/learning_resources/{?type_name}]
## LearningResource Collection [/repositories/{repo_slug}/learning_resources/{?type_name}]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ type_name: `chapter` (string, optional) - type of learning resource
+ ids: `1,9` (string, optional) - comma separated list of LearningResource ids. Will filter out LearningResources not in this list.

### List Learningresources [GET]
### List LearningResources [GET]

+ Response 200 (application/json)

Expand All @@ -168,19 +169,20 @@ Create a repository by providing its JSON representation.
"xa_nr_attempts": 0,
"xa_avg_grade": 0.0,
"xa_histogram_grade": 0.0,
"terms": []
"terms": [],
"preview_url": "https://www.example.com/courses..."
},
...
]
}

## Learningresource [/repositories/{repo_slug}/learning_resources/{learningresource_id}/]
## LearningResource [/repositories/{repo_slug}/learning_resources/{learningresource_id}/]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ learningresource_id: `8` (number, required) - ID of the Learningresource
+ learningresource_id: `8` (number, required) - ID of the LearningResource

### View a Learningresource [GET]
### View a LearningResource [GET]

+ Response 200 (application/json)

Expand All @@ -199,10 +201,11 @@ Create a repository by providing its JSON representation.
"xa_nr_attempts": 0,
"xa_avg_grade": 0.0,
"xa_histogram_grade": 0.0,
"terms": []
"terms": [],
"preview_url": "https://www.example.com/courses..."
}

### Partially Update a Learningresource [PATCH]
### Partially Update a LearningResource [PATCH]

+ Request (application/json)

Expand All @@ -227,10 +230,11 @@ Create a repository by providing its JSON representation.
"xa_nr_attempts": 0,
"xa_avg_grade": 0.0,
"xa_histogram_grade": 0.0,
"terms": []
"terms": [],
"preview_url": "https://www.example.com/courses..."
}

### Update a Learningresource [PUT]
### Update a LearningResource [PUT]

+ Request (application/json)

Expand All @@ -256,18 +260,84 @@ Create a repository by providing its JSON representation.
"xa_nr_attempts": 0,
"xa_avg_grade": 0.0,
"xa_histogram_grade": 0.0,
"terms": []
"terms": [],
"preview_url": "https://www.example.com/courses..."
}

## Group LearningResourceExports

List of LearningResources to be exported. This is stored per user and is deleted on logout.

## LearningResourceExport Collection [/repositories/{repo_slug}/learning_resource_exports/{username}/]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ username: `sarah` (string, required) - owner of exports (must be logged in user)

### List LearningResourceExports [GET]

+ Response 200 (application/json)

+ Body

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 13
}
]
}

### Delete LearningResourceExports [DELETE]

Clears the export list for this repository.

+ Response 204 (application/json)

### Add a LearningResource ID to Export list [POST]

+ Request (application/json)

{
"id": 15
}

+ Response 201 (application/json)

{
"id": 15
}

## Group Staticassets
## LearningResourceExport [/repositories/{repo_slug}/learning_resource_exports/{username}/]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ username: `sarah` (string, required) - owner of exports (must be logged in user)

### View a LearningResourceExport [GET]

+ Response 200 (application/json)

{
"id": 13
}

### Delete an ID from the LearningResource export list [DELETE]

+ Response 204 (application/json)

## Group StaticAssets

## Staticassets Collection [/repositories/{repo_slug}/learning_resources/{learningresource_id}/static_assets/]
## StaticAssets Collection [/repositories/{repo_slug}/learning_resources/{learningresource_id}/static_assets/]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ learningresource_id: `1` (number, required) - ID of the Learningresource
+ learningresource_id: `1` (number, required) - ID of the LearningResource

### List All Staticassets [GET]
### List All StaticAssets [GET]

+ Response 200 (application/json)

Expand All @@ -283,14 +353,14 @@ Create a repository by providing its JSON representation.
]
}

## Staticasset [/repositories/{repo_slug}/learning_resources/{learningresource_id}/static_assets/{static_asset_id}/]
## StaticAsset [/repositories/{repo_slug}/learning_resources/{learningresource_id}/static_assets/{static_asset_id}/]

+ Parameters
+ repo_slug: `physics-1` (string, required) - slug for the repository
+ learningresource_id: `1` (number, required) - ID of the Learningresource
+ static_asset_id: `1` (number, required) - ID of the Staticasset
+ learningresource_id: `1` (number, required) - ID of the LearningResource
+ static_asset_id: `1` (number, required) - ID of the StaticAsset

### View a Staticasset [GET]
### View a StaticAsset [GET]

+ Response 200 (application/json)

Expand Down
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"modernizr": "~2.8.3",
"retina.js": "~1.3.0",
"react": "0.13.3",
"react-addons": "0.1.2"
"react-addons": "0.1.2",
"select2": "~4.0.0",
"select2-bootstrap-theme": "~0.1.0-beta.4"
}
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ web:
LORE_ADMIN_EMAIL:
LORE_CAS_URL:
CELERY_ALWAYS_EAGER: False
CELERY_RESULT_BACKEND: redis://redis:6379/4
BROKER_URL: redis://redis:6379/4
HAYSTACK_URL: elastic:9200
ports:
Expand Down
Empty file added exporter/__init__.py
Empty file.
84 changes: 84 additions & 0 deletions exporter/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""
Functions for exporting learning resources
"""

from __future__ import unicode_literals

from tempfile import mkdtemp, mkstemp
import tarfile
import os
from shutil import rmtree

from django.utils.text import slugify
from django.core.files.storage import default_storage
from lore.settings import EXPORT_PATH_PREFIX


def export_resources_to_directory(learning_resources):
"""
Create files of LearningResource and StaticAsset contents inside directory.

Args:
learning_resources (list of learningresources.models.LearningResource):
LearningResources to export in tarball
Returns:
unicode: Newly created temp directory with files inside of it.
"""
def sanitize(title):
"""Sanitize title for use in filename."""
# Limit filename to 200 characters since limit is 256
# and we have a number and extension too.
return slugify(title)[:200]

tempdir = mkdtemp()
try:
for learning_resource in learning_resources:
filename = "{id}_{title}.xml".format(
id=learning_resource.id,
title=sanitize(learning_resource.title),
)
with open(os.path.join(tempdir, filename), 'w') as f:
f.write(learning_resource.content_xml)
except:
# Clean up temporary directory since we can't return it anymore.
rmtree(tempdir)
raise
return tempdir


def export_resources_to_tarball(learning_resources, username):
"""
Create tarball and put LearningResource and StaticAsset contents in it.

Args:
learning_resources (list of learningresources.models.LearningResource):
LearningResources to export in tarball
username (unicode): Name of user
Returns:
unicode: path of tarball within django-storage
"""
handle, tempfilepath = mkstemp()
os.close(handle)
try:
archive = tarfile.open(tempfilepath, mode='w:gz')

tempdir = export_resources_to_directory(learning_resources)
try:
for name in os.listdir(tempdir):
abs_path = os.path.join(tempdir, name)
if os.path.isfile(abs_path):
archive.add(abs_path, arcname=name)

archive.close()
output_path = '{prefix}{username}_exports.tar.gz'.format(
prefix=EXPORT_PATH_PREFIX,
username=username
)

# Remove any old paths.
default_storage.delete(output_path)
return default_storage.save(output_path, open(tempfilepath, 'rb'))
finally:
rmtree(tempdir)
finally:
os.remove(tempfilepath)
Loading