Skip to content
This repository was archived by the owner on Jul 21, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions README
Original file line number Diff line number Diff line change
@@ -1,37 +0,0 @@
************************************
INSTALLATION
************************************

Please refer to https://code.google.com/p/oppia/wiki/GettingStarted for extensive installation instructions. Here is just a short summary for developers who would like to contribute:

First, clone the Oppia repo. We suggest you make a directory called opensource/ within your home folder (mkdir opensource). Then do

cd opensource/

and inside there, follow the instructions at the bottom of this page

https://code.google.com/p/oppia/source/clones

to make your own copy of the Oppia repo on the code.google.com server. This means you will now have a separate repo (say oppia-yourname). You can make any changes you like to this test repo, and they will not affect the original repo (unless you try and push them to the main repo later).

Now go to the code.google.com page for your repo and git clone it to your own computer. The instructions are at

https://code.google.com/r/[YOUR_REPO_NAME]/source/checkout

We suggest you follow the method using .netrc, since it is more convenient. After editing your ~/.netrc file, run

git clone https://code.google.com/r/[YOUR_REPO_NAME]/

You might have to change the name of the downloaded directory to oppia,

mv [YOUR_REPO_NAME] oppia

Then, navigate to oppia/ and install Oppia with

bash scripts/start.sh

************************************
TESTING THE INSTALLATION
************************************

Run `bash scripts/test.sh' and `bash scripts/run_js_tests.sh' from the oppia/ folder.
5 changes: 5 additions & 0 deletions core/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from core.domain import config_services
from core.domain import exp_services
from core.domain import recommendations_services
from core.domain import rights_manager
from core.domain import rte_component_registry
from core.domain import user_services
from core.platform import models
Expand Down Expand Up @@ -170,6 +171,10 @@ def post(self):
(self.user_id, exploration_id))
exp_services.delete_demo(unicode(exploration_id))
exp_services.load_demo(unicode(exploration_id))

# Release ownership of all explorations.
rights_manager.release_ownership_of_exploration(
feconf.SYSTEM_COMMITTER_ID, unicode(exploration_id))
elif self.payload.get('action') == 'clear_search_index':
exp_services.clear_search_index()
elif self.payload.get('action') == 'save_config_properties':
Expand Down
12 changes: 6 additions & 6 deletions core/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,12 @@ def render_template(
'DEFAULT_LANGUAGE_CODE': feconf.ALL_LANGUAGE_CODES[0]['code'],
'DEV_MODE': feconf.DEV_MODE,
'DOMAIN_URL': '%s://%s' % (scheme, netloc),
'EXPLORATION_STATUS_PRIVATE': (
rights_manager.EXPLORATION_STATUS_PRIVATE),
'EXPLORATION_STATUS_PUBLIC': (
rights_manager.EXPLORATION_STATUS_PUBLIC),
'EXPLORATION_STATUS_PUBLICIZED': (
rights_manager.EXPLORATION_STATUS_PUBLICIZED),
'ACTIVITY_STATUS_PRIVATE': (
rights_manager.ACTIVITY_STATUS_PRIVATE),
'ACTIVITY_STATUS_PUBLIC': (
rights_manager.ACTIVITY_STATUS_PUBLIC),
'ACTIVITY_STATUS_PUBLICIZED': (
rights_manager.ACTIVITY_STATUS_PUBLICIZED),
'FULL_URL': '%s://%s/%s' % (scheme, netloc, path),
'INVALID_NAME_CHARS': feconf.INVALID_NAME_CHARS,
# TODO(sll): Consider including the obj_editor html directly as
Expand Down
50 changes: 31 additions & 19 deletions core/controllers/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def test_editor(self, exploration_id, escaped_state_name=None, **kwargs):
except:
raise self.PageNotFoundException

if not rights_manager.Actor(self.user_id).can_edit(exploration_id):
if not rights_manager.Actor(self.user_id).can_edit(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id):
raise self.UnauthorizedUserException(
'You do not have the credentials to edit this exploration.',
self.user_id)
Expand Down Expand Up @@ -171,14 +172,15 @@ def get(self, exploration_id):
exploration_id, strict=False)
if (exploration is None or
not rights_manager.Actor(self.user_id).can_view(
exploration_id)):
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id)):
self.redirect('/')
return

can_edit = (
bool(self.user_id) and
self.username not in config_domain.BANNED_USERNAMES.value and
rights_manager.Actor(self.user_id).can_edit(exploration_id))
rights_manager.Actor(self.user_id).can_edit(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id))

value_generators_js = VALUE_GENERATORS_JS.value

Expand Down Expand Up @@ -211,20 +213,27 @@ def get(self, exploration_id):
'INTERACTION_SPECS': interaction_registry.Registry.get_all_specs(),
'additional_angular_modules': additional_angular_modules,
'can_delete': rights_manager.Actor(
self.user_id).can_delete(exploration_id),
self.user_id).can_delete(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_edit': can_edit,
'can_modify_roles': rights_manager.Actor(
self.user_id).can_modify_roles(exploration_id),
self.user_id).can_modify_roles(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_publicize': rights_manager.Actor(
self.user_id).can_publicize(exploration_id),
'can_publish': rights_manager.Actor(self.user_id).can_publish(
exploration_id),
self.user_id).can_publicize(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_publish': rights_manager.Actor(
self.user_id).can_publish(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_release_ownership': rights_manager.Actor(
self.user_id).can_release_ownership(exploration_id),
self.user_id).can_release_ownership(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_unpublicize': rights_manager.Actor(
self.user_id).can_unpublicize(exploration_id),
'can_unpublish': rights_manager.Actor(self.user_id).can_unpublish(
exploration_id),
self.user_id).can_unpublicize(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'can_unpublish': rights_manager.Actor(
self.user_id).can_unpublish(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id),
'dependencies_html': jinja2.utils.Markup(dependencies_html),
'gadget_templates': jinja2.utils.Markup(gadget_templates),
'interaction_templates': jinja2.utils.Markup(
Expand Down Expand Up @@ -304,7 +313,8 @@ def _get_exploration_data(self, exploration_id, version=None):

def get(self, exploration_id):
"""Gets the data for the exploration overview page."""
if not rights_manager.Actor(self.user_id).can_view(exploration_id):
if not rights_manager.Actor(self.user_id).can_view(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id):
raise self.PageNotFoundException

version = self.request.get('v', default_value=None)
Expand Down Expand Up @@ -363,7 +373,7 @@ def delete(self, exploration_id):

exploration = exp_services.get_exploration_by_id(exploration_id)
can_delete = rights_manager.Actor(self.user_id).can_delete(
exploration.id)
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration.id)
if not can_delete:
raise self.UnauthorizedUserException(
'User %s does not have permissions to delete exploration %s' %
Expand Down Expand Up @@ -399,8 +409,9 @@ def put(self, exploration_id):
viewable_if_private = self.payload.get('viewable_if_private')

if new_member_username:
if not rights_manager.Actor(self.user_id).can_modify_roles(
exploration_id):
if not rights_manager.Actor(
self.user_id).can_modify_roles(
rights_manager.ACTIVITY_TYPE_EXPLORATION, exploration_id):
raise self.UnauthorizedUserException(
'Only an owner of this exploration can add or change '
'roles.')
Expand All @@ -411,7 +422,7 @@ def put(self, exploration_id):
raise Exception(
'Sorry, we could not find the specified user.')

rights_manager.assign_role(
rights_manager.assign_role_for_exploration(
self.user_id, exploration_id, new_member_id, new_member_role)

elif is_public is not None:
Expand Down Expand Up @@ -452,10 +463,11 @@ def put(self, exploration_id):
except utils.ValidationError as e:
raise self.InvalidInputException(e)

rights_manager.release_ownership(self.user_id, exploration_id)
rights_manager.release_ownership_of_exploration(
self.user_id, exploration_id)

elif viewable_if_private is not None:
rights_manager.set_private_viewability(
rights_manager.set_private_viewability_of_exploration(
self.user_id, exploration_id, viewable_if_private)

else:
Expand Down
26 changes: 14 additions & 12 deletions core/controllers/editor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ def assert_cannot_edit(self, response_body):

class EditorTest(BaseEditorControllerTest):

def setUp(self):
super(EditorTest, self).setUp()
exp_services.load_demo('0')
rights_manager.release_ownership_of_exploration(
feconf.SYSTEM_COMMITTER_ID, '0')

def test_editor_page(self):
"""Test access to editor pages for the sample exploration."""
exp_services.delete_demo('0')
exp_services.load_demo('0')

# Check that non-editors can access, but not edit, the editor page.
response = self.testapp.get('/create/0')
Expand All @@ -93,7 +97,7 @@ def test_editor_page(self):

def test_new_state_template(self):
"""Test the validity of the NEW_STATE_TEMPLATE."""
exp_services.load_demo('0')

exploration = exp_services.get_exploration_by_id('0')
exploration.add_states([feconf.DEFAULT_INIT_STATE_NAME])
new_state_dict = exploration.states[
Expand All @@ -103,8 +107,6 @@ def test_new_state_template(self):

def test_add_new_state_error_cases(self):
"""Test the error cases for adding a new state to an exploration."""
exp_services.delete_demo('0')
exp_services.load_demo('0')
CURRENT_VERSION = 1

self.login(self.EDITOR_EMAIL)
Expand Down Expand Up @@ -175,9 +177,6 @@ def _put_and_expect_400_error(payload):
self.logout()

def test_resolved_answers_handler(self):
exp_services.delete_demo('0')
exp_services.load_demo('0')

# In the reader perspective, submit the first multiple-choice answer,
# then submit 'blah' once, 'blah2' twice and 'blah3' three times.
# TODO(sll): Use the ExplorationPlayer in reader_test for this.
Expand Down Expand Up @@ -440,7 +439,7 @@ def test_deletion_rights_for_unpublished_exploration(self):
UNPUBLISHED_EXP_ID, 'A title', 'A category')
exp_services.save_new_exploration(self.owner_id, exploration)

rights_manager.assign_role(
rights_manager.assign_role_for_exploration(
self.owner_id, UNPUBLISHED_EXP_ID, self.editor_id,
rights_manager.ROLE_EDITOR)

Expand Down Expand Up @@ -469,7 +468,7 @@ def test_deletion_rights_for_published_exploration(self):
PUBLISHED_EXP_ID, 'A title', 'A category')
exp_services.save_new_exploration(self.owner_id, exploration)

rights_manager.assign_role(
rights_manager.assign_role_for_exploration(
self.owner_id, PUBLISHED_EXP_ID, self.editor_id,
rights_manager.ROLE_EDITOR)
rights_manager.publish_exploration(self.owner_id, PUBLISHED_EXP_ID)
Expand Down Expand Up @@ -508,8 +507,9 @@ def setUp(self):

self.EXP_ID = '0'

exp_services.delete_demo(self.EXP_ID)
exp_services.load_demo(self.EXP_ID)
rights_manager.release_ownership_of_exploration(
feconf.SYSTEM_COMMITTER_ID, self.EXP_ID)

self.login(self.EDITOR_EMAIL)

Expand Down Expand Up @@ -622,9 +622,11 @@ class ExplorationEditRightsTest(BaseEditorControllerTest):

def test_user_banning(self):
"""Test that banned users are banned."""

EXP_ID = '0'
exp_services.delete_demo(EXP_ID)
exp_services.load_demo(EXP_ID)
rights_manager.release_ownership_of_exploration(
feconf.SYSTEM_COMMITTER_ID, EXP_ID)

# Sign-up new editors Joe and Sandra.
self.signup('joe@example.com', 'joe')
Expand Down
1 change: 0 additions & 1 deletion core/controllers/galleries.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from core.domain import exp_domain
from core.domain import exp_jobs
from core.domain import exp_services
from core.domain import rights_manager
from core.domain import user_services
from core.platform import models
(base_models, exp_models,) = models.Registry.import_models([
Expand Down
10 changes: 5 additions & 5 deletions core/controllers/galleries_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_gallery_handler_demo_exploration(self):
'title': 'Welcome to Oppia!',
'language_code': 'en',
'objective': 'become familiar with Oppia\'s capabilities',
'status': rights_manager.EXPLORATION_STATUS_PUBLIC,
'status': rights_manager.ACTIVITY_STATUS_PUBLIC,
}, response_dict['explorations_list'][0])

# Publicize the demo exploration.
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_gallery_handler_demo_exploration(self):
'title': 'A new title!',
'language_code': 'en',
'objective': 'become familiar with Oppia\'s capabilities',
'status': rights_manager.EXPLORATION_STATUS_PUBLICIZED,
'status': rights_manager.ACTIVITY_STATUS_PUBLICIZED,
}, response_dict['explorations_list'][0])

def test_gallery_handler_for_created_explorations(self):
Expand Down Expand Up @@ -163,15 +163,15 @@ def test_gallery_handler_for_created_explorations(self):
'title': 'Title B',
'language_code': 'en',
'objective': 'Objective B',
'status': rights_manager.EXPLORATION_STATUS_PUBLICIZED,
'status': rights_manager.ACTIVITY_STATUS_PUBLICIZED,
}, response_dict['explorations_list'][0])
self.assertDictContainsSubset({
'id': 'A',
'category': 'Category A',
'title': 'Title A',
'language_code': 'en',
'objective': 'Objective A',
'status': rights_manager.EXPLORATION_STATUS_PUBLIC,
'status': rights_manager.ACTIVITY_STATUS_PUBLIC,
}, response_dict['explorations_list'][1])

# Delete exploration A
Expand All @@ -186,7 +186,7 @@ def test_gallery_handler_for_created_explorations(self):
'title': 'Title B',
'language_code': 'en',
'objective': 'Objective B',
'status': rights_manager.EXPLORATION_STATUS_PUBLICIZED,
'status': rights_manager.ACTIVITY_STATUS_PUBLICIZED,
}, response_dict['explorations_list'][0])

def test_new_exploration_ids(self):
Expand Down
16 changes: 8 additions & 8 deletions core/controllers/home_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,27 @@ def test_managers_can_see_explorations(self):
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PRIVATE)
rights_manager.ACTIVITY_STATUS_PRIVATE)

rights_manager.publish_exploration(self.owner_id, self.EXP_ID)
response = self.get_json(self.MY_EXPLORATIONS_DATA_URL)
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PUBLIC)
rights_manager.ACTIVITY_STATUS_PUBLIC)

rights_manager.publicize_exploration(self.owner_id, self.EXP_ID)
response = self.get_json(self.MY_EXPLORATIONS_DATA_URL)
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PUBLICIZED)
rights_manager.ACTIVITY_STATUS_PUBLICIZED)
self.logout()

def test_collaborators_can_see_explorations(self):
self.save_new_default_exploration(
self.EXP_ID, self.owner_id, title=self.EXP_TITLE)
rights_manager.assign_role(
rights_manager.assign_role_for_exploration(
self.owner_id, self.EXP_ID, self.collaborator_id,
rights_manager.ROLE_EDITOR)
self.set_admins([self.OWNER_EMAIL])
Expand All @@ -129,28 +129,28 @@ def test_collaborators_can_see_explorations(self):
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PRIVATE)
rights_manager.ACTIVITY_STATUS_PRIVATE)

rights_manager.publish_exploration(self.owner_id, self.EXP_ID)
response = self.get_json(self.MY_EXPLORATIONS_DATA_URL)
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PUBLIC)
rights_manager.ACTIVITY_STATUS_PUBLIC)

rights_manager.publicize_exploration(self.owner_id, self.EXP_ID)
response = self.get_json(self.MY_EXPLORATIONS_DATA_URL)
self.assertEqual(len(response['explorations_list']), 1)
self.assertEqual(
response['explorations_list'][0]['status'],
rights_manager.EXPLORATION_STATUS_PUBLICIZED)
rights_manager.ACTIVITY_STATUS_PUBLICIZED)

self.logout()

def test_viewer_cannot_see_explorations(self):
self.save_new_default_exploration(
self.EXP_ID, self.owner_id, title=self.EXP_TITLE)
rights_manager.assign_role(
rights_manager.assign_role_for_exploration(
self.owner_id, self.EXP_ID, self.viewer_id,
rights_manager.ROLE_VIEWER)
self.set_admins([self.OWNER_EMAIL])
Expand Down
Loading