Commit Graph

39 Commits

Author SHA1 Message Date
Will Daly
6ba6afced8 Merge pull request #6943 from edx/will/country-access-api-changes
Finish Country Access (Part 1 of 3)
2015-02-10 12:57:48 -05:00
Will Daly
98ee3a5377 Implement IP filtering in embargo middleware.
Add history table for course access rule changes.

Provide test utility for simulating restricted access.

Provide `redirect_if_blocked` method for integration with other
parts of the system (will be used for blocking enrollment).

Add info-level logging explaining when and why users are blocked.
2015-02-10 10:47:51 -05:00
Will Daly
7e746f7df0 Fix embargo migration to the new data models.
The previous version of this migration incorrectly handled
disabled configuration.  When configuration is disabled,
the embargoed country field was the empty string; calling
str.split(",") produced a list with a single empty list entry,
which is not a valid country code.
2015-02-09 14:08:35 -05:00
Will Daly
92c2fdbca1 Add new models to embargo to support country access
Add Django admin UI for configuring country access

Migrate existing embargo rules into the new tables.

ECOM-996: updated the middleware to use new models and access rules

ECOM-996: added the flag to support old and new formats

ECOM-996: added the api layer for country access settings

ECOM-996: added the api layer for country access settings

ECOM-996 implementing the white and blacklist checks.

ECOM-996 minor re-factoring in api.

ECOM-996 minor re-factoring in api.

ECOM-1025 refactoring the code according to PR feedback.

ECOM-1025 refactoring the code according to PR feedback.

ECOM-1025 deleting cache in model save and delete methods

ECOM-1025 adding basic api test cases file.

ECOM-1025 refactoring the code according to PR feedback.

ECOM-1025 refactoring the code according to PR feedback.

ECOM-1025 refactoring the code according to PR feedback. adding the test cases.

ECOM-1025 removing extra line

ECOM-1025 removing un-used function.

ECOM-1025 removing un-used function.

ECOM-1025 re-factor the code.

ECOM-1025 re-name the test file to test_middleware_access_rules.py. we already had old test_middleware.py

ECOM-1025 adding test cases for newly added models.

ECOM-1025 adding test cases and resolve conflicts.

ECOM-1025 fixing the quality and pep-8 issues.

ECOM-1025 re-factoring the code according to the PR feedback.

ECOM-1025 re-name the variable name.

ECOM-1025 removing the _check_ip_lists and its test cases. also added few missing scenarios test cases.

ECOM-1025 removing un-used line.
2015-02-09 18:28:10 +05:00
Calen Pennington
b353ed2ea2 Better support specifying of modulestore configuration in test cases
The existing pattern of using `override_settings(MODULESTORE=...)` prevented
us from having more than one layer of subclassing in modulestore tests.

In a structure like:

    @override_settings(MODULESTORE=store_a)
    class BaseTestCase(ModuleStoreTestCase):
        def setUp(self):
            # use store

    @override_settings(MODULESTORE=store_b)
    class ChildTestCase(BaseTestCase):
        def setUp(self):
            # use store

In this case, the store actions performed in `BaseTestCase` on behalf of
`ChildTestCase` would still use `store_a`, even though the `ChildTestCase`
had specified to use `store_b`. This is because the `override_settings`
decorator would be the innermost wrapper around the `BaseTestCase.setUp` method,
no matter what `ChildTestCase` does.

To remedy this, we move the call to `override_settings` into the
`ModuleStoreTestCase.setUp` method, and use a cleanup to remove the override.
Subclasses can just defined the `MODULESTORE` class attribute to specify which
modulestore to use _for the entire `setUp` chain_.

[PLAT-419]
2015-02-04 09:09:14 -05:00
Calen Pennington
03a05fd9d4 Always call super(..).setUp() from setUp 2015-02-04 09:09:14 -05:00
Will Daly
ce9c258f8b Update country access message end-points to be backwards compatible with embargo theme templates
Move default country access messages out of static_templates, so they are not served by other Django views.
2015-02-03 08:59:41 -05:00
Will Daly
82d7e25f3e Add views to the embargo app to render messages explaining why students are blocked. 2015-02-02 14:04:29 -05:00
Will Daly
a5867da9de Add new models to embargo to support country access
Add Django admin UI for configuring country access

Migrate existing embargo rules into the new tables.
2015-02-02 11:54:41 -05:00
Diana Huang
c71a183316 Update embargo copy.
ECOM-963

update copy in tests
2015-01-29 15:10:35 -05:00
Jesse Zoldak
bf3b87bc64 Clean up all modulestore testcases
Move modulestore config for tests to an importable location
Disable pylnt warning for lms imports in common tests
Refactor all testcases that loaded all xml courses
TE-610
TE-489
2014-12-02 07:09:36 -05:00
Sarina Canelake
0dad9da5e4 s/pylint: disable=W0621/pylint: disable=redefined-outer-name/ 2014-12-01 11:22:08 -05:00
stv
cf9308144d Fix PEP8: E302 expected 2 blank lines, found 1 2014-11-10 11:00:11 -08:00
Adam Palay
0a385544a3 update number of queries in embargo test 2014-09-19 10:19:23 -04:00
Renzo Lucioni
9239253614 Remove Django Waffle 2014-09-12 16:22:03 -04:00
Will Daly
512db7be99 Fix embargo middleware with tests 2014-09-09 08:50:10 -04:00
Renzo Lucioni
c3359135e7 Refrain from accessing country code if country is None 2014-09-05 10:58:18 -04:00
Renzo Lucioni
aa28fba9ad Revert "Revert "Merge pull request #4976 from edx/will/ecom-128""
This reverts commit 371dfd6187.
2014-09-05 10:51:51 -04:00
Diana Huang
371dfd6187 Revert "Merge pull request #4976 from edx/will/ecom-128"
This reverts commit a03baee25c, reversing
changes made to 12e2d442e9.
2014-09-04 16:01:28 -04:00
Will Daly
31a6566110 Embargo based on country code in the user's profile. 2014-08-27 08:51:45 -04:00
Jason Zhu
13846e074d Support ipv6 in geoinfo and Embargo 2014-08-14 16:13:35 +08:00
Calen Pennington
cfcbdc0145 Move to OpaqueKey implementations from the external library
[LMS-2757]
2014-05-29 17:03:35 -04:00
Calen Pennington
9feff62857 Merge pull request #3834 from cpennington/ok-merge-from-master
Merge master into opaque-keys
2014-05-23 11:36:52 -04:00
Calen Pennington
cd862b3253 Merge remote-tracking branch 'edx/master' into opaque-keys
Conflicts:
	cms/djangoapps/contentstore/tests/test_contentstore.py
	cms/djangoapps/contentstore/views/component.py
	cms/djangoapps/contentstore/views/item.py
	cms/djangoapps/contentstore/views/preview.py
	cms/djangoapps/contentstore/views/tests/test_container.py
	cms/static/js/spec/views/unit_spec.js
	cms/static/js/utils/module.js
	cms/templates/container.html
	cms/templates/studio_vertical_wrapper.html
	cms/templates/studio_xblock_wrapper.html
	common/djangoapps/student/views.py
	lms/templates/notes.html
	lms/templates/textannotation.html
	lms/templates/videoannotation.html
2014-05-22 10:52:00 -04:00
Sarina Canelake
4723467345 Validate forms to allow old and new style course key serialization syntax 2014-05-21 17:44:50 -04:00
Alan Boudreault
877ec3f963 some minor improvements to embargo 2014-05-20 10:03:06 -04:00
Alan Boudreault
db161543d8 Modified EMBARGO_SITE to SITE_EMBARGOED, improved logs 2014-05-19 15:53:45 -04:00
Alan Boudreault
25948e3694 Fix minor typo in a test 2014-05-19 15:12:02 -04:00
Alan Boudreault
ba6e61b907 Extended Embargo feature to support site access restriction and ip network 2014-05-19 15:12:02 -04:00
Calen Pennington
155ffe37ca Merge remote-tracking branch 'edx/master' into opaque-keys-merge-master
Conflicts:
	cms/djangoapps/contentstore/views/item.py
	cms/djangoapps/contentstore/views/tests/test_container.py
	cms/djangoapps/contentstore/views/tests/test_tabs.py
	common/lib/xmodule/xmodule/modulestore/mongo/draft.py
	lms/djangoapps/certificates/management/commands/gen_cert_report.py
	lms/djangoapps/certificates/queue.py
	lms/djangoapps/certificates/views.py
	lms/djangoapps/courseware/module_render.py
	lms/djangoapps/courseware/tests/test_module_render.py
	lms/djangoapps/instructor/views/api.py
	lms/djangoapps/instructor/views/instructor_dashboard.py
	lms/djangoapps/instructor/views/legacy.py
	lms/djangoapps/shoppingcart/tests/test_models.py
	lms/djangoapps/verify_student/views.py
2014-05-09 15:29:32 -04:00
Calen Pennington
d466132a1f Merge remote-tracking branches 'edx/opaque-keys-base-keys', 'edx/opaque-keys-cms', 'edx/opaque-keys-common-djangoapps', 'edx/opaque-keys-common-lib-xmodule', 'edx/opaque-keys-common-misc', 'edx/opaque-keys-django-fields', 'edx/opaque-keys-embargo-tests', 'edx/opaque-keys-library', 'edx/opaque-keys-lms-courseware', 'edx/opaque-keys-lms-djangoapps', 'edx/opaque-keys-lms-templates', 'edx/opaque-keys-mongoengine-fields', 'edx/opaque-keys-requirements' and 'edx/opaque-keys-roles-table' into opaque-keys 2014-05-08 20:32:28 -04:00
Calen Pennington
e2bfcf2a36 Make course ids and usage ids opaque to LMS and Studio [partial commit]
This commit updates common/djangoapps.

These keys are now objects with a limited interface, and the particular
internal representation is managed by the data storage layer (the
modulestore).

For the LMS, there should be no outward-facing changes to the system.
The keys are, for now, a change to internal representation only. For
Studio, the new serialized form of the keys is used in urls, to allow
for further migration in the future.

Co-Author: Andy Armstrong <andya@edx.org>
Co-Author: Christina Roberts <christina@edx.org>
Co-Author: David Baumgold <db@edx.org>
Co-Author: Diana Huang <dkh@edx.org>
Co-Author: Don Mitchell <dmitchell@edx.org>
Co-Author: Julia Hansbrough <julia@edx.org>
Co-Author: Nimisha Asthagiri <nasthagiri@edx.org>
Co-Author: Sarina Canelake <sarina@edx.org>

[LMS-2370]
2014-05-07 12:54:49 -04:00
Calen Pennington
afde40ad13 Make course ids and usage ids opaque to LMS and Studio [partial commit]
This commit makes the embargo.tests module a real python module.

These keys are now objects with a limited interface, and the particular
internal representation is managed by the data storage layer (the
modulestore).

For the LMS, there should be no outward-facing changes to the system.
The keys are, for now, a change to internal representation only. For
Studio, the new serialized form of the keys is used in urls, to allow
for further migration in the future.

Co-Author: Andy Armstrong <andya@edx.org>
Co-Author: Christina Roberts <christina@edx.org>
Co-Author: David Baumgold <db@edx.org>
Co-Author: Diana Huang <dkh@edx.org>
Co-Author: Don Mitchell <dmitchell@edx.org>
Co-Author: Julia Hansbrough <julia@edx.org>
Co-Author: Nimisha Asthagiri <nasthagiri@edx.org>
Co-Author: Sarina Canelake <sarina@edx.org>

[LMS-2370]
2014-05-05 11:54:11 -04:00
Sarina Canelake
af31f31be8 Expose "enabled" checkbox in Embargo admin 2014-05-02 14:59:22 -04:00
Sarina Canelake
f79cefe19a Add logging to embargo middleware 2014-03-02 18:27:18 -05:00
Jay Zoldak
1fe453a3a7 Update schema for bok-choy database
Finalize tests for embargo middleware app
2014-02-27 10:27:29 -05:00
Sarina Canelake
e71bbeb1e2 Tests for embargo middleware feature 2014-02-27 09:33:17 -05:00
Sarina Canelake
fe85a1eec1 Django-admin for Embargo feature
Allows specification of countries to embargo, what course(s) should
apply embargo restrictions, and whitelist/blacklist capability for
specific individual IP addresses.
2014-02-27 08:38:05 -05:00
Julia Hansbrough
a7ae152d9b Embargo Middleware feature
Adds configurable middleware in common/djangoapps/embargo that
allows specific courses to comply with US Export regulations by
embargoing students from specific countries, whilst simultaneously
allowing other courses to be freely open to all.
2014-02-27 08:37:58 -05:00