Exemplo n.º 1
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = priority_group_logic

        new_params['name'] = "Priority Group"

        new_params['no_create_raw'] = True
        new_params['no_create_with_scope'] = True
        new_params['no_create_with_key_fields'] = True

        new_params['public_field_keys'] = ["link_id", "name", "priority"]
        new_params['public_field_names'] = ["Link ID", "Name", "Priority"]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 2
0
    def _checkHasStatisticAccess(self, statistic, params=None):
        """Checks that the user has access to the specified statistic.
    """

        logic = params['logic']

        id = accounts.getCurrentAccount()
        user = None
        if id:
            user = user_logic.getForAccount(id)

        checker = access.Checker(None)
        checker.setCurrentUser(id, user)

        access_type = statistic.read_access
        has_access = False

        minimal_rights = logic.ACCESS_TYPES.index(access_type)
        for item in logic.ACCESS_TYPES[minimal_rights:]:
            ref_logic = logic.helper.LOGICS_DICT[item]
            try:
                checker.checkHasActiveRole({}, ref_logic.logic)
                has_access = True
                break
            except Exception:
                pass

        return has_access
Exemplo n.º 3
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['edit'] = [('checkCanEditTimeline', [program_logic.logic])]

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = soc.logic.models.timeline.logic
        new_params['edit_template'] = 'soc/timeline/edit.html'
        new_params['name'] = "Timeline"

        patterns = [
            (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.edit', "Edit %(name_short)s")
        ]

        new_params['create_extra_dynaproperties'] = {
            'link_id': forms.CharField(widget=forms.HiddenInput)
        }
        new_params['django_patterns_defaults'] = patterns

        new_params['edit_dynaproperties'] = []

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 4
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['create'] = ['checkIsDeveloper']
        rights['edit'] = [('checkIsMyActiveRole', club_admin_logic.logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['invite'] = [('checkHasRoleForScope', club_admin_logic.logic)]
        rights['accept_invite'] = [('checkIsMyRequestWithStatus',
                                    [['group_accepted']])]
        rights['process_request'] = [('checkCanProcessRequest',
                                      [[club_admin_logic.logic]])]
        rights['manage'] = [('checkIsAllowedToManageRole',
                             [club_admin_logic.logic, club_admin_logic.logic])]

        new_params = {}
        new_params['logic'] = soc.logic.models.club_admin.logic
        new_params['group_logic'] = club_logic.logic
        new_params['group_view'] = club_view.view
        new_params['rights'] = rights

        new_params['scope_view'] = club_view

        new_params['name'] = "Club Admin"
        new_params['sidebar_grouping'] = 'Clubs'

        new_params['extra_dynaexclude'] = ['agreed_to_tos']

        new_params['allow_invites'] = True
        new_params['show_in_roles_overview'] = False

        new_params['public_field_keys'] = ["name", "link_id", "scope_path"]
        new_params['public_field_names'] = [
            "Admin Name", "Admin ID", "Club ID"
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)

        # register the role with the group_view
        self._params['group_view'].registerRole(self._logic.role_name, self)

        # create and store the special form for invited users
        updated_fields = {
            'link_id':
            forms.CharField(widget=widgets.ReadOnlyInput(), required=False)
        }

        invited_create_form = dynaform.extendDynaForm(
            dynaform=self._params['create_form'],
            dynaproperties=updated_fields)

        self._params['invited_create_form'] = invited_create_form
Exemplo n.º 5
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
      comment_on_name: e.g. 'Document'
      comment_on_url_name: e.g. 'document'
    """

        rights = access.Checker(params)
        rights['create'] = [('checkSeeded',
                             ['checkIsDocumentReadable', 'scope_path'])]
        rights['edit'] = [('checkIsMyEntity', [comment_logic, 'author', True])]
        rights['delete'] = [('checkIsMyEntity',
                             [comment_logic, 'author', True])]

        new_params = {}
        new_params['logic'] = comment_logic
        new_params['rights'] = rights

        new_params['name'] = "Comment"

        new_params['create_template'] = 'soc/comment/edit.html'
        new_params['edit_template'] = 'soc/comment/edit.html'

        new_params['no_show'] = True
        new_params['no_admin'] = True
        new_params['no_create_raw'] = True
        new_params['no_create_with_key_fields'] = True
        new_params['no_list_raw'] = True

        new_params['create_extra_dynaproperties'] = {
            'on':
            forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
                                   required=False),
            'content':
            forms.fields.CharField(widget=helper.widgets.TinyMCE(attrs={
                'rows': 10,
                'cols': 40
            })),
            'scope_path':
            forms.CharField(widget=forms.HiddenInput, required=True),
        }
        new_params['extra_dynaexclude'] = ['author', 'link_id', 'modified_by']

        new_params['edit_extra_dynaproperties'] = {
            'link_id':
            forms.CharField(widget=forms.HiddenInput, required=True),
            'created_by':
            forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
                                   required=False),
        }

        params = dicts.merge(params, new_params)
        super(View, self).__init__(params=params)
Exemplo n.º 6
0
  def __init__(self, params):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['home'] = ['allow']

    new_params = {}
    new_params['rights'] = rights

    new_params['extra_dynaexclude'] = ['home']
    new_params['home_template'] = 'soc/presence/home.html'

    new_params['create_extra_dynaproperties'] = {
        # add cleaning of the link id and feed url
        'clean_link_id': cleaning.clean_link_id('link_id'),
        'clean_feed_url': cleaning.clean_feed_url('feed_url'),
        }

    new_params['edit_extra_dynaproperties'] = {
        'home_link_id': widgets.ReferenceField(
            reference_url='document', filter=['__scoped__'],
            filter_fields={'prefix': params['document_prefix']},
            required=False, label=ugettext('Home page Document link ID'),
            help_text=soc.models.work.Work.link_id.help_text,
            group=ugettext("1. Public Info")),
    }

    patterns = []

    page_name = "Home"
    patterns += [(r'^%(url_name)s/(?P<access_type>home)/%(key_fields)s$',
                  '%(module_package)s.%(module_name)s.home',
                  page_name)]

    new_params['extra_django_patterns'] = patterns

    new_params['public_field_prefetch'] = ['home']
    new_params['public_field_extra'] = lambda entity: {
        "path": entity.scope_path + '/' + entity.link_id if
            entity.scope_path else entity.link_id,
        "home": entity.home.title if entity.home else "",
    }
    new_params['public_field_keys'] = ["path", "home"]
    new_params['public_field_names'] = ["Path", "Home Document"]

    params = dicts.merge(params, new_params, sub_merge=True)

    super(View, self).__init__(params=params)
Exemplo n.º 7
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['unspecified'] = ['deny']
        rights['edit'] = ['deny']
        rights['show'] = [('checkIsMyEntity',
                           [notification_logic, 'scope_path'])]
        rights['delete'] = [('checkIsMyEntity',
                             [notification_logic, 'scope_path'])]
        rights['list'] = ['checkIsUser']
        # create is developer only for the time being to test functionality
        rights['create'] = ['checkIsDeveloper']

        new_params = {}
        new_params['logic'] = notification_logic
        new_params['rights'] = rights

        new_params['name'] = "Notification"

        new_params['no_create_with_key_fields'] = True
        new_params['create_form'] = CreateForm

        new_params['edit_redirect'] = '/%(url_name)s/list'

        new_params['list_template'] = 'soc/notification/list/notification.html'

        site_name = site_logic.getSingleton().site_name

        new_params['public_configuration'] = {"multiselect": True}
        new_params['public_field_extra'] = lambda entity: {
            "from": entity.from_user.name if entity.from_user else site_name,
        }
        new_params['public_field_keys'] = [
            "unread",
            "from",
            "subject",
            "created_on",
        ]
        new_params['public_field_names'] = [
            "Unread", "From", "Subject", "Received on"
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 8
0
    def __init__(self):
        """
    """

        rights = access.Checker(None)
        rights['unspecified'] = ['deny']
        rights['any_access'] = ['allow']
        rights['show'] = ['allow']

        params = {}
        params['name'] = "Test"
        params['logic'] = TestModelLogic()
        params['rights'] = rights

        super(TestView, self).__init__(params=params)
Exemplo n.º 9
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['create'] = ['checkIsDeveloper']
        rights['edit'] = [('checkHasRoleForLinkIdAsScope', host_logic),
                          ('checkGroupIsActiveForLinkId', sponsor_logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['home'] = [('checkHasRoleForScope', host_logic)]
        rights['list'] = ['checkIsDeveloper']
        rights['list_requests'] = [('checkHasRoleForLinkIdAsScope', host_logic)
                                   ]
        rights['list_roles'] = [('checkHasRoleForLinkIdAsScope', host_logic)]

        new_params = {}
        new_params['logic'] = soc.logic.models.sponsor.logic
        new_params['rights'] = rights

        new_params['name'] = "Program Owner"
        new_params['module_name'] = "sponsor"
        new_params['document_prefix'] = "sponsor"
        new_params['sidebar_grouping'] = 'Programs'

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Sponsor Link ID',
            },
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 10
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = priority_group_logic

        new_params['name'] = "Cron"

        new_params['django_patterns_defaults'] = [
            (r'^%(url_name)s/(?P<access_type>poke)$',
             'soc.views.models.%(module_name)s.poke', 'Poke %(name_short)s'),
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 11
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)

    new_params = {}
    new_params['rights'] = rights
    new_params['logic'] = job_logic

    new_params['name'] = "Job"

    new_params['no_create_raw'] = True
    new_params['no_create_with_scope'] = True
    new_params['no_create_with_key_fields'] = True

    new_params['extra_dynaexclude'] = ['key_data', 'text_data']

    new_params['edit_dynaproperties'] = {
      'task': forms.CharField(widget=widgets.PlainTextWidget()),
      }

    new_params['public_field_extra'] = lambda entity: {
        "id": entity.key().id_or_name(),
        "priority_group": entity.priority_group.name,
    }
    new_params['public_field_keys'] = ["id", "task_name", "priority_group"]
    new_params['public_field_names'] = ["ID", "Name", "Priority Group"]

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
Exemplo n.º 12
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['edit'] = ['deny']
        rights['show'] = [('checkIsMyEntity',
                           [notification_logic, 'scope_path'])]
        rights['delete'] = [('checkIsMyEntity',
                             [notification_logic, 'scope_path'])]
        rights['list'] = ['checkIsUser']
        # create is developer only for the time being to test functionality
        rights['create'] = ['checkIsDeveloper']

        new_params = {}
        new_params['logic'] = notification_logic
        new_params['rights'] = rights

        new_params['name'] = "Notification"

        new_params['no_create_with_key_fields'] = True
        new_params['create_form'] = CreateForm

        new_params['edit_redirect'] = '/%(url_name)s/list'

        new_params['public_configuration'] = {"multiselect": True}
        new_params['public_field_prefetch'] = ['from_user']
        new_params['public_field_extra'] = lambda entity: {
            "from":
            entity.from_user.name
            if entity.from_user else site_logic.getSingleton().site_name,
            "unread":
            "Not Read" if entity.unread else "Read",
        }
        new_params['public_field_props'] = {
            "unread": {
                "stype": "select",
                "editoptions": {
                    "value": ":All;^Read$:Read;^Not Read$:Not Read"
                }
            }
        }
        new_params['public_conf_extra'] = {
            "multiselect": True,
        }
        new_params['public_field_keys'] = [
            "unread",
            "from",
            "subject",
            "created_on",
        ]
        new_params['public_field_names'] = [
            "Unread", "From", "Subject", "Received on"
        ]
        new_params['public_button_global'] = [{
            'bounds': [1, 'all'],
            'id': 'mark_read',
            'caption': 'Mark as Read',
            'type': 'post',
            'parameters': {
                'url': '',
                'keys': ['key'],
                'refresh': 'current',
            }
        }, {
            'bounds': [1, 'all'],
            'id': 'mark_unread',
            'caption': 'Mark as Unread',
            'type': 'post',
            'parameters': {
                'url': '',
                'keys': ['key'],
                'refresh': 'current',
            }
        }, {
            'bounds': [1, 'all'],
            'id': 'delete',
            'caption': 'Delete Notification',
            'type': 'post',
            'parameters': {
                'url': '',
                'keys': ['key'],
                'refresh': 'current',
            }
        }]

        params = dicts.merge(params, new_params)

        params['public_row_extra'] = lambda entity: {
            "link": redirects.getPublicRedirect(entity, params)
        }

        super(View, self).__init__(params=params)
Exemplo n.º 13
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = ['checkIsDeveloper']
    rights['delete'] = ['checkIsDeveloper']
    rights['show'] = ['allow']
    rights['list'] = ['checkIsDeveloper']
    rights['list_developers'] = ['checkIsDeveloper']

    new_params = {}
    new_params['logic'] = soc.logic.models.user.logic
    new_params['rights'] = rights
    
    new_params['name'] = "User"

    new_params['edit_template'] = 'soc/user/edit.html'
    new_params['pickable'] = True
    new_params['cache_pick'] = True

    new_params['sidebar_heading'] = 'Users'

    new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos',
        'agreed_to_tos_on', 'status']
    new_params['create_extra_dynaproperties'] = {
        'clean_link_id': cleaning.clean_user_not_exist('link_id'),
        'clean_account': cleaning.clean_user_account_not_in_use('account')}

    # recreate the choices for the edit form
    status_choices = []
    for choice in user_logic.getModel().status.choices:
      status_choices.append((choice, choice))

    new_params['edit_extra_dynaproperties'] = {
        'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
            required=True),
        'clean_link_id': cleaning.clean_link_id('link_id'),
        'agreed_to_tos_on': forms.DateTimeField(
            widget=widgets.ReadOnlyInput(attrs={'disabled':'true'}),
            required=False),
        'status': forms.ChoiceField(choices=status_choices),
        'clean_account': cleaning.clean_user_account('account'),
        'clean': cleaning.validate_user_edit('link_id', 'account'),
    }

    patterns = []

    patterns += [(r'^%(url_name)s/(?P<access_type>list_developers)$',
                  'soc.views.models.%(module_name)s.list_developers', 
                  "List Developers")]

    new_params['extra_django_patterns'] = patterns

    new_params['sidebar_developer'] = [('/%s/list_developers', 'List Developers',
                                        'list_developers')]

    new_params['public_field_prefetch'] = ['account']
    new_params['public_field_extra'] = lambda entity: {
        "email": entity.account.email(),
    }
    new_params['public_field_keys'] = ['email', 'name', 'link_id']
    new_params['public_field_names'] = ['Email', 'Public name', 'Link ID']

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
Exemplo n.º 14
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      original_params: a dict with params for this View
    """

    from soc.views.models import program as program_view

    rights = access.Checker(params)
    rights['any_access'] = ['allow']
    rights['show'] = ['allow']
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkHasRoleForKeyFieldsAsScope',
                           org_admin_logic.logic,),
                      ('checkGroupIsActiveForLinkId', org_logic.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['home'] = ['allow']
    rights['public_list'] = ['allow']
    rights['apply_mentor'] = ['checkIsUser']
    rights['list_requests'] = [('checkHasRoleForKeyFieldsAsScope',
                                org_admin_logic.logic)]
    rights['list_roles'] = [('checkHasRoleForKeyFieldsAsScope',
                             org_admin_logic.logic)]

    new_params = {}
    new_params['logic'] = soc.logic.models.organization.logic
    new_params['rights'] = rights

    new_params['scope_view'] = program_view
    new_params['scope_redirect'] = redirects.getCreateRedirect

    new_params['name'] = "Organization"
    new_params['url_name'] = "org"
    new_params['document_prefix'] = "org"
    new_params['sidebar_grouping'] = 'Organizations'

    new_params['public_template'] = 'soc/organization/public.html'
    new_params['home_template'] = 'soc/organization/home.html'

    new_params['sans_link_id_public_list'] = True

    patterns = []

    patterns += [
        (r'^%(url_name)s/(?P<access_type>apply_mentor)/%(scope)s$',
        '%(module_package)s.%(module_name)s.apply_mentor',
        "List of all %(name_plural)s you can apply to"),
        (r'^%(url_name)s/(?P<access_type>list_proposals)/%(key_fields)s$',
        '%(module_package)s.%(module_name)s.list_proposals',
        "List of all Student Proposals for "),
        (r'^%(url_name)s/(?P<access_type>applicant)/%(scope)s$',
        '%(module_package)s.%(module_name)s.applicant', 
        "%(name)s Creation via Accepted Application"),
        ]

    new_params['extra_django_patterns'] = patterns

    new_params['create_dynafields'] = [
        {'name': 'link_id',
         'base': forms.fields.CharField,
         'label': 'Organization Link ID',
         },
        ]

    new_params['create_extra_dynaproperties'] = {
        'scope_path': forms.CharField(widget=forms.HiddenInput,
                                   required=True),
        'description': forms.fields.CharField(
            widget=helper.widgets.FullTinyMCE(
                attrs={'rows': 25, 'cols': 100})),
        'clean_description': cleaning.clean_html_content('description'),
        'clean_ideas': cleaning.clean_url('ideas'),
        'clean': cleaning.validate_new_group('link_id', 'scope_path',
            soc.logic.models.organization),
        }

    new_params['edit_extra_dynaproperties'] = {
        'clean': cleaning.clean_refs(params if params else new_params,
                                     ['home_link_id'])
        }

    new_params['public_field_extra'] = lambda entity: {
        'ideas': lists.urlize(entity.ideas, 'Click Here'),
    }

    params = dicts.merge(params, new_params, sub_merge=True)

    super(View, self).__init__(params=params)

    self._params['public_field_keys'] = self._params['select_field_keys'] = [
        "name", "link_id", "short_name", "ideas"
    ]
    self._params['public_field_names'] = self._params['select_field_names'] = [
        "Name", "Link ID", "Short Name", "Ideas Page"
    ]
    self._params['select_field_extra'] = self._params['public_field_extra']
    self._params['select_row_action'] = {
        "type": "redirect_custom",
        "parameters": dict(new_window=True),
    }
    self._params['select_row_extra'] = lambda entity: {
        "link": redirects.getRequestRedirectForRole(
            entity, params['mentor_url_name'])
    }
Exemplo n.º 15
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['listSelf'] = ['checkIsUser']
        rights['create'] = ['deny']
        rights['edit'] = ['checkIsDeveloper']
        rights['process_invite'] = [('checkIsMyRequestWithStatus',
                                     [['group_accepted']])]
        rights['list'] = ['checkIsDeveloper']
        rights['delete'] = ['checkIsDeveloper']
        rights['roles'] = ['checkIsUser']

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = request_logic

        new_params['name'] = "Request"

        new_params['sidebar_developer'] = [('/%s/list', 'List %(name_plural)s',
                                            'list')]

        new_params['create_template'] = ['soc/request/create.html']

        new_params['extra_dynaexclude'] = ['user', 'role', 'group', 'status']

        patterns = [
            (r'^%(url_name)s/(?P<access_type>process_invite)/(?P<id>[0-9]*)$',
             'soc.views.models.%(module_name)s.process_invite',
             'Process Invite to become')
        ]

        new_params['extra_django_patterns'] = patterns

        new_params[
            'invite_processing_template'] = 'soc/request/process_invite.html'
        new_params['request_processing_template'] = \
            'soc/request/process_request.html'

        new_params['public_field_extra'] = lambda entity: {
            "user": "******" % (entity.user.name, entity.user.link_id),
            "for": entity.group.name,
        }
        new_params['public_field_keys'] = [
            "role", "user", "for", "status", "created_on"
        ]
        new_params['public_field_names'] = [
            "Role", "User", "For", "Status", "Created On"
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)

        # create and store the special forms for invite and requests
        self._params['request_form'] = self._params['create_form']

        updated_fields = {
            'user_id': widgets.ReferenceField(reference_url='user'),
            'clean_user_id': cleaning.clean_existing_user('user_id'),
        }

        invite_form = dynaform.extendDynaForm(
            dynaform=self._params['create_form'],
            dynaproperties=updated_fields)
        # reverse the fields so that user_id field comes first
        invite_form.base_fields.keyOrder.reverse()

        self._params['invite_form'] = invite_form
Exemplo n.º 16
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkIsMyActiveRole', soc.logic.models.mentor.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasRoleForScope',
                         soc.logic.models.org_admin.logic)]
    rights['accept_invite'] = [
        ('checkIsMyRequestWithStatus', [['group_accepted']]),
        ('checkIsNotStudentForProgramOfOrgInRequest',[org_logic.logic,
                                                      student_logic.logic])]
    rights['request'] = [
        ('checkIsNotStudentForProgramOfOrg',
            [org_logic.logic, student_logic.logic]),
        ('checkCanMakeRequestToGroup', org_logic.logic)]
    rights['process_request'] = [
        ('checkCanProcessRequest', [[soc.logic.models.org_admin.logic]])]
    rights['manage'] = [
        ('checkIsAllowedToManageRole', [soc.logic.models.mentor.logic,
             soc.logic.models.org_admin.logic])]

    new_params = {}
    new_params['logic'] = soc.logic.models.mentor.logic
    new_params['group_logic'] = org_logic.logic
    new_params['group_view'] = org_view.view
    new_params['rights'] = rights
    new_params['pickable'] = True
    new_params['cache_pick_order'] = ['link_id', 'name']

    new_params['scope_view'] = org_view

    new_params['name'] = "Mentor"
    new_params['module_name'] = "mentor"
    new_params['sidebar_grouping'] = 'Organizations'

    new_params['extra_dynaexclude'] = ['agreed_to_tos', 'program']

    new_params['create_dynafields'] = [
        {'name': 'scope_path',
         'base': forms.fields.CharField,
         'widget': forms.HiddenInput,
         'required': True,
         },
        {'name': 'mentor_agreement',
         'base': forms.fields.CharField,
         'required': False,
         'widget': widgets.AgreementField,
         'group': ugettext("5. Terms of Service"),
         },
        {'name': 'agreed_to_mentor_agreement',
         'base': forms.fields.BooleanField,
         'initial': False,
         'required':True,
         'label': ugettext('I agree to the Mentor Agreement'),
         'group': ugettext("5. Terms of Service"),
         },
        ]

    new_params['allow_requests_and_invites'] = True
    # only if subclassed, so params is not empty
    new_params['show_in_roles_overview'] = bool(params)

    new_params['public_field_keys'] = ["name", "link_id", "scope_path"]
    new_params['public_field_names'] = ["Name", "Mentor ID", "Organization ID"]

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)

    params = self.getParams()

    # register the role with the group_view
    params['group_view'].registerRole(self._logic.role_name, self)

    # create and store the special form for invited users
    dynafields = [
        {'name': 'link_id',
         'base': forms.CharField,
         'widget': widgets.ReadOnlyInput(),
         'required': False,
         },
        {'name': 'mentor_agreement',
         'base': forms.fields.Field,
         'required': False,
         'widget': widgets.AgreementField,
         'group': ugettext("5. Terms of Service"),
        },
        ]

    dynaproperties = params_helper.getDynaFields(dynafields)

    invited_create_form = dynaform.extendDynaForm(
        dynaform=params['create_form'],
        dynaproperties=dynaproperties)

    params['invited_create_form'] = invited_create_form

    # add the contact field to the admin list
    params['admin_field_keys'].append('can_we_contact_you')
    params['admin_field_names'].append('Allowed to Contact?')
    params['admin_field_hidden'].append('can_we_contact_you')
Exemplo n.º 17
0
def constructParams(params):
    """Constructs a new params dictionary based on params.

  Params usage:
    The params dictionary is passed to getCreateForm and getEditForm,
    see their docstring on how they use it.

    rights: The rights value is merged with a default rights
      dictionary and then used as rights value.
    url_name: The url_name value is used in constructing several
      redirects as the first part of the url.
    module_name: The module_name value is used in constructing the
      location of several templates. It is expected that it matches
      the part after "/templates/soc/" for this View.
    name_plural: The name_plural argument is provided to the
      LIST_DESCRIPTION when constructing the list_description field.
    extra_dynainclude: The extra_dynainclude value is used when
      constructing the create_dynainclude value.
    extra_dynaexclude: The extra_dynaexclude value is used when
      constructing the create_dynaexclude value.
    logic: The logic value is used as argument to save the scope_logic
      and create a create form.
  """

    logic = params['logic']

    if params.get('rights'):
        rights = params['rights']
    else:
        rights = access.Checker(params)

    rights['unspecified'] = []
    rights['any_access'] = ['checkIsLoggedIn']
    rights['show'] = ['checkIsUser']
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = ['checkIsDeveloper']
    rights['delete'] = ['checkIsDeveloper']
    rights['list'] = ['checkIsDeveloper']
    rights['pick'] = ['checkIsUser']  # TODO(SRabbelier): proper check

    new_params = {}
    new_params['scope_logic'] = logic.getScopeLogic()

    if 'name_short' not in params:
        params['name_short'] = params['name']

    if 'name_plural' not in params:
        params['name_plural'] = params['name'] + 's'

    if 'module_name' not in params:
        params['module_name'] = params['name_short'].replace(' ', '_').lower()

    if 'url_name' not in params:
        params['url_name'] = params['module_name']

    if 'document_prefix' not in params:
        params['document_prefix'] = params['url_name']

    # Do not expand edit_redirect to allow it to be overwritten without suffix
    new_params['edit_redirect'] = '/%(url_name)s/edit/%(suffix)s'
    new_params['missing_redirect'] = '/%(url_name)s/create' % params
    new_params['delete_redirect'] = '/%(url_name)s/list' % params
    new_params['invite_redirect'] = '/request/list'
    # new_params['cancel_redirect'] = '/%(url_name)s/list' % params
    new_params['public_redirect'] = None

    new_params['sidebar'] = None
    new_params['sidebar_grouping'] = 'main'
    new_params['sidebar_defaults'] = []
    new_params['sidebar_developer'] = [
        # TODO(SRabbelier): remove create once new list code is in
        ('/%s/create', 'New %(name)s', 'create'),
        ('/%s/list', 'List %(name_plural)s', 'list'),
    ]
    new_params['sidebar_additional'] = []

    names_sans_link_id = [
        i for i in logic.getKeyFieldNames() if i != 'link_id'
    ]
    sans_link_id_pattern = getPattern(names_sans_link_id,
                                      linkable.SCOPE_PATH_ARG_PATTERN)

    new_params['link_id_arg_pattern'] = linkable.LINK_ID_ARG_PATTERN
    new_params['link_id_pattern_core'] = linkable.LINK_ID_PATTERN_CORE
    new_params['scope_path_pattern'] = getScopePattern(params)
    new_params['sans_link_id_pattern'] = sans_link_id_pattern

    new_params['django_patterns'] = None
    new_params['extra_django_patterns'] = []
    new_params['django_patterns_defaults'] = []

    # Defines the module package that the view is in. If it is not
    # already defined in the respective view, it defaults to
    # soc.views.models
    if not params.get('module_package'):
        new_params['module_package'] = 'soc.views.models'

    if not params.get('no_edit'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.edit', 'Edit %(name_short)s')
        ]

    if not params.get('no_delete'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.delete',
             'Delete %(name_short)s')
        ]

    if not params.get('no_show'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.public',
             'Show %(name_short)s')
        ]

    if not params.get('no_admin'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>admin)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.admin',
             'Show %(name_short)s (admin)')
        ]

    if not params.get('no_create_raw'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>create)$',
             '%(module_package)s.%(module_name)s.create',
             'Create %(name_short)s')
        ]

    if not params.get('no_create_with_scope'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>create)/%(scope)s$',
             '%(module_package)s.%(module_name)s.create',
             'Create %(name_short)s')
        ]

    if not params.get('no_create_with_key_fields'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>create)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.create',
             'Create %(name_short)s')
        ]

    if not params.get('no_list_raw'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>list)$',
             '%(module_package)s.%(module_name)s.list', 'List %(name_plural)s')
        ]

    if params.get('pickable'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>pick)$',
             '%(module_package)s.%(module_name)s.pick', 'Pick %(name_short)s')
        ]

    if params.get('export_content_type'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.export',
             'Export %(name_short)s')
        ]

    if params.get('sans_link_id_create'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>create)/%(sans_link_id)s$',
             '%(module_package)s.%(module_name)s.create',
             'Create %(name_short)s')
        ]

    if params.get('sans_link_id_list'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>list)/%(sans_link_id)s$',
             '%(module_package)s.%(module_name)s.list', 'List %(name_plural)s')
        ]

    if params.get('sans_link_id_public_list'):
        new_params['django_patterns_defaults'] += [
            (r'^%(url_name)s/(?P<access_type>list_public)/%(sans_link_id)s$',
             '%(module_package)s.%(module_name)s.list_public',
             'List %(name_plural)s')
        ]

    new_params['public_template'] = 'soc/%(module_name)s/public.html' % params
    new_params['export_template'] = 'soc/export.html'
    new_params['create_template'] = 'soc/models/edit.html'
    new_params['edit_template'] = 'soc/models/edit.html'
    new_params['admin_template'] = 'soc/models/admin.html'
    new_params['list_template'] = 'soc/models/list.html'
    new_params['invite_template'] = 'soc/models/invite.html'

    new_params['context'] = None

    new_params['cache_pick'] = False

    new_params['export_content_type'] = None
    new_params['export_extension'] = '.txt'
    new_params['csv_fieldnames'] = []

    # TODO: Use only the js modules needed instead of js_uses_all
    new_params['js_uses_all'] = DEF_JS_USES_LIST
    new_params['js_uses_list'] = ['jq', 'menu']
    new_params['js_uses_show'] = ['jq', 'menu']
    new_params['js_uses_edit'] = [
        'jq', 'menu', 'tinymce', 'jq_purr', 'jq_spin', 'jq_autocomplete'
    ]

    new_params['error_public'] = 'soc/%(module_name)s/error.html' % params
    new_params['error_export'] = new_params['error_public']
    new_params['error_edit'] = new_params['error_public']

    new_params['list_main'] = 'soc/list/main.html'
    new_params['list_pagination'] = 'soc/list/pagination.html'
    new_params['list_row'] = 'soc/%(module_name)s/list/row.html' % params
    new_params[
        'list_heading'] = 'soc/%(module_name)s/list/heading.html' % params

    new_params['public_row_action'] = {
        "type": "redirect_custom",
        "parameters": dict(new_window=True),
    }
    new_params['public_row_extra'] = lambda entity, *args: {
        "link": redirects.getEditRedirect(entity, params),
    }

    new_params['list_params'] = {
        'list_description': 'description',
        'list_info': 'info',
        'list_key_order': 'key_order',
        'list_main': 'main',
        'list_pagination': 'pagination',
        'list_row': 'row',
        'list_heading': 'heading',
    }

    new_params['list_description'] = DEF_LIST_DESCRIPTION_FMT % params
    new_params['no_lists_msg'] = ""
    new_params['save_message'] = [
        ugettext('%(name)s saved.' % params),
        ugettext('Cannot delete %(name)s.' % params)
    ]
    new_params['submit_msg_param_name'] = DEF_SUBMIT_MSG_PARAM_NAME
    new_params['edit_params'] = {
        DEF_SUBMIT_MSG_PARAM_NAME: DEF_SUBMIT_MSG_PROFILE_SAVED,
    }

    new_params['cannot_delete_params'] = {
        DEF_SUBMIT_MSG_PARAM_NAME: DEF_SUBMIT_MSG_CANNOT_DELETE_ENTITY,
    }

    new_params['dynabase'] = helper.forms.BaseForm

    create_dynaproperties = {
        'clean_link_id': cleaning.clean_link_id('link_id'),
        'clean_feed_url': cleaning.clean_feed_url,
    }
    create_dynaproperties.update(params.get('create_extra_dynaproperties', {}))

    # dynafields override any dynaproperties
    create_dynafields = getDynaFields(params.get('create_dynafields', {}))
    create_dynaproperties = dicts.merge(create_dynafields,
                                        create_dynaproperties)

    new_params['references'] = []
    new_params['create_dynainclude'] = [] + params.get('extra_dynainclude', [])
    new_params['create_dynaexclude'] = ['scope', 'scope_path'] + \
        params.get('extra_dynaexclude', [])
    new_params['create_dynaproperties'] = create_dynaproperties

    edit_dynaproperties = {
        'clean_link_id': cleaning.clean_link_id('link_id'),
        'link_id': forms.CharField(widget=helper.widgets.ReadOnlyInput()),
    }
    edit_dynaproperties.update(params.get('edit_extra_dynaproperties', {}))

    # dynafields override any dynaproperties
    edit_dynafields = getDynaFields(params.get('edit_dynafields', {}))
    edit_dynaproperties = dicts.merge(edit_dynafields, edit_dynaproperties)

    new_params['edit_dynainclude'] = None
    new_params['edit_dynaexclude'] = None
    new_params['edit_dynaproperties'] = edit_dynaproperties
    new_params['list_msg'] = None

    params = dicts.merge(params, new_params)

    # These need to be constructed separately, because they require
    # parameters that can be defined either in params, or new_params.
    if not 'create_form' in params:
        params['create_form'] = getCreateForm(params, logic.getModel())

    if not 'edit_form' in params:
        params['edit_form'] = getEditForm(params, params['create_form'])

    if not 'admin_form' in params:
        params['admin_form'] = getAdminForm(params['edit_form'])

    if not 'key_fields_pattern' in params:
        params['key_fields_pattern'] = getKeyFieldsPattern(params)

    # merge already done by access.Checker
    params['rights'] = rights

    return params
Exemplo n.º 18
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['unspecified'] = ['checkIsDeveloper']
    rights['any_access'] = ['allow']
    rights['home'] = ['allow']
    rights['show'] = ['checkIsDeveloper']

    new_params = {}
    new_params['logic'] = soc.logic.models.site.logic
    new_params['rights'] = rights

    new_params['name'] = "Site Settings"
    new_params['name_plural'] = new_params['name']
    new_params['document_prefix'] = 'site'
    new_params['name_short'] = "Site"

    new_params['sidebar_developer'] = []

    new_params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')]
    new_params['sidebar_heading'] = new_params['name_short']

    new_params['edit_template'] = 'soc/site/edit.html'
    new_params['home_template'] = 'soc/site/home.html'

    new_params['create_extra_dynaproperties'] = {
        'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
        'noreply_email': forms.EmailField(required=False),
        }
    new_params['edit_extra_dynaproperties'] = {
        'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
        'home_link_id': widgets.ReferenceField(
            reference_url='document', required=False,
            filter_fields={'prefix': new_params['document_prefix']},
            label=ugettext('Home page Document link ID'),
            help_text=soc.models.work.Work.link_id.help_text),
        'tos_link_id': widgets.ReferenceField(
            reference_url='document', required=False,
            filter_fields={'prefix': new_params['document_prefix']},
            label=ugettext('Terms of Service Document link ID'),
            help_text=soc.models.work.Work.link_id.help_text),
        'clean_noreply_email': cleaning.clean_empty_field('noreply_email'),
        }

    # XSRF secret key is not editable by mere mortals.
    new_params['extra_dynaexclude'] = ['xsrf_secret_key']

    patterns = []

    page_name = "Home Page"
    patterns += [(r'^$', 'soc.views.models.%(module_name)s.main_public',
                  page_name)]

    page_name = "Edit Site"
    patterns += [(r'^%(url_name)s/(?P<access_type>edit)$',
                  'soc.views.models.%(module_name)s.main_edit',
                  page_name)]

    if soc.logic.system.isDebug():
      patterns += [('^seed_db$', 'soc.models.seed_db.seed', "Seed DB"),
                   ('^clear_db$', 'soc.models.seed_db.clear', "Clear DB"),
                   ('^reseed_db$', 'soc.models.seed_db.reseed', "Reseed DB"),
                   ('^seed_many$', 'soc.models.seed_db.seed_many', "Seed Many"),
                   ('^new_seed_many$', 'soc.models.seed_db.new_seed_many',
                    "New Seed Many"),
                   ]

    new_params['extra_django_patterns'] = patterns

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
Exemplo n.º 19
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['any_access'] = ['allow']
        rights['show'] = [('checkIsSurveyWritable', survey_logic)]
        rights['create'] = ['checkIsUser']
        rights['edit'] = [('checkIsSurveyWritable', survey_logic)]
        rights['delete'] = ['checkIsDeveloper'
                            ]  # TODO: fix deletion of Surveys
        rights['list'] = ['checkDocumentList']
        rights['pick'] = ['checkDocumentPick']
        rights['record'] = [('checkHasAny', [[
            ('checkIsSurveyReadable', [survey_logic]),
            ('checkIsMySurveyRecord', [survey_logic, 'id'])
        ]])]
        rights['results'] = ['checkIsUser']
        rights['take'] = [('checkIsSurveyTakeable', survey_logic)]

        new_params = {}
        new_params['logic'] = survey_logic
        new_params['rights'] = rights

        new_params['name'] = 'Survey'
        new_params['sidebar_grouping'] = "Surveys"

        new_params['extra_django_patterns'] = [
            (r'^%(url_name)s/(?P<access_type>take)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.take', 'Take %(name)s'),
            (r'^%(url_name)s/(?P<access_type>json)/%(scope)s$',
             '%(module_package)s.%(module_name)s.json',
             'Export %(name)s as JSON'),
            (r'^%(url_name)s/(?P<access_type>record)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.record',
             'View survey record for %(name)s'),
            (r'^%(url_name)s/(?P<access_type>results)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.results',
             'View survey results for %(name)s'),
            (r'^%(url_name)s/(?P<access_type>show)/user/(?P<link_id>)\w+$',
             '%(module_package)s.%(module_name)s.results',
             'View survey results for user'),
        ]

        new_params['export_content_type'] = 'text/text'
        new_params['export_extension'] = '.csv'
        new_params['export_function'] = surveys.toCSV(self)
        new_params['delete_redirect'] = '/'

        new_params['edit_template'] = 'soc/survey/edit.html'
        new_params['create_template'] = 'soc/survey/edit.html'
        new_params['public_template'] = 'soc/survey/public.html'
        new_params['record_template'] = 'soc/survey/view_record.html'
        new_params['take_template'] = 'soc/survey/take.html'

        new_params['no_create_raw'] = True
        new_params['no_create_with_scope'] = True
        new_params['no_create_with_key_fields'] = True
        new_params['no_list_raw'] = True
        new_params['sans_link_id_create'] = True
        new_params['sans_link_id_list'] = True

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Survey Link ID',
            },
        ]

        new_params['create_extra_dynaproperties'] = {
            'content':
            forms.fields.CharField(required=False,
                                   label='Description',
                                   widget=widgets.FullTinyMCE(attrs={
                                       'rows': 25,
                                       'cols': 100
                                   })),
            'survey_html':
            forms.fields.CharField(widget=forms.HiddenInput, required=False),
            'scope_path':
            forms.fields.CharField(widget=forms.HiddenInput, required=True),
            'prefix':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=True),
            'clean_content':
            cleaning.clean_html_content('content'),
            'clean_link_id':
            cleaning.clean_link_id('link_id'),
            'clean_scope_path':
            cleaning.clean_scope_path('scope_path'),
            'clean':
            cleaning.validate_document_acl(self, True),
        }

        new_params['extra_dynaexclude'] = [
            'author', 'created', 'home_for', 'modified_by', 'modified',
            'take_survey', 'survey_content'
        ]

        new_params['edit_extra_dynaproperties'] = {
            'doc_key_name':
            forms.fields.CharField(widget=forms.HiddenInput),
            'created_by':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=False),
            'last_modified_by':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=False),
            'clean':
            cleaning.validate_document_acl(self),
        }

        new_params['survey_take_form'] = surveys.SurveyTakeForm
        new_params['survey_record_form'] = surveys.SurveyRecordForm

        new_params['public_field_prefetch'] = ['author']
        new_params['public_field_extra'] = lambda entity: {
            "path": entity.scope_path + '/' + entity.link_id,
            "created_by": entity.author.link_id,
        }
        new_params['public_field_keys'] = [
            "path", "title", "link_id", "is_featured", "created_by", "created",
            "modified"
        ]
        new_params['public_field_names'] = [
            "Path",
            "Title",
            "Link ID",
            "Featured",
            "Created By",
            "Created On",
            "Modified",
        ]

        new_params['records_field_keys'] = ['taken_by', 'modified']
        new_params['records_field_names'] = [
            'Taken By',
            'Taken On',
        ]
        new_params['records_field_prefetch'] = ['user']
        new_params['records_field_extra'] = lambda entity: {
            'taken_by': '%s (%s)' % (entity.user.name, entity.user.link_id),
        }

        new_params['take_params'] = {'s': '0'}

        new_params['successful_take_message'] = ugettext(
            'Survey record submitted.')

        params = dicts.merge(params, new_params, sub_merge=True)

        super(View, self).__init__(params=params)
Exemplo n.º 20
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['any_access'] = ['allow']
        rights['show'] = ['allow']
        rights['create'] = [('checkSeeded',
                             ['checkHasRoleForScope', host_logic.logic])]
        rights['edit'] = ['checkIsHostForProgram']
        rights['delete'] = ['checkIsDeveloper']
        rights['accepted_orgs'] = [('checkIsAfterEvent', [
            'accepted_organization_announced_deadline', '__all__',
            program_logic.logic
        ])]

        new_params = {}
        new_params['logic'] = soc.logic.models.program.logic
        new_params['rights'] = rights

        new_params['scope_view'] = sponsor_view
        new_params['scope_redirect'] = redirects.getCreateRedirect

        new_params['name'] = "Program"
        new_params['sidebar_grouping'] = 'Programs'
        new_params['document_prefix'] = 'program'

        new_params['extra_dynaexclude'] = [
            'timeline', 'org_admin_agreement', 'mentor_agreement',
            'student_agreement', 'about_page', 'events_page',
            'connect_with_us_page', 'privacy_policy'
        ]

        patterns = []
        patterns += [
            (r'^%(url_name)s/(?P<access_type>assign_slots)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.assign_slots',
             'Assign slots'),
            (r'^%(url_name)s/(?P<access_type>slots)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.slots',
             'Assign slots (JSON)'),
            (r'^%(url_name)s/(?P<access_type>show_duplicates)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.show_duplicates',
             'Show duplicate slot assignments'),
            (r'^%(url_name)s/(?P<access_type>assigned_proposals)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.assigned_proposals',
             "Assigned proposals for multiple organizations"),
            (r'^%(url_name)s/(?P<access_type>accepted_orgs)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.accepted_orgs',
             "List all accepted organizations"),
            (r'^%(url_name)s/(?P<access_type>list_projects)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.list_projects',
             "List all Student Projects"),
            (r'^%(url_name)s/(?P<access_type>list_participants)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.list_participants',
             "List all Participants for"),
        ]

        new_params['extra_django_patterns'] = patterns

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Program Link ID',
            },
        ]

        # TODO: add clean field to check for uniqueness in link_id and scope_path
        new_params['create_extra_dynaproperties'] = {
            'description':
            forms.fields.CharField(widget=helper.widgets.TinyMCE(attrs={
                'rows': 10,
                'cols': 40
            })),
            'accepted_orgs_msg':
            forms.fields.CharField(required=False,
                                   widget=helper.widgets.TinyMCE(attrs={
                                       'rows': 10,
                                       'cols': 40
                                   })),
            'scope_path':
            forms.CharField(widget=forms.HiddenInput, required=True),
            'is_active':
            forms.BooleanField(required=False),
        }

        params = dicts.merge(params, new_params, sub_merge=True)

        new_params = {}

        reference_fields = [
            ('org_admin_agreement_link_id',
             soc.models.work.Work.link_id.help_text,
             ugettext('Organization Admin Agreement Document link ID')),
            ('mentor_agreement_link_id',
             soc.models.work.Work.link_id.help_text,
             ugettext('Mentor Agreement Document link ID')),
            ('student_agreement_link_id',
             soc.models.work.Work.link_id.help_text,
             ugettext('Student Agreement Document link ID')),
            ('home_link_id', soc.models.work.Work.link_id.help_text,
             ugettext('Home page Document link ID')),
            ('about_page_link_id', soc.models.work.Work.link_id.help_text,
             ugettext('About Page Document link ID')),
            ('events_page_link_id', soc.models.work.Work.link_id.help_text,
             ugettext('Events Page Document link ID')),
            ('connect_with_us_page_link_id',
             soc.models.work.Work.link_id.help_text,
             ugettext('Connect With Us Page Document link ID')),
            ('privacy_policy_link_id', soc.models.work.Work.link_id.help_text,
             ugettext('Privacy Policy Page Document link ID')),
        ]

        result = {}

        for key, help_text, label in reference_fields:
            result[key] = widgets.ReferenceField(
                reference_url='document',
                filter=['__scoped__'],
                filter_fields={'prefix': params['document_prefix']},
                required=False,
                label=label,
                help_text=help_text)

        result['clean'] = cleaning.clean_refs(
            params, [i for i, _, _ in reference_fields])

        new_params['edit_extra_dynaproperties'] = result

        document_references = [
            ('org_admin_agreement_link_id', 'org_admin_agreement',
             lambda x: x.org_admin_agreement),
            ('mentor_agreement_link_id', 'mentor_agreement',
             lambda x: x.mentor_agreement),
            ('student_agreement_link_id', 'student_agreement',
             lambda x: x.student_agreement),
            ('about_page_link_id', 'about_page', lambda x: x.about_page),
            ('events_page_link_id', 'events_page', lambda x: x.events_page),
            ('connect_with_us_page_link_id', 'connect_with_us_page',
             lambda x: x.connect_with_us_page),
            ('privacy_policy_link_id', 'privacy_policy',
             lambda x: x.privacy_policy),
        ]

        new_params['references'] = document_references

        new_params['public_field_keys'] = ["name", "scope_path"]
        new_params['public_field_names'] = ["Program Name", "Program Owner"]

        params = dicts.merge(params, new_params, sub_merge=True)

        super(View, self).__init__(params=params)
Exemplo n.º 21
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['create'] = ['checkIsDeveloper']
        rights['edit'] = [('checkHasRoleForLinkId', club_admin_logic.logic),
                          ('checkGroupIsActiveForLinkId', club_logic.logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['home'] = ['allow']
        rights['list'] = ['checkIsDeveloper']
        rights['apply_member'] = [
            'checkIsUser',
            ('checkGroupIsActiveForScopeAndLinkId', club_logic.logic)
        ]
        rights['list_requests'] = [('checkHasRoleForLinkId',
                                    club_admin_logic.logic)]
        rights['list_roles'] = [('checkHasRoleForLinkId',
                                 club_admin_logic.logic)]

        new_params = {}
        new_params['logic'] = soc.logic.models.club.logic
        new_params['rights'] = rights
        new_params['name'] = "Club"
        new_params['url_name'] = "club"
        new_params['document_prefix'] = "club"
        new_params['sidebar_grouping'] = 'Clubs'

        new_params['public_template'] = 'soc/group/public.html'

        patterns = []

        patterns += [
            (r'^%(url_name)s/(?P<access_type>apply_member)$',
             'soc.views.models.%(module_name)s.apply_member',
             "List of all %(name_plural)s you can apply to"),
        ]

        new_params['extra_django_patterns'] = patterns

        new_params['sidebar_additional'] = [
            ('/' + new_params['url_name'] + '/apply_member', 'Join a Club',
             'apply_member'),
        ]

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Club Link ID',
            },
        ]

        new_params['create_extra_dynaproperties'] = {
            'clean':
            cleaning.validate_new_group('link_id', 'scope_path', club_logic,
                                        None)
        }

        # get rid of the clean method
        new_params['edit_extra_dynaproperties'] = {
            'clean': (lambda x: x.cleaned_data)
        }

        new_params['public_field_keys'] = ["name", "link_id", "short_name"]
        new_params['public_field_names'] = ["Name", "Link ID", "Short name"]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)

        # create and store the special form for applicants
        updated_fields = {
            'link_id':
            forms.CharField(widget=widgets.ReadOnlyInput(), required=False),
            'clean_link_id':
            cleaning.clean_link_id('link_id')
        }

        applicant_create_form = dynaform.extendDynaForm(
            dynaform=self._params['create_form'],
            dynaproperties=updated_fields)

        self._params['applicant_create_form'] = applicant_create_form
Exemplo n.º 22
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['unspecified'] = ['deny']
        rights['any_access'] = ['allow']
        rights['create_profile'] = ['checkIsUnusedAccount']
        rights['edit_profile'] = ['checkHasUserEntity']
        rights['roles'] = ['checkIsUser']
        rights['requests'] = ['checkIsUser']
        rights['signIn'] = ['checkNotLoggedIn']
        rights['notification'] = ['checkIsUser']

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = user_logic

        new_params['name'] = "User"
        new_params['module_name'] = "user_self"
        new_params['url_name'] = "user"

        new_params['create_template'] = 'soc/user/edit_profile.html'
        new_params['edit_template'] = 'soc/user/edit_profile.html'
        new_params['save_message'] = [ugettext('Profile saved.')]
        new_params['edit_redirect'] = '/%(url_name)s/edit_profile'

        # set the specific fields for the users profile page
        new_params['extra_dynaexclude'] = [
            'former_accounts', 'account', 'is_developer', 'status',
            'agreed_to_tos_on'
        ]

        new_params['create_extra_dynaproperties'] = {
            'clean_agreed_to_tos':
            cleaning.clean_agrees_to_tos('agreed_to_tos'),
            'clean_link_id': cleaning.clean_user_not_exist('link_id'),
        }

        new_params['edit_extra_dynaproperties'] = {
            'clean_link_id':
            cleaning.clean_user_is_current('link_id', False),
            'agreed_to_tos_on':
            forms.DateTimeField(
                widget=widgets.ReadOnlyInput(attrs={'disabled': 'true'}),
                required=False),
        }

        new_params['sidebar_heading'] = 'User (self)'
        new_params['sidebar'] = [
            (users.create_login_url("/"), 'Sign In', 'signIn'),
            ('/' + new_params['url_name'] + '/create_profile',
             'Create Profile', 'create_profile'),
            ('/' + new_params['url_name'] + '/edit_profile', 'Edit Profile',
             'edit_profile'),
            ('/' + new_params['url_name'] + '/roles', 'Roles', 'roles'),
            ('/' + new_params['url_name'] + '/requests', 'Requests',
             'requests'),
        ]

        patterns = []

        page_name = ugettext("Create your profile")
        patterns += [(r'^%(url_name)s/(?P<access_type>create_profile)$',
                      'soc.views.models.%(module_name)s.create', page_name)]

        page_name = ugettext("Edit your profile")
        patterns += [(r'^%(url_name)s/(?P<access_type>edit_profile)$',
                      'soc.views.models.%(module_name)s.edit', page_name)]

        page_name = ugettext("List of your roles")
        patterns += [(r'^%(url_name)s/(?P<access_type>roles)$',
                      'soc.views.models.user_self.roles', page_name)]

        page_name = ugettext("List of your requests")
        patterns += [(r'^%(url_name)s/(?P<access_type>requests)$',
                      'soc.views.models.request.list_self', page_name)]

        new_params['django_patterns_defaults'] = patterns

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 23
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['create'] = [('checkHasRoleForScope', host_logic.logic)]
        rights['edit'] = [('checkIsMyActiveRole', host_logic.logic)]
        rights['invite'] = [('checkHasRoleForScope', host_logic.logic)]
        rights['list'] = ['checkIsDeveloper']
        rights['accept_invite'] = [('checkIsMyRequestWithStatus',
                                    [['group_accepted']])]
        rights['process_request'] = [('checkCanProcessRequest',
                                      [[host_logic.logic]])]
        rights['manage'] = [('checkIsAllowedToManageRole',
                             [host_logic.logic, host_logic.logic])]

        new_params = {}
        new_params['rights'] = rights
        new_params['logic'] = soc.logic.models.host.logic
        new_params['group_logic'] = sponsor_logic.logic
        new_params['group_view'] = soc.views.models.sponsor.view

        new_params['scope_view'] = sponsor_view

        new_params['name'] = "Program Administrator"
        new_params['module_name'] = "host"
        new_params['sidebar_grouping'] = 'Programs'

        new_params['extra_dynaexclude'] = ['agreed_to_tos']

        new_params['create_extra_dynaproperties'] = {
            'scope_path': forms.CharField(widget=forms.HiddenInput,
                                          required=True),
            'clean_link_id': cleaning.clean_existing_user('link_id'),
            'clean_home_page': cleaning.clean_url('home_page'),
            'clean_blog': cleaning.clean_url('blog'),
            'clean_photo_url': cleaning.clean_url('photo_url')
        }

        new_params['allow_invites'] = True
        new_params['show_in_roles_overview'] = True

        new_params['public_field_keys'] = ["name", "link_id", "scope_path"]
        new_params['public_field_names'] = [
            "Name", "Administrator ID", "Program Owner"
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)

        # register the role with the group_view
        self._params['group_view'].registerRole(self._logic.role_name, self)

        # create and store the special form for invited users
        updated_fields = {
            'link_id':
            forms.CharField(widget=widgets.ReadOnlyInput(), required=False)
        }

        invited_create_form = dynaform.extendDynaForm(
            dynaform=self._params['create_form'],
            dynaproperties=updated_fields)

        self._params['invited_create_form'] = invited_create_form
Exemplo n.º 24
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkIsMyActiveRole', student_logic.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['apply'] = [
        'checkIsUser',
        ('checkIsActivePeriod', 
         ['student_signup', 'scope_path', program_logic.logic]),
        ('checkIsNotParticipatingInProgramInScope', [program_logic.logic,
        student_logic.logic, org_admin_logic.logic, mentor_logic.logic]),
        ]
    rights['manage'] = [('checkIsMyActiveRole', student_logic.logic)]

    new_params = {}
    new_params['logic'] = soc.logic.models.student.logic
    new_params['group_logic'] = program_logic.logic
    new_params['group_view'] = program_view.view
    new_params['rights'] = rights

    new_params['scope_view'] = program_view
    new_params['scope_redirect'] = redirects.getCreateRedirect
    new_params['manage_redirect'] = redirects.getUserRolesRedirect

    new_params['name'] = "Student"
    new_params['module_name'] = "student"
    new_params['sidebar_grouping'] = 'Students'

    new_params['create_template'] = 'soc/student/edit.html'
    new_params['edit_template'] = 'soc/student/edit.html'

    new_params['public_field_keys'] = ["name", "link_id", "scope_path"]
    new_params['public_field_names'] = ["Student Name", "Student ID", "Program ID"]

    # add apply pattern
    patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
        '%(module_package)s.%(module_name)s.apply',
        'Become a %(name)s'),]

    new_params['extra_django_patterns'] = patterns

    new_params['extra_dynaexclude'] = ['agreed_to_tos', 'school']

    current_year = time.gmtime().tm_year
    # the current year is not the minimum because a program could span
    # more than one year
    allowed_years = range(current_year-1, current_year+20)

    view_logic = params['logic'] if params else new_params['logic']

    new_params['create_extra_dynaproperties'] = {
        'expected_graduation': forms.TypedChoiceField(
            choices=[(x,x) for x in allowed_years],
            coerce=lambda val: int(val)
            ),
        'clean': cleaning.validate_student(view_logic.getScopeLogic().logic),
        'school_home_page': forms.fields.URLField(required=True),
        'clean_school_home_page': cleaning.clean_url('school_home_page'),
        }

    new_params['create_dynafields'] = [
        {'name': 'scope_path',
         'base': forms.fields.CharField,
         'widget': forms.HiddenInput,
         'required': True,
         },
        {'name': 'student_agreement',
         'base': forms.fields.CharField,
         'required': False,
         'widget': widgets.AgreementField,
         'group': ugettext("5. Terms of Service"),
         },
        {'name': 'agreed_to_student_agreement',
         'base': forms.fields.BooleanField,
         'initial': False,
         'required':True,
         'label': ugettext('I agree to the Student Agreement'),
         'group': ugettext("5. Terms of Service"),
         },
        ]

    # only if subclassed, so params is not empty
    new_params['show_in_roles_overview'] = bool(params)

    params = dicts.merge(params, new_params, sub_merge=True)

    super(View, self).__init__(params=params)

    params = self.getParams()

    # create and store the special form for users
    updated_fields = {
        'link_id': forms.CharField(widget=forms.HiddenInput,
            required=True),
        'clean_link_id': cleaning.clean_user_is_current('link_id'),
        }

    user_create_form = dynaform.extendDynaForm(
        dynaform = params['create_form'],
        dynaproperties = updated_fields)

    params['user_create_form'] = user_create_form

    params['admin_field_keys'].extend([
        'school_name', 'school_country', 'school_home_page', 'school_type',
        'major', 'degree', 'grade', 'expected_graduation', 'program_knowledge',
        'can_we_contact_you'])
    params['admin_field_names'].extend([
        'School Name', 'School Country', 'School Homepage', 'School Type',
        'Major', 'Degree', 'Grade', 'Expected Graduation Year',
        'How did you hear about us?', 'Allowed to Contact?'])
    params['admin_field_hidden'].extend([
        'school_name', 'school_country', 'school_home_page', 'school_type',
        'major', 'degree', 'grade', 'expected_graduation', 'program_knowledge',
        'can_we_contact_you'])
Exemplo n.º 25
0
 def setUp(self):
     self.test_context = {'TEST_KEY': 'TEST_VALUE'}
     self.rights = access.Checker(None)
Exemplo n.º 26
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        # TODO(ljvderijk): phase out this module + access checks
        rights = access.Checker(params)
        rights['create'] = ['checkIsDeveloper']
        rights['delete'] = [('checkCanEditGroupApp', [org_app_logic.logic]),
                            ('checkIsActivePeriod',
                             ['org_signup', 'scope_path',
                              program_logic.logic])]
        rights['edit'] = [('checkCanEditGroupApp', [org_app_logic.logic]),
                          ('checkIsActivePeriod',
                           ['org_signup', 'scope_path', program_logic.logic])]
        rights['list'] = ['checkIsDeveloper']
        rights['list_self'] = ['checkIsUser']
        rights['show'] = ['allow']
        rights['review'] = [
            'checkIsHostForProgramInScope',
            ('checkCanReviewGroupApp', [org_app_logic.logic])
        ]
        rights['review_overview'] = ['checkIsHostForProgramInScope']
        rights['bulk_accept'] = ['checkIsHostForProgramInScope']
        rights['bulk_reject'] = ['checkIsHostForProgramInScope']
        rights['apply'] = [
            'checkIsUser',
            ('checkCanCreateOrgApp', ['org_signup', program_logic.logic]),
            ('checkIsNotStudentForProgramInScope',
             [program_logic.logic, student_logic.logic])
        ]

        new_params = {}

        new_params['rights'] = rights
        new_params['logic'] = org_app_logic.logic

        new_params['scope_view'] = program_view
        new_params['scope_redirect'] = redirects.getCreateRedirect

        new_params['sidebar_grouping'] = 'Organizations'

        new_params['list_key_order'] = [
            'link_id', 'scope_path', 'name', 'home_page', 'email',
            'description', 'why_applying', 'pub_mailing_list', 'irc_channel',
            'member_criteria', 'prior_participation', 'prior_application',
            'license_name', 'ideas', 'dev_mailing_list', 'contrib_template',
            'contrib_disappears', 'member_disappears', 'encourage_contribs',
            'continued_contribs'
        ]

        patterns = [
            (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
             'soc.views.models.%(module_name)s.create',
             'Create an %(name_plural)s'),
            (r'^%(url_name)s/(?P<access_type>bulk_accept)/%(scope)s$',
             'soc.views.models.%(module_name)s.bulk_accept',
             'Bulk Acceptation of %(name_plural)s'),
            (r'^%(url_name)s/(?P<access_type>bulk_reject)/%(scope)s$',
             'soc.views.models.%(module_name)s.bulk_reject',
             'Bulk Rejection of %(name_plural)s'),
        ]

        new_params['extra_django_patterns'] = patterns
        new_params['extra_key_order'] = [
            'admin_agreement', 'agreed_to_admin_agreement'
        ]

        new_params['extra_dynaexclude'] = [
            'applicant', 'backup_admin', 'status', 'created_on',
            'last_modified_on'
        ]

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Organization Link ID',
            },
        ]

        new_params['create_extra_dynaproperties'] = {
            'scope_path':
            forms.fields.CharField(widget=forms.HiddenInput, required=True),
            'contrib_template':
            forms.fields.CharField(widget=helper.widgets.FullTinyMCE(
                attrs={
                    'rows': 25,
                    'cols': 100
                })),
            'description':
            forms.fields.CharField(widget=helper.widgets.FullTinyMCE(
                attrs={
                    'rows': 25,
                    'cols': 100
                })),
            'admin_agreement':
            forms.fields.Field(required=False, widget=widgets.AgreementField),
            'agreed_to_admin_agreement':
            forms.fields.BooleanField(initial=False, required=True),
            'clean_description':
            cleaning.clean_html_content('description'),
            'clean_contrib_template':
            cleaning.clean_html_content('contrib_template'),
            'clean_ideas':
            cleaning.clean_url('ideas'),
            'clean':
            cleaning.validate_new_group('link_id', 'scope_path',
                                        model_logic.organization,
                                        org_app_logic)
        }

        # get rid of the clean method
        new_params['edit_extra_dynaproperties'] = {
            'clean': (lambda x: x.cleaned_data)
        }

        new_params['name'] = "Organization Application"
        new_params['name_plural'] = "Organization Applications"
        new_params['name_short'] = "Org App"
        new_params['url_name'] = "org_app"
        new_params['group_name'] = "Organization"
        new_params['group_url_name'] = 'org'

        new_params['review_template'] = 'soc/org_app/review.html'
        # TODO use a proper template that works for each program
        new_params['accepted_mail_template'] = \
            'soc/org_app/mail/accepted_gsoc2009.html'
        new_params['rejected_mail_template'] = 'soc/org_app/mail/rejected.html'

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)
Exemplo n.º 27
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

    Params:
      params: a dict with params for this View
    """

        rights = access.Checker(params)
        rights['any_access'] = ['allow']
        rights['show'] = ['checkIsDocumentReadable']
        rights['create'] = ['checkIsDocumentCreatable']
        rights['edit'] = ['checkIsDocumentWritable']
        rights['delete'] = ['checkIsDocumentWritable']
        rights['list'] = ['checkDocumentList']
        rights['pick'] = ['checkDocumentPick']

        new_params = {}
        new_params['logic'] = document_logic
        new_params['rights'] = rights

        new_params['name'] = "Document"
        new_params['pickable'] = True

        new_params['export_content_type'] = 'text/text'
        new_params['export_extension'] = '.html'
        new_params['export_function'] = lambda x: (x.content, x.link_id)
        new_params['delete_redirect'] = '/'

        new_params['no_create_raw'] = True
        new_params['no_create_with_scope'] = True
        new_params['no_create_with_key_fields'] = True
        new_params['no_list_raw'] = True
        new_params['sans_link_id_create'] = True
        new_params['sans_link_id_list'] = True

        new_params['create_dynafields'] = [
            {
                'name': 'link_id',
                'base': forms.fields.CharField,
                'label': 'Document Link ID',
            },
        ]

        new_params['create_extra_dynaproperties'] = {
            'content':
            forms.fields.CharField(widget=widgets.FullTinyMCE(attrs={
                'rows': 25,
                'cols': 100
            })),
            'scope_path':
            forms.fields.CharField(widget=forms.HiddenInput, required=True),
            'prefix':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=True),
            'clean_content':
            cleaning.clean_html_content('content'),
            'clean_link_id':
            cleaning.clean_link_id('link_id'),
            'clean_scope_path':
            cleaning.clean_scope_path('scope_path'),
            'clean':
            cleaning.validate_document_acl(self, True),
        }
        new_params['extra_dynaexclude'] = [
            'author', 'created', 'home_for', 'modified_by', 'modified'
        ]

        new_params['edit_extra_dynaproperties'] = {
            'doc_key_name':
            forms.fields.CharField(widget=forms.HiddenInput),
            'created_by':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=False),
            'last_modified_by':
            forms.fields.CharField(widget=widgets.ReadOnlyInput(),
                                   required=False),
            'clean':
            cleaning.validate_document_acl(self),
        }

        new_params['public_field_prefetch'] = ['author']
        new_params['public_field_extra'] = lambda entity: {
            'path': entity.scope_path + '/' + entity.link_id,
            'author_id': entity.author.link_id,
        }
        new_params['public_field_keys'] = [
            "path", "title", "link_id", "is_featured", "author_id", "created",
            "modified"
        ]
        new_params['public_field_names'] = [
            "Path", "Title", "Link ID", "Featured", "Created By", "Created On",
            "Modified"
        ]

        params = dicts.merge(params, new_params)

        super(View, self).__init__(params=params)