Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e3cb462d
Commit
e3cb462d
authored
Oct 07, 2016
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move embargo from common to openedx/core/djangoapps.
parent
82345810
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
77 additions
and
58 deletions
+77
-58
cms/envs/common.py
+2
-2
common/djangoapps/course_modes/tests/test_views.py
+2
-2
common/djangoapps/course_modes/views.py
+1
-1
common/djangoapps/enrollment/tests/test_views.py
+3
-3
common/djangoapps/enrollment/views.py
+1
-1
common/djangoapps/student/tests/test_enrollment.py
+2
-2
common/djangoapps/student/views.py
+1
-1
docs/en_us/platform_api/source/conf.py
+1
-1
lms/djangoapps/commerce/api/v0/tests/test_views.py
+1
-1
lms/djangoapps/commerce/api/v0/views.py
+1
-1
lms/djangoapps/shoppingcart/tests/test_views.py
+2
-2
lms/djangoapps/shoppingcart/views.py
+1
-1
lms/djangoapps/student_account/test/test_views.py
+1
-1
lms/djangoapps/verify_student/tests/test_views.py
+2
-2
lms/djangoapps/verify_student/views.py
+1
-1
lms/envs/common.py
+2
-3
lms/urls.py
+1
-1
openedx/core/djangoapps/embargo/__init__.py
+0
-0
openedx/core/djangoapps/embargo/admin.py
+6
-2
openedx/core/djangoapps/embargo/api.py
+1
-1
openedx/core/djangoapps/embargo/exceptions.py
+0
-0
openedx/core/djangoapps/embargo/fixtures/__init__.py
+0
-0
openedx/core/djangoapps/embargo/fixtures/country_codes.py
+0
-0
openedx/core/djangoapps/embargo/forms.py
+1
-1
openedx/core/djangoapps/embargo/messages.py
+0
-0
openedx/core/djangoapps/embargo/middleware.py
+2
-2
openedx/core/djangoapps/embargo/migrations/0001_initial.py
+0
-0
openedx/core/djangoapps/embargo/migrations/0002_data__add_countries.py
+0
-0
openedx/core/djangoapps/embargo/migrations/__init__.py
+0
-0
openedx/core/djangoapps/embargo/models.py
+13
-6
openedx/core/djangoapps/embargo/test_utils.py
+1
-1
openedx/core/djangoapps/embargo/tests/__init__.py
+0
-0
openedx/core/djangoapps/embargo/tests/test_api.py
+7
-4
openedx/core/djangoapps/embargo/tests/test_forms.py
+12
-6
openedx/core/djangoapps/embargo/tests/test_middleware.py
+3
-3
openedx/core/djangoapps/embargo/tests/test_models.py
+1
-1
openedx/core/djangoapps/embargo/tests/test_views.py
+2
-2
openedx/core/djangoapps/embargo/urls.py
+2
-2
openedx/core/djangoapps/embargo/views.py
+1
-1
No files found.
cms/envs/common.py
View file @
e3cb462d
...
...
@@ -368,7 +368,7 @@ MIDDLEWARE_CLASSES = (
# Allows us to dark-launch particular languages
'openedx.core.djangoapps.dark_lang.middleware.DarkLangMiddleware'
,
'embargo.middleware.EmbargoMiddleware'
,
'
openedx.core.djangoapps.
embargo.middleware.EmbargoMiddleware'
,
# Detects user-requested locale from 'accept-language' header in http request
'django.middleware.locale.LocaleMiddleware'
,
...
...
@@ -866,7 +866,7 @@ INSTALLED_APPS = (
'django_openid_auth'
,
# Country embargo support
'embargo'
,
'
openedx.core.djangoapps.
embargo'
,
# Monitoring signals
'openedx.core.djangoapps.monitoring'
,
...
...
common/djangoapps/course_modes/tests/test_views.py
View file @
e3cb462d
...
...
@@ -20,7 +20,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
course_modes.models
import
CourseMode
,
Mode
from
course_modes.tests.factories
import
CourseModeFactory
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.
embargo.test_utils
import
restrict_course
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
util.testing
import
UrlResetMixin
...
...
@@ -409,7 +409,7 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
class
TrackSelectionEmbargoTest
(
UrlResetMixin
,
ModuleStoreTestCase
):
"""Test embargo restrictions on the track selection page. """
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
common/djangoapps/course_modes/views.py
View file @
e3cb462d
...
...
@@ -23,7 +23,7 @@ from lms.djangoapps.commerce.utils import EcommerceService
from
course_modes.models
import
CourseMode
from
courseware.access
import
has_access
from
edxmako.shortcuts
import
render_to_response
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
from
student.models
import
CourseEnrollment
from
util.db
import
outer_atomic
...
...
common/djangoapps/enrollment/tests/test_views.py
View file @
e3cb462d
...
...
@@ -22,7 +22,6 @@ from django.test.utils import override_settings
import
pytz
from
course_modes.models
import
CourseMode
from
embargo.models
import
CountryAccessRule
,
Country
,
RestrictedCourse
from
enrollment.views
import
EnrollmentUserThrottle
from
util.models
import
RateLimitConfiguration
from
util.testing
import
UrlResetMixin
...
...
@@ -34,7 +33,8 @@ from openedx.core.lib.django_test_client_utils import get_absolute_url
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseStaffRole
from
student.tests.factories
import
AdminFactory
,
CourseModeFactory
,
UserFactory
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.embargo.models
import
CountryAccessRule
,
Country
,
RestrictedCourse
from
openedx.core.djangoapps.embargo.test_utils
import
restrict_course
class
EnrollmentTestMixin
(
object
):
...
...
@@ -925,7 +925,7 @@ class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestC
EMAIL
=
"bob@example.com"
PASSWORD
=
"edx"
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
common/djangoapps/enrollment/views.py
View file @
e3cb462d
...
...
@@ -17,7 +17,7 @@ from rest_framework.response import Response
from
rest_framework.throttling
import
UserRateThrottle
from
rest_framework.views
import
APIView
from
opaque_keys.edx.keys
import
CourseKey
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.cors_csrf.authentication
import
SessionAuthenticationCrossDomainCsrf
from
openedx.core.djangoapps.cors_csrf.decorators
import
ensure_csrf_cookie_cross_domain
from
openedx.core.lib.api.authentication
import
(
...
...
common/djangoapps/student/tests/test_enrollment.py
View file @
e3cb462d
...
...
@@ -12,7 +12,7 @@ from course_modes.models import CourseMode
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
util.testing
import
UrlResetMixin
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.
embargo.test_utils
import
restrict_course
from
student.tests.factories
import
UserFactory
,
CourseModeFactory
from
student.models
import
CourseEnrollment
,
CourseFullError
from
student.roles
import
(
...
...
@@ -32,7 +32,7 @@ class EnrollmentTest(UrlResetMixin, SharedModuleStoreTestCase):
USERNAME
=
"Bob"
EMAIL
=
"bob@example.com"
PASSWORD
=
"edx"
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@classmethod
def
setUpClass
(
cls
):
...
...
common/djangoapps/student/views.py
View file @
e3cb462d
...
...
@@ -109,7 +109,7 @@ from student.cookies import set_logged_in_cookies, delete_logged_in_cookies
from
student.models
import
anonymous_id_for_user
,
UserAttribute
,
EnrollStatusChange
from
shoppingcart.models
import
DonationConfiguration
,
CourseRegistrationCode
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
import
analytics
from
eventtracking
import
tracker
...
...
docs/en_us/platform_api/source/conf.py
View file @
e3cb462d
...
...
@@ -128,7 +128,7 @@ MOCK_MODULES = [
'celery'
,
'celery.task'
,
'student.roles'
,
'embargo.models'
,
'
openedx.core.djangoapps.
embargo.models'
,
'xmodule.vertical_block'
,
'xmodule.course_module'
,
'user_api.accounts.api'
,
...
...
lms/djangoapps/commerce/api/v0/tests/test_views.py
View file @
e3cb462d
...
...
@@ -22,7 +22,7 @@ from commerce.tests.mocks import mock_basket_order, mock_create_basket
from
commerce.tests.test_views
import
UserMixin
from
course_modes.models
import
CourseMode
from
edx_rest_api_client
import
exceptions
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.
embargo.test_utils
import
restrict_course
from
enrollment.api
import
get_enrollment
from
openedx.core.lib.django_test_client_utils
import
get_absolute_url
from
student.models
import
CourseEnrollment
...
...
lms/djangoapps/commerce/api/v0/views.py
View file @
e3cb462d
...
...
@@ -15,7 +15,7 @@ from commerce.exceptions import InvalidResponseError
from
commerce.http
import
DetailResponse
,
InternalRequestErrorResponse
from
course_modes.models
import
CourseMode
from
courseware
import
courses
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
from
enrollment.api
import
add_enrollment
from
enrollment.views
import
EnrollmentCrossDomainSessionAuth
from
openedx.core.djangoapps.commerce.utils
import
ecommerce_api_client
...
...
lms/djangoapps/shoppingcart/tests/test_views.py
View file @
e3cb462d
...
...
@@ -43,7 +43,7 @@ from courseware.tests.factories import InstructorFactory
from
student.models
import
CourseEnrollment
from
course_modes.models
import
CourseMode
from
edxmako.shortcuts
import
render_to_response
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.
embargo.test_utils
import
restrict_course
from
shoppingcart.processors
import
render_purchase_form_html
from
shoppingcart.admin
import
SoftDeleteCouponAdmin
from
shoppingcart.views
import
initialize_report
...
...
@@ -1846,7 +1846,7 @@ class RedeemCodeEmbargoTests(UrlResetMixin, ModuleStoreTestCase):
USERNAME
=
'bob'
PASSWORD
=
'test'
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
lms/djangoapps/shoppingcart/views.py
View file @
e3cb462d
...
...
@@ -29,7 +29,7 @@ from config_models.decorators import require_config
from
shoppingcart.reports
import
RefundReport
,
ItemizedPurchaseReport
,
UniversityRevenueShareReport
,
CertificateStatusReport
from
student.models
import
CourseEnrollment
,
EnrollmentClosedError
,
CourseFullError
,
\
AlreadyEnrolledError
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
from
.exceptions
import
(
ItemAlreadyInCartException
,
AlreadyEnrolledInCourseException
,
CourseDoesNotExistException
,
ReportTypeDoesNotExistException
,
...
...
lms/djangoapps/student_account/test/test_views.py
View file @
e3cb462d
...
...
@@ -281,7 +281,7 @@ class StudentAccountLoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMi
EMAIL
=
"bob@example.com"
PASSWORD
=
"password"
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@mock.patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
lms/djangoapps/verify_student/tests/test_views.py
View file @
e3cb462d
...
...
@@ -37,7 +37,7 @@ from courseware.url_helpers import get_redirect_url
from
common.test.utils
import
XssTestMixin
from
commerce.models
import
CommerceConfiguration
from
commerce.tests
import
TEST_PAYMENT_DATA
,
TEST_API_URL
,
TEST_API_SIGNING_KEY
,
TEST_PUBLIC_URL_ROOT
from
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.
embargo.test_utils
import
restrict_course
from
openedx.core.djangoapps.user_api.accounts.api
import
get_account_settings
from
openedx.core.djangoapps.theming.tests.test_util
import
with_comprehensive_theme
from
shoppingcart.models
import
Order
,
CertificateItem
...
...
@@ -104,7 +104,7 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin):
YESTERDAY
=
NOW
-
timedelta
(
days
=
1
)
TOMORROW
=
NOW
+
timedelta
(
days
=
1
)
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@mock.patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
lms/djangoapps/verify_student/views.py
View file @
e3cb462d
...
...
@@ -35,7 +35,7 @@ from course_modes.models import CourseMode
from
courseware.url_helpers
import
get_redirect_url
from
edx_rest_api_client.exceptions
import
SlumberBaseException
from
edxmako.shortcuts
import
render_to_response
,
render_to_string
from
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.
embargo
import
api
as
embargo_api
from
openedx.core.djangoapps.commerce.utils
import
ecommerce_api_client
from
openedx.core.djangoapps.user_api.accounts
import
NAME_MIN_LENGTH
from
openedx.core.djangoapps.user_api.accounts.api
import
update_account_settings
...
...
lms/envs/common.py
View file @
e3cb462d
...
...
@@ -1137,9 +1137,8 @@ MIDDLEWARE_CLASSES = (
'splash.middleware.SplashMiddleware'
,
'openedx.core.djangoapps.geoinfo.middleware.CountryMiddleware'
,
'embargo.middleware.EmbargoMiddleware'
,
'
openedx.core.djangoapps.
embargo.middleware.EmbargoMiddleware'
,
# Allows us to set user preferences
'openedx.core.djangoapps.lang_pref.middleware.LanguagePreferenceMiddleware'
,
...
...
@@ -2036,7 +2035,7 @@ INSTALLED_APPS = (
'rss_proxy'
,
# Country embargo support
'embargo'
,
'
openedx.core.djangoapps.
embargo'
,
# Monitoring functionality
'openedx.core.djangoapps.monitoring'
,
...
...
lms/urls.py
View file @
e3cb462d
...
...
@@ -755,7 +755,7 @@ urlpatterns += (
# Embargo
if
settings
.
FEATURES
.
get
(
'EMBARGO'
):
urlpatterns
+=
(
url
(
r'^embargo/'
,
include
(
'embargo.urls'
)),
url
(
r'^embargo/'
,
include
(
'
openedx.core.djangoapps.
embargo.urls'
)),
)
# Survey Djangoapp
...
...
common
/djangoapps/embargo/__init__.py
→
openedx/core
/djangoapps/embargo/__init__.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/admin.py
→
openedx/core
/djangoapps/embargo/admin.py
View file @
e3cb462d
...
...
@@ -5,8 +5,12 @@ from django.contrib import admin
import
textwrap
from
config_models.admin
import
ConfigurationModelAdmin
from
embargo.models
import
IPFilter
,
CountryAccessRule
,
RestrictedCourse
from
embargo.forms
import
IPFilterForm
,
RestrictedCourseForm
from
.models
import
(
IPFilter
,
CountryAccessRule
,
RestrictedCourse
)
from
.forms
import
(
IPFilterForm
,
RestrictedCourseForm
)
class
IPFilterAdmin
(
ConfigurationModelAdmin
):
...
...
common
/djangoapps/embargo/api.py
→
openedx/core
/djangoapps/embargo/api.py
View file @
e3cb462d
...
...
@@ -15,7 +15,7 @@ from rest_framework import status
from
ipware.ip
import
get_ip
from
student.auth
import
has_course_author_access
from
embargo
.models
import
CountryAccessRule
,
RestrictedCourse
from
.models
import
CountryAccessRule
,
RestrictedCourse
log
=
logging
.
getLogger
(
__name__
)
...
...
common
/djangoapps/embargo/exceptions.py
→
openedx/core
/djangoapps/embargo/exceptions.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/fixtures/__init__.py
→
openedx/core
/djangoapps/embargo/fixtures/__init__.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/fixtures/country_codes.py
→
openedx/core
/djangoapps/embargo/fixtures/country_codes.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/forms.py
→
openedx/core
/djangoapps/embargo/forms.py
View file @
e3cb462d
...
...
@@ -11,7 +11,7 @@ from xmodule.modulestore.django import modulestore
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
embargo
.models
import
IPFilter
,
RestrictedCourse
from
.models
import
IPFilter
,
RestrictedCourse
class
RestrictedCourseForm
(
forms
.
ModelForm
):
...
...
common
/djangoapps/embargo/messages.py
→
openedx/core
/djangoapps/embargo/messages.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/middleware.py
→
openedx/core
/djangoapps/embargo/middleware.py
View file @
e3cb462d
...
...
@@ -35,8 +35,8 @@ from django.shortcuts import redirect
from
ipware.ip
import
get_ip
from
util.request
import
course_id_from_url
from
embargo
.models
import
IPFilter
from
embargo
import
api
as
embargo_api
from
.models
import
IPFilter
from
.
import
api
as
embargo_api
log
=
logging
.
getLogger
(
__name__
)
...
...
common
/djangoapps/embargo/migrations/0001_initial.py
→
openedx/core
/djangoapps/embargo/migrations/0001_initial.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/migrations/0002_data__add_countries.py
→
openedx/core
/djangoapps/embargo/migrations/0002_data__add_countries.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/migrations/__init__.py
→
openedx/core
/djangoapps/embargo/migrations/__init__.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/models.py
→
openedx/core
/djangoapps/embargo/models.py
View file @
e3cb462d
...
...
@@ -8,7 +8,7 @@ file and check it in at the same time as your model changes. To do that,
1. Go to the edx-platform dir
2. ./manage.py lms schemamigration embargo --auto description_of_your_change
3. Add the migration file created in edx-platform/
common
/djangoapps/embargo/migrations/
3. Add the migration file created in edx-platform/
openedx/core
/djangoapps/embargo/migrations/
"""
import
ipaddr
...
...
@@ -27,8 +27,8 @@ from django_countries import countries
from
config_models.models
import
ConfigurationModel
from
openedx.core.djangoapps.xmodule_django.models
import
CourseKeyField
,
NoneToEmptyManager
from
embargo
.exceptions
import
InvalidAccessPoint
from
embargo
.messages
import
ENROLL_MESSAGES
,
COURSEWARE_MESSAGES
from
.exceptions
import
InvalidAccessPoint
from
.messages
import
ENROLL_MESSAGES
,
COURSEWARE_MESSAGES
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -90,6 +90,9 @@ class EmbargoedState(ConfigurationModel):
return
[]
return
[
country
.
strip
()
.
upper
()
for
country
in
self
.
embargoed_countries
.
split
(
','
)]
def
__unicode__
(
self
):
return
self
.
embargoed_countries
class
RestrictedCourse
(
models
.
Model
):
"""Course with access restrictions.
...
...
@@ -575,6 +578,7 @@ post_delete.connect(invalidate_country_rule_cache, sender=RestrictedCourse)
class
CourseAccessRuleHistory
(
models
.
Model
):
"""History of course access rule changes. """
# pylint: disable=model-missing-unicode
timestamp
=
models
.
DateTimeField
(
db_index
=
True
,
auto_now_add
=
True
)
course_key
=
CourseKeyField
(
max_length
=
255
,
db_index
=
True
)
...
...
@@ -684,14 +688,14 @@ class IPFilter(ConfigurationModel):
for
network
in
self
.
networks
:
yield
network
def
__contains__
(
self
,
ip
):
def
__contains__
(
self
,
ip
_addr
):
try
:
ip
=
ipaddr
.
IPAddress
(
ip
)
ip
_addr
=
ipaddr
.
IPAddress
(
ip_addr
)
except
ValueError
:
return
False
for
network
in
self
.
networks
:
if
network
.
Contains
(
ip
):
if
network
.
Contains
(
ip
_addr
):
return
True
return
False
...
...
@@ -713,3 +717,6 @@ class IPFilter(ConfigurationModel):
if
self
.
blacklist
==
''
:
return
[]
return
self
.
IPFilterList
([
addr
.
strip
()
for
addr
in
self
.
blacklist
.
split
(
','
)])
def
__unicode__
(
self
):
return
"Whitelist: {} - Blacklist: {}"
.
format
(
self
.
whitelist_ips
,
self
.
blacklist_ips
)
common
/djangoapps/embargo/test_utils.py
→
openedx/core
/djangoapps/embargo/test_utils.py
View file @
e3cb462d
...
...
@@ -6,7 +6,7 @@ import pygeoip
from
django.core.urlresolvers
import
reverse
from
django.core.cache
import
cache
from
embargo
.models
import
Country
,
CountryAccessRule
,
RestrictedCourse
from
.models
import
Country
,
CountryAccessRule
,
RestrictedCourse
@contextlib.contextmanager
...
...
common
/djangoapps/embargo/tests/__init__.py
→
openedx/core
/djangoapps/embargo/tests/__init__.py
View file @
e3cb462d
File moved
common
/djangoapps/embargo/tests/test_api.py
→
openedx/core
/djangoapps/embargo/tests/test_api.py
View file @
e3cb462d
...
...
@@ -25,13 +25,13 @@ from student.roles import (
OrgStaffRole
,
OrgInstructorRole
)
from
embargo
.models
import
(
from
.
.models
import
(
RestrictedCourse
,
Country
,
CountryAccessRule
,
)
from
util.testing
import
UrlResetMixin
from
embargo
import
api
as
embargo_api
from
embargo
.exceptions
import
InvalidAccessPoint
from
..
import
api
as
embargo_api
from
.
.exceptions
import
InvalidAccessPoint
from
mock
import
patch
...
...
@@ -229,6 +229,9 @@ class EmbargoCheckAccessApiTests(ModuleStoreTestCase):
@contextmanager
def
_mock_geoip
(
self
,
country_code
):
"""
Mock for the GeoIP module.
"""
with
mock
.
patch
.
object
(
pygeoip
.
GeoIP
,
'country_code_by_addr'
)
as
mock_ip
:
mock_ip
.
return_value
=
country_code
yield
...
...
@@ -240,7 +243,7 @@ class EmbargoCheckAccessApiTests(ModuleStoreTestCase):
class
EmbargoMessageUrlApiTests
(
UrlResetMixin
,
ModuleStoreTestCase
):
"""Test the embargo API calls for retrieving the blocking message URLs. """
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
ENABLED_CACHES
=
[
'default'
,
'mongo_metadata_inheritance'
,
'loc_cache'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
...
...
common
/djangoapps/embargo/tests/test_forms.py
→
openedx/core
/djangoapps/embargo/tests/test_forms.py
View file @
e3cb462d
...
...
@@ -9,8 +9,8 @@ from opaque_keys.edx.locator import CourseLocator
# Explicitly import the cache from ConfigurationModel so we can reset it after each test
from
config_models.models
import
cache
from
embargo
.models
import
IPFilter
from
embargo
.forms
import
RestrictedCourseForm
,
IPFilterForm
from
.
.models
import
IPFilter
from
.
.forms
import
RestrictedCourseForm
,
IPFilterForm
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -40,13 +40,17 @@ class RestrictedCourseFormTest(ModuleStoreTestCase):
self
.
_assert_course_field_error
(
form
)
def
_assert_course_field_error
(
self
,
form
):
# Validation shouldn't work
"""
Validation shouldn't work.
"""
self
.
assertFalse
(
form
.
is_valid
())
msg
=
'COURSE NOT FOUND'
self
.
assertIn
(
msg
,
form
.
_errors
[
'course_key'
][
0
])
# pylint: disable=protected-access
with
self
.
assertRaisesRegexp
(
ValueError
,
"The RestrictedCourse could not be created because the data didn't validate."
):
with
self
.
assertRaisesRegexp
(
ValueError
,
"The RestrictedCourse could not be created because the data didn't validate."
):
form
.
save
()
...
...
@@ -111,9 +115,11 @@ class IPFilterFormTest(TestCase):
form
=
IPFilterForm
(
data
=
form_data
)
self
.
assertFalse
(
form
.
is_valid
())
wmsg
=
"Invalid IP Address(es): [u'.0.0.1', u':dead:beef:::', u'1.0.0.0/55'] Please fix the error(s) and try again."
wmsg
=
"Invalid IP Address(es): [u'.0.0.1', u':dead:beef:::', u'1.0.0.0/55']"
\
" Please fix the error(s) and try again."
self
.
assertEquals
(
wmsg
,
form
.
_errors
[
'whitelist'
][
0
])
# pylint: disable=protected-access
bmsg
=
"Invalid IP Address(es): [u'18.244.*', u'999999:c0a8:101::42', u'1.0.0.0/'] Please fix the error(s) and try again."
bmsg
=
"Invalid IP Address(es): [u'18.244.*', u'999999:c0a8:101::42', u'1.0.0.0/']"
\
" Please fix the error(s) and try again."
self
.
assertEquals
(
bmsg
,
form
.
_errors
[
'blacklist'
][
0
])
# pylint: disable=protected-access
with
self
.
assertRaisesRegexp
(
ValueError
,
"The IPFilter could not be created because the data didn't validate."
):
...
...
common
/djangoapps/embargo/tests/test_middleware.py
→
openedx/core
/djangoapps/embargo/tests/test_middleware.py
View file @
e3cb462d
...
...
@@ -17,8 +17,8 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
config_models.models
import
cache
as
config_cache
from
embargo
.models
import
RestrictedCourse
,
IPFilter
from
embargo
.test_utils
import
restrict_course
from
.
.models
import
RestrictedCourse
,
IPFilter
from
.
.test_utils
import
restrict_course
@attr
(
shard
=
3
)
...
...
@@ -35,7 +35,7 @@ class EmbargoMiddlewareAccessTests(UrlResetMixin, ModuleStoreTestCase):
USERNAME
=
'fred'
PASSWORD
=
'secret'
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
common
/djangoapps/embargo/tests/test_models.py
→
openedx/core
/djangoapps/embargo/tests/test_models.py
View file @
e3cb462d
...
...
@@ -3,7 +3,7 @@ import json
from
django.test
import
TestCase
from
django.db.utils
import
IntegrityError
from
opaque_keys.edx.locator
import
CourseLocator
from
embargo
.models
import
(
from
.
.models
import
(
EmbargoedCourse
,
EmbargoedState
,
IPFilter
,
RestrictedCourse
,
Country
,
CountryAccessRule
,
CourseAccessRuleHistory
)
...
...
common
/djangoapps/embargo/tests/test_views.py
→
openedx/core
/djangoapps/embargo/tests/test_views.py
View file @
e3cb462d
...
...
@@ -7,7 +7,7 @@ from django.conf import settings
import
ddt
from
util.testing
import
UrlResetMixin
from
embargo
import
messages
from
..
import
messages
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
from
openedx.core.djangoapps.theming.tests.test_util
import
with_comprehensive_theme
...
...
@@ -34,7 +34,7 @@ class CourseAccessMessageViewTest(CacheIsolationTestCase, UrlResetMixin):
ENABLED_CACHES
=
[
'default'
]
URLCONF_MODULES
=
[
'embargo'
]
URLCONF_MODULES
=
[
'
openedx.core.djangoapps.
embargo'
]
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
...
...
common
/djangoapps/embargo/urls.py
→
openedx/core
/djangoapps/embargo/urls.py
View file @
e3cb462d
...
...
@@ -2,11 +2,11 @@
from
django.conf.urls
import
patterns
,
url
from
embargo
.views
import
CourseAccessMessageView
from
.views
import
CourseAccessMessageView
urlpatterns
=
patterns
(
'embargo.views'
,
'
openedx.core.djangoapps.
embargo.views'
,
url
(
r'^blocked-message/(?P<access_point>enrollment|courseware)/(?P<message_key>.+)/$'
,
CourseAccessMessageView
.
as_view
(),
...
...
common
/djangoapps/embargo/views.py
→
openedx/core
/djangoapps/embargo/views.py
View file @
e3cb462d
...
...
@@ -5,7 +5,7 @@ from django.views.generic.base import View
from
edxmako.shortcuts
import
render_to_response
from
embargo
import
messages
from
.
import
messages
class
CourseAccessMessageView
(
View
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment