コード例 #1
0
 def get(self):
     if (self.user_id and
             self.username not in config_domain.BANNED_USERNAMES.value and
             user_services.has_user_registered_as_editor(self.user_id)):
         self.render_template('dashboard/dashboard.html')
     else:
         self._get_splash_page()
コード例 #2
0
ファイル: home.py プロジェクト: directorlive/oppia
 def get(self):
     if self.username in config_domain.BANNED_USERNAMES.value:
         raise self.UnauthorizedUserException("You do not have the credentials to access this page.")
     elif user_services.has_user_registered_as_editor(self.user_id):
         self.values.update({"nav_mode": feconf.NAV_MODE_HOME})
         self.render_template("dashboard/my_explorations.html", redirect_url_on_logout="/")
     else:
         self.redirect(utils.set_url_query_parameter(feconf.SIGNUP_URL, "return_url", "/my_explorations"))
コード例 #3
0
ファイル: base.py プロジェクト: tdtshafer/oppia
    def test_registered_as_editor(self, **kwargs):
        """Check that the user has registered as an editor."""
        if (not self.user_id
                or self.username in config_domain.BANNED_USERNAMES.value or
                not user_services.has_user_registered_as_editor(self.user_id)):
            raise self.UnauthorizedUserException(
                'You do not have the credentials to access this page.')

        return handler(self, **kwargs)
コード例 #4
0
    def test_editor(self, exploration_id, escaped_state_name=None, **kwargs):
        """Gets the user and exploration id if the user can edit it.

        Args:
            self: the handler instance
            exploration_id: the exploration id
            escaped_state_name: the URL-escaped state name, if it exists
            **kwargs: any other arguments passed to the handler

        Returns:
            The relevant handler, if the user is authorized to edit this
            exploration.

        Raises:
            self.PageNotFoundException: if no such exploration or state exists.
            self.UnauthorizedUserException: if the user exists but does not
                have the right credentials.
        """
        if not self.user_id:
            self.redirect(current_user_services.create_login_url(
                self.request.uri))
            return

        if self.username in config_domain.BANNED_USERNAMES.value:
            raise self.UnauthorizedUserException(
                'You do not have the credentials to access this page.')

        redirect_url = feconf.EDITOR_PREREQUISITES_URL

        if not user_services.has_user_registered_as_editor(self.user_id):
            redirect_url = utils.set_url_query_parameter(
                redirect_url, 'return_url', self.request.uri)
            self.redirect(redirect_url)
            return

        try:
            exploration = exp_services.get_exploration_by_id(exploration_id)
        except:
            raise self.PageNotFoundException

        if not (rights_manager.Actor(self.user_id).can_edit(exploration_id) or
                self.is_super_admin):
            raise self.UnauthorizedUserException(
                'You do not have the credentials to edit this exploration.',
                self.user_id)

        if not escaped_state_name:
            return handler(self, exploration_id, **kwargs)

        state_name = self.unescape_state_name(escaped_state_name)
        if state_name not in exploration.states:
            logging.error('Could not find state: %s' % state_name)
            logging.error('Available states: %s' % exploration.states.keys())
            raise self.PageNotFoundException

        return handler(self, exploration_id, state_name, **kwargs)
コード例 #5
0
ファイル: editor.py プロジェクト: sunu/oh-missions-oppia-beta
    def test_editor(self, exploration_id, escaped_state_name=None, **kwargs):
        """Gets the user and exploration id if the user can edit it.

        Args:
            self: the handler instance
            exploration_id: the exploration id
            escaped_state_name: the URL-escaped state name, if it exists
            **kwargs: any other arguments passed to the handler

        Returns:
            The relevant handler, if the user is authorized to edit this
            exploration.

        Raises:
            self.PageNotFoundException: if no such exploration or state exists.
            self.UnauthorizedUserException: if the user exists but does not
                have the right credentials.
        """
        if not self.user_id:
            self.redirect(
                current_user_services.create_login_url(self.request.uri))
            return

        if self.username in config_domain.BANNED_USERNAMES.value:
            raise self.UnauthorizedUserException(
                'You do not have the credentials to access this page.')

        redirect_url = feconf.EDITOR_PREREQUISITES_URL

        if not user_services.has_user_registered_as_editor(self.user_id):
            redirect_url = utils.set_url_query_parameter(
                redirect_url, 'return_url', self.request.uri)
            self.redirect(redirect_url)
            return

        try:
            exploration = exp_services.get_exploration_by_id(exploration_id)
        except:
            raise self.PageNotFoundException

        if not (rights_manager.Actor(self.user_id).can_edit(exploration_id)
                or self.is_super_admin):
            raise self.UnauthorizedUserException(
                'You do not have the credentials to edit this exploration.',
                self.user_id)

        if not escaped_state_name:
            return handler(self, exploration_id, **kwargs)

        state_name = self.unescape_state_name(escaped_state_name)
        if state_name not in exploration.states:
            logging.error('Could not find state: %s' % state_name)
            logging.error('Available states: %s' % exploration.states.keys())
            raise self.PageNotFoundException

        return handler(self, exploration_id, state_name, **kwargs)
コード例 #6
0
ファイル: base.py プロジェクト: nachi11/oppia
    def test_registered_as_editor(self, **kwargs):
        """Check that the user has registered as an editor."""
        if (
            not self.user_id
            or self.username in config_domain.BANNED_USERNAMES.value
            or not user_services.has_user_registered_as_editor(self.user_id)
        ):
            raise self.UnauthorizedUserException("You do not have the credentials to access this page.")

        return handler(self, **kwargs)
コード例 #7
0
ファイル: home.py プロジェクト: Cgruppo/oppia
 def get(self):
     if self.username in config_domain.BANNED_USERNAMES.value:
         raise self.UnauthorizedUserException(
             'You do not have the credentials to access this page.')
     elif user_services.has_user_registered_as_editor(self.user_id):
         self.values.update({
             'nav_mode': feconf.NAV_MODE_HOME,
         })
         self.render_template(
             'dashboard/timeline.html', redirect_url_on_logout='/')
     else:
         self.redirect(utils.set_url_query_parameter(
             feconf.SIGNUP_URL, 'return_url', '/timeline'))
コード例 #8
0
 def get(self):
     if self.username in config_domain.BANNED_USERNAMES.value:
         raise self.UnauthorizedUserException(
             'You do not have the credentials to access this page.')
     elif user_services.has_user_registered_as_editor(self.user_id):
         self.values.update({
             'nav_mode': feconf.NAV_MODE_HOME,
         })
         self.render_template(
             'dashboard/my_explorations.html', redirect_url_on_logout='/')
     else:
         self.redirect(utils.set_url_query_parameter(
             feconf.SIGNUP_URL, 'return_url', '/my_explorations'))
コード例 #9
0
    def test_registered_as_editor(self, **kwargs):
        """Check that the user has registered as an editor."""
        if not self.user_id:
            self.redirect(
                current_user_services.create_login_url(self.request.uri))
            return

        if self.username in config_domain.BANNED_USERNAMES.value:
            raise self.UnauthorizedUserException(
                'You do not have the credentials to access this page.')

        redirect_url = feconf.EDITOR_PREREQUISITES_URL

        if not user_services.has_user_registered_as_editor(self.user_id):
            redirect_url = utils.set_url_query_parameter(
                redirect_url, 'return_url', self.request.uri)
            self.redirect(redirect_url)
            return

        return handler(self, **kwargs)
コード例 #10
0
ファイル: base.py プロジェクト: miyucy/oppia
    def test_registered_as_editor(self, **kwargs):
        """Check that the user has registered as an editor."""
        if not self.user_id:
            self.redirect(current_user_services.create_login_url(
                self.request.uri))
            return

        if self.username in config_domain.BANNED_USERNAMES.value:
            raise self.UnauthorizedUserException(
                'You do not have the credentials to access this page.')

        redirect_url = feconf.EDITOR_PREREQUISITES_URL

        if not user_services.has_user_registered_as_editor(self.user_id):
            redirect_url = utils.set_url_query_parameter(
                redirect_url, 'return_url', self.request.uri)
            self.redirect(redirect_url)
            return

        return handler(self, **kwargs)
コード例 #11
0
ファイル: profile.py プロジェクト: tdtshafer/oppia
    def post(self):
        """Handles POST requests."""
        username = self.payload.get('username')
        agreed_to_terms = self.payload.get('agreed_to_terms')
        can_receive_email_updates = self.payload.get(
            'can_receive_email_updates')

        has_previously_registered = (
            user_services.has_user_registered_as_editor(self.user_id))

        if has_previously_registered:
            self.render_json({})
            return

        if not isinstance(agreed_to_terms, bool) or not agreed_to_terms:
            raise self.InvalidInputException(
                'In order to edit explorations on this site, you will '
                'need to accept the license terms.')
        else:
            user_services.record_agreement_to_terms(self.user_id)

        if not user_services.get_username(self.user_id):
            try:
                user_services.set_username(self.user_id, username)
            except utils.ValidationError as e:
                raise self.InvalidInputException(e)

        if can_receive_email_updates is not None:
            user_services.update_email_preferences(self.user_id,
                                                   can_receive_email_updates)

        # Note that an email is only sent when the user registers for the first
        # time.
        if feconf.CAN_SEND_EMAILS_TO_USERS:
            email_manager.send_post_signup_email(self.user_id)

        self.render_json({})
コード例 #12
0
ファイル: profile.py プロジェクト: makerscraft/oppia
    def post(self):
        """Handles POST requests."""
        username = self.payload.get('username')
        agreed_to_terms = self.payload.get('agreed_to_terms')
        can_receive_email_updates = self.payload.get(
            'can_receive_email_updates')

        has_previously_registered = (
            user_services.has_user_registered_as_editor(self.user_id))

        if has_previously_registered:
            self.render_json({})
            return

        if not isinstance(agreed_to_terms, bool) or not agreed_to_terms:
            raise self.InvalidInputException(
                'In order to edit explorations on this site, you will '
                'need to accept the license terms.')
        else:
            user_services.record_agreement_to_terms(self.user_id)

        if not user_services.get_username(self.user_id):
            try:
                user_services.set_username(self.user_id, username)
            except utils.ValidationError as e:
                raise self.InvalidInputException(e)

        if can_receive_email_updates is not None:
            user_services.update_email_preferences(
                self.user_id, can_receive_email_updates)

        # Note that an email is only sent when the user registers for the first
        # time.
        if feconf.CAN_SEND_EMAILS_TO_USERS:
            email_manager.send_post_signup_email(self.user_id)

        self.render_json({})
コード例 #13
0
ファイル: editor.py プロジェクト: miyucy/oppia
    def get(self, exploration_id):
        """Handles GET requests."""
        try:
            exp_services.get_exploration_by_id(exploration_id)
        except:
            raise self.PageNotFoundException

        if not rights_manager.Actor(self.user_id).can_view(exploration_id):
            raise self.PageNotFoundException

        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))

        if (can_edit and not
                user_services.has_user_registered_as_editor(self.user_id)):
            redirect_url = utils.set_url_query_parameter(
                feconf.EDITOR_PREREQUISITES_URL, 'return_url',
                self.request.uri)
            self.redirect(redirect_url)
            return

        # TODO(sll): Consider including the obj_generator html in a ng-template
        # to remove the need for an additional RPC?
        object_editors_js = OBJECT_EDITORS_JS.value
        value_generators_js = VALUE_GENERATORS_JS.value

        all_interactive_widget_ids = (
            widget_registry.Registry.get_widget_ids_of_type(
                feconf.INTERACTIVE_PREFIX))

        widget_dependency_ids = (
            widget_registry.Registry.get_deduplicated_dependency_ids(
                all_interactive_widget_ids))
        dependencies_html, additional_angular_modules = (
            dependency_registry.Registry.get_deps_html_and_angular_modules(
                widget_dependency_ids + self.EDITOR_PAGE_DEPENDENCY_IDS))

        widget_js_directives = (
            widget_registry.Registry.get_noninteractive_widget_js() +
            widget_registry.Registry.get_interactive_widget_js(
                all_interactive_widget_ids))

        self.values.update({
            'additional_angular_modules': additional_angular_modules,
            'announcement': jinja2.utils.Markup(
                EDITOR_PAGE_ANNOUNCEMENT.value),
            'can_delete': rights_manager.Actor(
                self.user_id).can_delete(exploration_id),
            'can_edit': can_edit,
            'can_modify_roles': rights_manager.Actor(
                self.user_id).can_modify_roles(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),
            'can_release_ownership': rights_manager.Actor(
                self.user_id).can_release_ownership(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),
            'dependencies_html': jinja2.utils.Markup(dependencies_html),
            'moderator_request_forum_url': MODERATOR_REQUEST_FORUM_URL.value,
            'nav_mode': feconf.NAV_MODE_CREATE,
            'object_editors_js': jinja2.utils.Markup(object_editors_js),
            'value_generators_js': jinja2.utils.Markup(value_generators_js),
            'widget_js_directives': jinja2.utils.Markup(widget_js_directives),            
            'SHOW_SKIN_CHOOSER': feconf.SHOW_SKIN_CHOOSER,
        })

        self.render_template('editor/exploration_editor.html')