Esempio n. 1
0
        def getUploadForms(name, label, help_text):
            dynafields = [{
                'name': name,
                'base': forms.FileField,
                'label': label,
                'required': False,
                'help_text': help_text,
            }]

            dynaproperties = params_helper.getDynaFields(dynafields)

            add_form = dynaform.newDynaForm(dynabase=base_form,
                                            dynaproperties=dynaproperties)

            dynaproperties = {
                'name':
                django_fields.CharField(label='Name',
                                        required=False,
                                        widget=widgets.HTMLTextWidget),
                'uploaded':
                django_fields.CharField(label='Uploaded on',
                                        required=False,
                                        widget=widgets.PlainTextWidget),
                'size':
                django_fields.CharField(label='Size',
                                        required=False,
                                        widget=widgets.PlainTextWidget),
            }
            edit_form = dynaform.extendDynaForm(
                add_form,
                dynaproperties=dynaproperties,
                dynainclude=['name', 'size', 'uploaded', name])

            return add_form, edit_form
Esempio n. 2
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
Esempio 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['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkIsMyActiveRole', club_member_logic.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasRoleForScope', club_admin_logic.logic)]
    rights['accept_invite'] = [
        ('checkIsMyRequestWithStatus', [['group_accepted']])]
    rights['request'] = ['checkIsUser',
                         ('checkCanMakeRequestToGroup', club_logic.logic)]
    rights['process_request'] = [('checkCanProcessRequest', 
                                  [[club_admin_logic.logic]])]
    rights['manage'] = [('checkIsAllowedToManageRole',
                         [soc.logic.models.club_member.logic,
                          club_admin_logic.logic])]

    new_params = {}
    new_params['logic'] = soc.logic.models.club_member.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 Member"
    new_params['sidebar_grouping'] = 'Clubs'

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

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

    new_params['public_field_keys'] = ["name", "link_id", "scope_path"]
    new_params['public_field_names'] = ["Member Name", "Member 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
Esempio 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"] = [
            ("checkHasActiveRoleForScope", club_member_logic.logic),
            ("checkIsMyEntity", [club_member_logic.logic, "user", True]),
        ]
        rights["delete"] = ["checkIsDeveloper"]
        rights["invite"] = [("checkHasActiveRoleForScope", club_admin_logic.logic)]
        rights["accept_invite"] = [("checkCanCreateFromRequest", "club_member")]
        rights["request"] = ["checkIsUser", ("checkCanMakeRequestToGroup", club_logic)]
        rights["process_request"] = [
            ("checkHasActiveRoleForScope", club_admin_logic.logic),
            ("checkCanProcessRequest", "club_member"),
        ]
        rights["manage"] = [
            ("checkIsAllowedToManageRole", [soc.logic.models.club_member.logic, club_admin_logic.logic])
        ]

        new_params = {}
        new_params["logic"] = soc.logic.models.club_member.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 Member"
        new_params["sidebar_grouping"] = "Clubs"

        new_params["extra_dynaexclude"] = ["agreed_to_tos"]

        new_params["allow_requests_and_invites"] = True
        new_params["show_in_roles_overview"] = False

        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
Esempio 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
    """

    rights = access.Checker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkHasActiveRoleForScope', club_admin_logic.logic),
        ('checkIsMyEntity', [club_admin_logic.logic, 'user', True])]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasActiveRoleForScope', club_admin_logic.logic)]
    rights['accept_invite'] = [('checkCanCreateFromRequest', 'club_admin')]
    rights['process_request'] = [('checkHasActiveRoleForScope', 
                                 club_admin_logic.logic),
                                 ('checkCanProcessRequest', 'club_admin')]
    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

    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._params['module_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
Esempio n. 6
0
def getAdminForm(base_form):
  """Constructs a new AdminForm from base_form.
  """

  # extend _and_ deepcopy the base_fields to do a proper copy
  admin_form = dynaform.extendDynaForm(dynaform = base_form)
  admin_form.base_fields = copy.deepcopy(admin_form.base_fields)

  # replace all widgets with PTW's
  for _, value in admin_form.base_fields.iteritems():
    if not isinstance(value, forms.fields.Field):
      continue

    value.widget = widgets.PlainTextWidget()

  return admin_form
Esempio n. 7
0
def getAdminForm(base_form):
    """Constructs a new AdminForm from base_form.
  """

    # extend _and_ deepcopy the base_fields to do a proper copy
    admin_form = dynaform.extendDynaForm(dynaform=base_form)
    admin_form.base_fields = copy.deepcopy(admin_form.base_fields)

    # replace all widgets with PTW's
    for _, value in admin_form.base_fields.iteritems():
        if not isinstance(value, forms.fields.Field):
            continue

        value.widget = widgets.PlainTextWidget()

    return admin_form
Esempio n. 8
0
def getEditForm(params, base_form):
  """Constructs a new EditForm using params.

  Params usage:
    create_form: The dynabase value is used as the dynaform argument
      to dyanform.extendDynaForm.
    edit_dynainclude: same as create_form, but as dynainclude argument
    edit_dynaexclude: same as create_form, but as dynaexclude argument
    edit_dynaproperties: same as create_form, but as dynaproperties argument
  """

  edit_form = dynaform.extendDynaForm(
    dynaform = base_form,
    dynainclude = params['edit_dynainclude'],
    dynaexclude = params['edit_dynaexclude'],
    dynaproperties = params['edit_dynaproperties'],
    )

  return edit_form
Esempio n. 9
0
def getEditForm(params, base_form):
    """Constructs a new EditForm using params.

  Params usage:
    create_form: The dynabase value is used as the dynaform argument
      to dyanform.extendDynaForm.
    edit_dynainclude: same as create_form, but as dynainclude argument
    edit_dynaexclude: same as create_form, but as dynaexclude argument
    edit_dynaproperties: same as create_form, but as dynaproperties argument
  """

    edit_form = dynaform.extendDynaForm(
        dynaform=base_form,
        dynainclude=params['edit_dynainclude'],
        dynaexclude=params['edit_dynaexclude'],
        dynaproperties=params['edit_dynaproperties'],
    )

    return edit_form
Esempio 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)
    rights['edit'] = ['checkCanEditTimeline']

    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$',
                  'soc.views.models.%(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)

    for name, logic_value in program_logic.logic.TIMELINE_LOGIC.iteritems():
      create_form = params_helper.getCreateForm(self._params, 
          logic_value.getModel())
      edit_form = dynaform.extendDynaForm(
        dynaform = create_form,
        dynainclude = self._params['edit_dynainclude'],
        dynaexclude = self._params['edit_dynaexclude'],
        )

      self._params['edit_form_%s' % name] = edit_form
Esempio n. 11
0
        def getUploadForms(name, label, help_text):
            dynafields = [
                {"name": name, "base": forms.FileField, "label": label, "required": False, "help_text": help_text}
            ]

            dynaproperties = params_helper.getDynaFields(dynafields)

            add_form = dynaform.newDynaForm(dynabase=base_form, dynaproperties=dynaproperties)

            dynaproperties = {
                "name": django_fields.CharField(label="Name", required=False, widget=widgets.HTMLTextWidget),
                "uploaded": django_fields.CharField(
                    label="Uploaded on", required=False, widget=widgets.PlainTextWidget
                ),
                "size": django_fields.CharField(label="Size", required=False, widget=widgets.PlainTextWidget),
            }
            edit_form = dynaform.extendDynaForm(
                add_form, dynaproperties=dynaproperties, dynainclude=["name", "size", "uploaded", name]
            )

            return add_form, edit_form
Esempio n. 12
0
         'base': forms.ChoiceField,
         'passthrough': ['initial', 'required', 'choices'],
         'label': 'Assign Mentor',
         'choices': choices,
         'required': False,
         'help_text': 'Choose the mentor you would like to assign to this '
             'Proposal. Choose "No mentor" if you don\'t want any '
             'mentor assigned.'
         },
        ]

      dynaproperties = params_helper.getDynaFields(dynafields)
      dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')

      form = dynaform.extendDynaForm(
          dynaform=params['mentor_review_form'], 
          dynaproperties=dynaproperties)

    else:
      # the current user is not an org admin
      if entity.org.scoring_disabled:
        # reviews are disabled, don't show score field
        form = params['locked_review_form']
      else:
        # reviews are enabled, show the score field
        form = params['mentor_review_form']

    if request.method == 'POST':
      return self.reviewPost(request, context, params, entity,
                             form, org_admin_entity, mentor_entity, **kwargs)
    else:
Esempio 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:
      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'] = [('checkHasActiveRoleForKeyFieldsAsScope',
                           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'] = [('checkHasActiveRoleForKeyFieldsAsScope',
                                org_admin_logic.logic)]
    rights['list_roles'] = [('checkHasActiveRoleForKeyFieldsAsScope',
                             org_admin_logic.logic)]
    rights['applicant'] = [('checkIsApplicationAccepted',
                            org_app_logic.logic)]
    rights['list_proposals'] = [('checkHasAny', [
        [('checkHasActiveRoleForKeyFieldsAsScope', [org_admin_logic.logic]),
         ('checkHasActiveRoleForKeyFieldsAsScope', [mentor_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['list_row'] = 'soc/organization/list/row.html'
    new_params['list_heading'] = 'soc/organization/list/heading.html'
    new_params['home_template'] = 'soc/organization/home.html'

    new_params['application_logic'] = org_app_logic
    new_params['group_applicant_url'] = True
    new_params['sans_link_id_public_list'] = True

    new_params['extra_dynaexclude'] = ['slots', 'slots_calculated',
                                       'nr_applications', 'nr_mentors']

    patterns = []

    patterns += [
        (r'^%(url_name)s/(?P<access_type>apply_mentor)/%(scope)s$',
        'soc.views.models.%(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$',
        'soc.views.models.%(module_name)s.list_proposals',
        "List of all Student Proposals for this %(name)s"),
        ]

    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})),
        'contrib_template': forms.fields.CharField(
            widget=helper.widgets.FullTinyMCE(
                attrs={'rows': 25, 'cols': 100})),
        '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',
            soc.logic.models.organization, org_app_logic)
        }

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

    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
Esempio 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:
      params: a dict with params for this View
    """

    rights = access.Checker(params)
    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_prefetch'] = ['user', 'group']
    new_params['public_field_extra'] = publicFieldExtra
    new_params['public_field_keys'] = ['role_name', '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
Esempio 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'] = ['checkIsMyGroupAcceptedRequest']
    rights['list'] = ['checkIsDeveloper']
    rights['delete'] = ['checkIsDeveloper']
    rights['roles'] = ['checkIsUser']

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

    new_params['name'] = "Request"

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

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

    new_params['extra_dynaexclude'] = ['status', 'role_verbose', 'created_on']

    new_params['create_extra_dynaproperties'] = {
        'link_id': widgets.ReferenceField(reference_url='user'),
        'role': forms.CharField(widget=widgets.ReadOnlyInput(),
                                   required=True),
        'clean_link_id': cleaning.clean_existing_user('link_id'),
        }

    new_params['edit_extra_dynaproperties'] = {
        'scope_path': forms.CharField(widget=forms.HiddenInput,
                                        required=True),
        }

    patterns = [(r'^%(url_name)s/(?P<access_type>process_invite)/'
          '%(key_fields)s$',
          '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'

    params = dicts.merge(params, new_params)

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

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

    updated_fields = {
        'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
            required=True),
        'group_id': forms.CharField(widget=widgets.ReadOnlyInput(),
            required=True)}

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

    self._params['request_form'] = request_form
Esempio 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:
      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)]
        rights['applicant'] = [('checkIsApplicationAccepted',
                                org_app_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['list_row'] = 'soc/organization/list/row.html'
        new_params['list_heading'] = 'soc/organization/list/heading.html'
        new_params['home_template'] = 'soc/organization/home.html'

        new_params['application_logic'] = org_app_logic
        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 this %(name)s"),
            (r'^%(url_name)s/(?P<access_type>applicant)/%(key_fields)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
                })),
            'contrib_template':
            forms.fields.CharField(widget=helper.widgets.FullTinyMCE(
                attrs={
                    'rows': 25,
                    'cols': 100
                })),
            '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',
                                        soc.logic.models.organization,
                                        org_app_logic)
        }

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

        new_params['mentor_role_name'] = 'mentor'

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

        params = dicts.merge(params, new_params)

        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_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'])
        }

        # 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
Esempio n. 17
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the program View class
    to provide the user with list, public, create, edit and delete views.

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

    rights = gci_access.GCIChecker(params)
    rights['show'] = ['allow']
    rights['create'] = [('checkSeeded', ['checkHasRoleForScope',
                                         host_logic])]
    rights['edit'] = [('checkIsHostForProgram', [gci_program_logic.logic])]
    rights['delete'] = ['checkIsDeveloper']
    rights['assign_task_quotas'] = [
        ('checkIsHostForProgram', [gci_program_logic.logic])]
    rights['accepted_orgs'] = [('checkIsAfterEvent',
        ['accepted_organization_announced_deadline',
         '__all__', gci_program_logic.logic])]
    rights['list_participants'] = [('checkIsHostForProgram',
                                    [gci_program_logic.logic])]
    rights['task_difficulty'] = [('checkIsHostForProgram',
        [gci_program_logic.logic])]
    rights['task_type'] = [('checkIsHostForProgram',
        [gci_program_logic.logic])]
    rights['type_tag_edit'] = [('checkIsHostForProgram',
        [gci_program_logic.logic])]
    rights['list_self'] = [('checkIsAfterEvent',
        ['tasks_publicly_visible',
         '__all__', gci_program_logic.logic]),
         'checkIsUser']
    rights['list_tasks'] = [('checkIsAfterEvent',
        ['tasks_publicly_visible',
         '__all__', gci_program_logic.logic])]
    rights['show_ranking'] = ['allow']
    rights['request_tasks'] = [
        ('checkHasRoleForKeyFieldsAsScope', [gci_student_logic.logic]),
        ('checkIsAfterEvent', ['tasks_publicly_visible', '__all__',
            gci_program_logic.logic]),
        ('checkIsBeforeEvent', ['task_claim_deadline', '__all__',
            gci_program_logic.logic])]

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

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

    new_params['module_package'] = 'soc.modules.gci.views.models'
    new_params['url_prefix'] = 'gci'
    new_params['url_name'] = 'gci/program'

    new_params['extra_dynaexclude'] = ['task_difficulties', 'task_types',
        'ranking_schema']

    patterns = []
    patterns += [
        (r'^%(url_name)s/(?P<access_type>assign_task_quotas)/%(key_fields)s$',
          '%(module_package)s.%(module_name)s.assign_task_quotas',
          'Assign task quota limits'),
        (r'^%(url_name)s/(?P<access_type>task_difficulty)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.task_difficulty_edit',
         'Edit Task Difficulty Tags'),
        (r'^%(url_name)s/(?P<access_type>task_type)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.task_type_edit',
         'Edit Task Type Tags'),
        (r'^%(url_name)s/(?P<access_type>type_tag_edit)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.task_type_tag_edit',
         'Edit a Task Type Tag'),
        (r'^%(url_name)s/(?P<access_type>list_self)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.list_my_tasks',
         'List of my starred tasks'),
        (r'^%(url_name)s/(?P<access_type>list_tasks)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.list_tasks',
         'List of all Tasks in'),
        (r'^%(url_name)s/(?P<access_type>show_ranking)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.show_ranking',
         'Show ranking'),
        (r'^%(url_name)s/(?P<access_type>request_tasks)/%(key_fields)s$',
         '%(module_package)s.%(module_name)s.request_tasks',
         'Request more tasks'),
        ]

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

    new_params['extra_django_patterns'] = patterns

    new_params['org_app_logic'] = org_app_logic

    # used to list the participants in this program
    new_params['participants_logic'] = [
        (gci_org_admin_logic.logic, 'program'),
        (gci_mentor_logic.logic, 'program'),
        (gci_student_logic.logic, 'scope')]

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

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

    dynafields = [
        {'name': 'overview_task_difficulties',
         'base': forms.CharField,
         'label': 'Task Difficulty Levels',
         'group': 'Task Settings',
         'widget': widgets.ReadOnlyInput(),
         'required': False,
         'help_text': ugettext('Lists all the difficulty levels that '
                               'can be assigned to a task. Edit them '
                               'from the Program menu on sidebar.'),
         },
         {'name': 'overview_task_types',
         'base': forms.CharField,
         'label': 'Task Type Tags',
         'group': 'Task Settings',
         'widget': widgets.ReadOnlyInput(),
         'required': False,
         'help_text': ugettext('Lists all the types a task can be in. '
                               'Edit them from the Program menu on sidebar.'),
         },
        ]

    dynaproperties = params_helper.getDynaFields(dynafields)

    edit_form = dynaform.extendDynaForm(
        dynaform=self._params['edit_form'],
        dynaproperties=dynaproperties)

    self._params['edit_form'] = edit_form
Esempio 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['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
Esempio 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['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
Esempio n. 20
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the program View class
    to provide the user with list, public, create, edit and delete views.

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

        rights = gci_access.GCIChecker(params)
        rights['show'] = ['allow']
        rights['create'] = [('checkSeeded',
                             ['checkHasRoleForScope', host_logic])]
        rights['edit'] = [('checkIsHostForProgram', [gci_program_logic.logic])]
        rights['delete'] = ['checkIsDeveloper']
        rights['assign_task_quotas'] = [('checkIsHostForProgram',
                                         [gci_program_logic.logic])]
        rights['accepted_orgs'] = [('checkIsAfterEvent', [
            'accepted_organization_announced_deadline', '__all__',
            gci_program_logic.logic
        ])]
        rights['list_participants'] = [('checkIsHostForProgram',
                                        [gci_program_logic.logic])]
        rights['task_difficulty'] = [('checkIsHostForProgram',
                                      [gci_program_logic.logic])]
        rights['task_type'] = [('checkIsHostForProgram',
                                [gci_program_logic.logic])]
        rights['type_tag_edit'] = [('checkIsHostForProgram',
                                    [gci_program_logic.logic])]
        rights['list_self'] = [
            ('checkIsAfterEvent',
             ['tasks_publicly_visible', '__all__',
              gci_program_logic.logic]), 'checkIsUser'
        ]
        rights['list_tasks'] = [
            ('checkIsAfterEvent',
             ['tasks_publicly_visible', '__all__', gci_program_logic.logic])
        ]
        rights['show_ranking'] = ['allow']
        rights['request_tasks'] = [
            ('checkHasRoleForKeyFieldsAsScope', [gci_student_logic.logic]),
            ('checkIsAfterEvent',
             ['tasks_publicly_visible', '__all__', gci_program_logic.logic]),
            ('checkIsBeforeEvent',
             ['task_claim_deadline', '__all__', gci_program_logic.logic])
        ]

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

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

        new_params['module_package'] = 'soc.modules.gci.views.models'
        new_params['url_prefix'] = 'gci'
        new_params['url_name'] = 'gci/program'

        new_params['extra_dynaexclude'] = [
            'task_difficulties', 'task_types', 'ranking_schema'
        ]

        patterns = []
        patterns += [
            (r'^%(url_name)s/(?P<access_type>assign_task_quotas)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.assign_task_quotas',
             'Assign task quota limits'),
            (r'^%(url_name)s/(?P<access_type>task_difficulty)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.task_difficulty_edit',
             'Edit Task Difficulty Tags'),
            (r'^%(url_name)s/(?P<access_type>task_type)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.task_type_edit',
             'Edit Task Type Tags'),
            (r'^%(url_name)s/(?P<access_type>type_tag_edit)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.task_type_tag_edit',
             'Edit a Task Type Tag'),
            (r'^%(url_name)s/(?P<access_type>list_self)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.list_my_tasks',
             'List of my starred tasks'),
            (r'^%(url_name)s/(?P<access_type>list_tasks)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.list_tasks',
             'List of all Tasks in'),
            (r'^%(url_name)s/(?P<access_type>show_ranking)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.show_ranking',
             'Show ranking'),
            (r'^%(url_name)s/(?P<access_type>request_tasks)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.request_tasks',
             'Request more tasks'),
        ]

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

        new_params['extra_django_patterns'] = patterns

        new_params['org_app_logic'] = org_app_logic

        # used to list the participants in this program
        new_params['participants_logic'] = [
            (gci_org_admin_logic.logic, 'program'),
            (gci_mentor_logic.logic, 'program'),
            (gci_student_logic.logic, 'scope')
        ]

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

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

        dynafields = [
            {
                'name':
                'overview_task_difficulties',
                'base':
                forms.CharField,
                'label':
                'Task Difficulty Levels',
                'group':
                'Task Settings',
                'widget':
                widgets.ReadOnlyInput(),
                'required':
                False,
                'help_text':
                ugettext('Lists all the difficulty levels that '
                         'can be assigned to a task. Edit them '
                         'from the Program menu on sidebar.'),
            },
            {
                'name':
                'overview_task_types',
                'base':
                forms.CharField,
                'label':
                'Task Type Tags',
                'group':
                'Task Settings',
                'widget':
                widgets.ReadOnlyInput(),
                'required':
                False,
                'help_text':
                ugettext('Lists all the types a task can be in. '
                         'Edit them from the Program menu on sidebar.'),
            },
        ]

        dynaproperties = params_helper.getDynaFields(dynafields)

        edit_form = dynaform.extendDynaForm(dynaform=self._params['edit_form'],
                                            dynaproperties=dynaproperties)

        self._params['edit_form'] = edit_form
Esempio 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'] = [('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
Esempio 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['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkHasActiveRoleForScope', 
                       soc.logic.models.mentor.logic),
        ('checkIsMyEntity', [soc.logic.models.mentor.logic, 'user', True])]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasActiveRoleForScope',
                         soc.logic.models.org_admin.logic)]
    rights['accept_invite'] = [('checkCanCreateFromRequest', 'mentor'),
        'checkIsNotStudentForProgramOfOrg']
    rights['request'] = ['checkIsNotStudentForProgramOfOrg',
        ('checkCanMakeRequestToGroup', org_logic)]
    rights['process_request'] = [
        ('checkHasActiveRoleForScope', soc.logic.models.org_admin.logic),
        ('checkCanProcessRequest', 'mentor')]
    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
    new_params['show_in_roles_overview'] = True

    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._params['module_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=self._params['create_form'],
        dynaproperties=dynaproperties)

    self._params['invited_create_form'] = invited_create_form
Esempio 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'] = ['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'])
Esempio n. 24
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the program View class
    to provide the user with list, public, create, edit and delete views.

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

        rights = ghop_access.GHOPChecker(params)
        rights['show'] = ['allow']
        rights['create'] = [('checkSeeded',
                             ['checkHasRoleForScope', host_logic.logic])]
        rights['edit'] = [('checkIsHostForProgram', [ghop_program_logic.logic])
                          ]
        rights['delete'] = ['checkIsDeveloper']
        rights['accepted_orgs'] = [
            ('checkIsAfterEvent',
             ['student_signup_start', '__all__', ghop_program_logic.logic])
        ]
        rights['task_difficulty'] = [('checkIsHostForProgram',
                                      [ghop_program_logic.logic])]
        rights['task_type'] = [('checkIsHostForProgram',
                                [ghop_program_logic.logic])]
        rights['difficulty_tag_edit'] = [('checkIsHostForProgram',
                                          [ghop_program_logic.logic])]
        rights['type_tag_edit'] = [('checkIsHostForProgram',
                                    [ghop_program_logic.logic])]

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

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

        new_params['module_package'] = 'soc.modules.ghop.views.models'
        new_params['url_name'] = 'ghop/program'

        new_params['extra_dynaexclude'] = ['task_difficulties', 'task_types']

        patterns = []
        patterns += [
            (r'^%(url_name)s/(?P<access_type>assign_task_quotas)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.assign_task_quotas',
             'Assign task quota limits'),
            (r'^%(url_name)s/(?P<access_type>task_difficulty)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.task_difficulty_edit',
             'Edit Task Difficulty Tags'),
            (r'^%(url_name)s/(?P<access_type>task_type)/%(key_fields)s$',
             '%(module_package)s.%(module_name)s.task_type_edit',
             'Edit Task Type Tags'),
            (r'^%(url_name)s/(?P<access_type>difficulty_tag_edit)$',
             '%(module_package)s.%(module_name)s.difficulty_tag_edit',
             'Edit a Difficulty Tag'),
            (r'^%(url_name)s/(?P<access_type>type_tag_edit)$',
             '%(module_package)s.%(module_name)s.task_type_tag_edit',
             'Edit a Task Type Tag'),
        ]

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

        new_params['extra_django_patterns'] = patterns

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

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

        dynafields = [
            {
                'name':
                'overview_task_difficulties',
                'base':
                forms.CharField,
                'label':
                'Task Difficulty Levels',
                'group':
                'Task Settings',
                'widget':
                widgets.ReadOnlyInput(),
                'required':
                False,
                'help_text':
                ugettext('Lists all the difficulty levels that '
                         'can be assigned to a task. Edit them '
                         'from the Program menu on sidebar.'),
            },
            {
                'name':
                'overview_task_types',
                'base':
                forms.CharField,
                'label':
                'Task Type Tags',
                'group':
                'Task Settings',
                'widget':
                widgets.ReadOnlyInput(),
                'required':
                False,
                'help_text':
                ugettext('Lists all the types a task can be in. '
                         'Edit them from the Program menu on sidebar.'),
            },
        ]

        dynaproperties = params_helper.getDynaFields(dynafields)

        edit_form = dynaform.extendDynaForm(dynaform=self._params['edit_form'],
                                            dynaproperties=dynaproperties)

        self._params['edit_form'] = edit_form
Esempio n. 25
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
Esempio 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
    """

    rights = access.Checker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkCanStudentPropose', ['scope_path', False]),
        ('checkRoleAndStatusForStudentProposal',
            [['proposer'], ['active'], ['new', 'pending', 'invalid']])]
    rights['delete'] = ['checkIsDeveloper']
    rights['show'] = [
        ('checkRoleAndStatusForStudentProposal',
            [['proposer', 'org_admin', 'mentor', 'host'], 
            ['active', 'inactive'], 
            ['new', 'pending', 'accepted', 'rejected', 'invalid']])]
    rights['list'] = ['checkIsDeveloper']
    rights['list_orgs'] = [
        ('checkIsStudent', ['scope_path', ['active']]),
        ('checkCanStudentPropose', ['scope_path', False])]
    rights['list_self'] = [
        ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
    rights['apply'] = [
        ('checkIsStudent', ['scope_path', ['active']]),
        ('checkCanStudentPropose', ['scope_path', True])]
    rights['review'] = [('checkRoleAndStatusForStudentProposal',
            [['org_admin', 'mentor', 'host'], 
            ['active'],
            ['new', 'pending', 'accepted', 'rejected', 'invalid']])]

    new_params = {}
    new_params['logic'] = soc.logic.models.student_proposal.logic
    new_params['rights'] = rights
    new_params['name'] = "Student Proposal"
    new_params['url_name'] = "student_proposal"
    new_params['sidebar_grouping'] = 'Students'

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

    new_params['no_create_with_key_fields'] = True
    new_params['list_key_order'] = ['title', 'abstract', 'content',
        'additional_info', 'created_on', 'last_modified_on']

    patterns = [
        (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
        'soc.views.models.%(module_name)s.apply',
        'Create a new %(name)s'),
        (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
        'soc.views.models.%(module_name)s.list_self',
        'List my %(name_plural)s'),
        (r'^%(url_name)s/(?P<access_type>list_orgs)/%(scope)s$',
        'soc.views.models.%(module_name)s.list_orgs',
        'List my %(name_plural)s'),
        (r'^%(url_name)s/(?P<access_type>review)/%(key_fields)s$',
        'soc.views.models.%(module_name)s.review',
        'Review %(name)s'),
    ]

    new_params['extra_django_patterns'] = patterns

    new_params['extra_dynaexclude'] = ['org', 'program', 'score',
                                       'status', 'mentor', 'link_id',
                                       'possible_mentors']

    new_params['create_extra_dynaproperties'] = {
        'content': forms.fields.CharField(required=True,
            widget=widgets.FullTinyMCE(attrs={'rows': 25, 'cols': 100})),
        'scope_path': forms.CharField(widget=forms.HiddenInput,
            required=True),
        'organization': forms.CharField(label='Organization Link ID',
            required=True),
        'clean_abstract': cleaning.clean_content_length('abstract'),
        'clean_content': cleaning.clean_html_content('content'),
        'clean_organization': cleaning.clean_link_id('organization'),
        'clean_additional_info': cleaning.clean_url('additional_info'),
        'clean': cleaning.validate_student_proposal('organization',
            'scope_path', student_logic, org_logic),
        }

    new_params['edit_extra_dynaproperties'] = {
        'organization': forms.CharField(label='Organization Link ID',
            widget=widgets.ReadOnlyInput),
        'link_id': forms.CharField(widget=forms.HiddenInput)
        }

    new_params['edit_template'] = 'soc/student_proposal/edit.html'
    new_params['review_template'] = 'soc/student_proposal/review.html'
    new_params['review_after_deadline_template'] = 'soc/student_proposal/review_after_deadline.html'

    params = dicts.merge(params, new_params)

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

    # create the special form for students
    dynafields = [
        {'name': 'organization',
         'base': forms.CharField,
         'label': 'Organization Link ID',
         'widget': widgets.ReadOnlyInput(),
         'required': False,
         },
        ]

    dynaproperties = params_helper.getDynaFields(dynafields)

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

    self._params['student_create_form'] = student_create_form

    # create the special form for public review
    dynafields = [
        {'name': 'comment',
         'base': forms.CharField,
         'widget': widgets.FullTinyMCE(attrs={'rows': 10, 'cols': 40}),
         'label': 'Comment',
         'required': False,
         'example_text': 'Caution, you will not be able to edit your comment!',
         },
         ]

    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')

    public_review_form = dynaform.newDynaForm(dynamodel=None, 
        dynabase=helper.forms.BaseForm, dynainclude=None, 
        dynaexclude=None, dynaproperties=dynaproperties)
    self._params['public_review_form'] = public_review_form

    # create the special form for mentors
    dynafields = [
        {'name': 'score',
         'base': forms.ChoiceField,
         'label': 'Score',
         'initial': 0,
         'required': False,
         'passthrough': ['initial', 'required', 'choices'],
         'example_text':
             'A score will only be assigned if the review is private!',
         'choices': [(-4,'-4: Wow. This. Sucks.'),
                     (-3,'-3: Needs a lot of work'),
                     (-2,'-2: This is bad'),
                     (-1,'-1: I dont like this'),
                     (0,'0: No score'),
                     (1,'1: Might have potential'),
                     (2,'2: Good'),
                     (3,'3: Almost there'),
                     (4,'4: Made. Of. Awesome.')]
        },
        {'name': 'comment',
         'base': forms.CharField,
         'widget': widgets.FullTinyMCE(attrs={'rows': 10, 'cols': 40}),
         'label': 'Comment',
         'required': False,
         'example_text': 'Caution, you will not be able to edit your review!',
         },
        {'name': 'public',
         'base': forms.BooleanField,
         'label': 'Review visible to Student',
         'initial': False,
         'required': False,
         'help_text': 'By ticking this box the score will not be assigned, '
             'and the review will be visible to the student.',
         },
         ]

    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')

    mentor_review_form = dynaform.newDynaForm(dynamodel=None, 
        dynabase=helper.forms.BaseForm, dynainclude=None, 
        dynaexclude=None, dynaproperties=dynaproperties)
    self._params['mentor_review_form'] = mentor_review_form

    dynafields = [
      {'name': 'rank',
         'base': forms.IntegerField,
         'label': 'Set to rank',
         'help_text':
             'Set this proposal to the given rank (ignores the given score)',
         'example_text': 'A rank will only be assigned if the '
            'review is private!',
         'min_value': 1,
         'required': False,
         'passthrough': ['min_value', 'required', 'help_text'],
      },
      {'name': 'mentor',
       'base': widgets.ReferenceField,
       'passthrough': ['reference_url', 'required', 'label', 'filter'],
       'reference_url': 'mentor',
       'filter': ['__org__'],
       'label': 'Assign Mentor (Link ID)',
       'required': False,
       'help_text': 'Fill in the Link ID of the Mentor '
           'you would like to assign to this Proposal. '
           'Leave this box empty if you don\'t want any mentor assigned.',
      },
      ]

    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')

    admin_review_form = dynaform.extendDynaForm(dynaform=mentor_review_form, 
        dynaproperties=dynaproperties)

    self._params['admin_review_form'] = admin_review_form
Esempio 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['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkIsMyActiveRole', org_admin_logic.logic)]
    rights['delete'] = ['checkIsDeveloper']
    rights['invite'] = [('checkHasRoleForScope',
                         org_admin_logic.logic)]
    rights['accept_invite'] = [
        ('checkIsMyRequestWithStatus', [['group_accepted']]),
        ('checkIsNotStudentForProgramOfOrgInRequest', [org_logic.logic,
                                              student_logic.logic])]
    rights['process_request'] = [
        ('checkCanProcessRequest', [[org_admin_logic.logic]])]
    rights['manage'] = [
        ('checkIsAllowedToManageRole', [org_admin_logic.logic,
             org_admin_logic.logic])]

    new_params = {}
    new_params['logic'] = soc.logic.models.org_admin.logic
    new_params['group_logic'] = org_logic.logic
    new_params['group_view'] = org_view.view
    new_params['rights'] = rights

    new_params['scope_view'] = org_view

    new_params['name'] = "Organization Admin"
    new_params['module_name'] = "org_admin"
    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': 'admin_agreement',
         'base': forms.fields.CharField,
         'required': False,
         'widget': widgets.AgreementField,
         'group': ugettext("5. Terms of Service"),
         },
        {'name': 'agreed_to_admin_agreement',
         'base': forms.fields.BooleanField,
         'initial': False,
         'required':True,
         'label': ugettext('I agree to the Admin Agreement'),
         'group': ugettext("5. Terms of Service"),
         },
        ]

    new_params['allow_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'] = ["Admin Name", "Admin 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': 'admin_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')
Esempio n. 28
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'] = [('checkHasActiveRoleForScope', student_logic.logic),
        ('checkIsMyEntity', [student_logic.logic, 'user', True])]
    rights['delete'] = ['checkIsDeveloper']
    rights['apply'] = [
        'checkIsUser',
        ('checkIsActivePeriod', ['student_signup', 'scope_path']),
        'checkIsNotParticipatingInProgramInScope',
        ]
    rights['manage'] = [
        ('checkIsAllowedToManageRole', [soc.logic.models.host.logic])]
    rights['list_projects'] = [
        ('checkHasActiveRoleForScope', student_logic.logic),
        ('checkIsAfterEvent', ['accepted_students_announced_deadline',
                               'scope_path'])]

    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'

    # add apply pattern
    patterns = [(r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
        'soc.views.models.%(module_name)s.apply',
        'Become a %(name)s'),
        (r'^%(url_name)s/(?P<access_type>list_projects)/%(scope)s$',
        'soc.views.models.%(module_name)s.list_projects',
        'List of my Student Projects'),]

    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)

    new_params['create_extra_dynaproperties'] = {
        'expected_graduation': forms.TypedChoiceField(
            choices=[(x,x) for x in allowed_years],
            coerce=lambda val: int(val)
            )
        } 

    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"),
         },
        ]

    new_params['show_in_roles_overview'] = True

    params = dicts.merge(params, new_params)

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

    # 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 = self._params['create_form'],
        dynaproperties = updated_fields)

    self._params['user_create_form'] = user_create_form
Esempio n. 29
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')
Esempio n. 30
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.GSoCChecker(params)
    rights['create'] = ['checkIsDeveloper']
    rights['edit'] = [('checkCanStudentPropose', ['scope_path', False]),
        ('checkRoleAndStatusForStudentProposal',
            [['proposer'], ['active'], ['new', 'pending', 'invalid']])]
    rights['delete'] = ['checkIsDeveloper']
    rights['private'] = [
        ('checkRoleAndStatusForStudentProposal',
            [['proposer', 'org_admin', 'mentor', 'host'], 
            ['active', 'inactive'], 
            ['new', 'pending', 'accepted', 'rejected', 'invalid']])]
    rights['show'] = ['checkIsStudentProposalPubliclyVisible']
    rights['comment'] = [
        ('checkRoleAndStatusForStudentProposal',
            [['org_admin', 'mentor', 'host'], 
            ['active', 'inactive'],
            ['new', 'pending', 'accepted', 'rejected', 'invalid']])]
    rights['list'] = ['checkIsDeveloper']
    rights['list_orgs'] = [
        ('checkIsStudent', ['scope_path', ['active']]),
        ('checkCanStudentPropose', ['scope_path', False])]
    rights['list_self'] = [
        ('checkIsStudent', ['scope_path', ['active', 'inactive']])]
    rights['apply'] = [
        ('checkIsStudent', ['scope_path', ['active']]),
        ('checkCanStudentPropose', ['scope_path', True])]
    rights['review'] = [
            ('checkIsBeforeEvent',
            ['accepted_students_announced_deadline', None,
             program_logic.logic]),
            ('checkRoleAndStatusForStudentProposal',
            [['org_admin', 'mentor', 'host'], 
            ['active'],
            ['new', 'pending', 'accepted', 'invalid']])]

    new_params = {}
    new_params['logic'] = student_proposal_logic.logic
    new_params['rights'] = rights
    new_params['name'] = "Student Proposal"
    new_params['url_name'] = "gsoc/student_proposal"
    new_params['module_package'] = 'soc.modules.gsoc.views.models'
    new_params['sidebar_grouping'] = 'Students'

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

    new_params['no_create_with_key_fields'] = True

    patterns = [
        (r'^%(url_name)s/(?P<access_type>apply)/%(scope)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.apply',
        'Create a new %(name)s'),
        (r'^%(url_name)s/(?P<access_type>list_self)/%(scope)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.list_self',
        'List my %(name_plural)s'),
        (r'^%(url_name)s/(?P<access_type>list_orgs)/%(scope)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.list_orgs',
        'List my %(name_plural)s'),
        (r'^%(url_name)s/(?P<access_type>review)/%(key_fields)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.review',
        'Review %(name)s'),
        (r'^%(url_name)s/(?P<access_type>public)/%(key_fields)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.public',
        'Public view for %(name)s'),
        (r'^%(url_name)s/(?P<access_type>private)/%(key_fields)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.private',
        'Private view of %(name)s'),
        (r'^%(url_name)s/(?P<access_type>comment)/%(key_fields)s$',
        'soc.modules.gsoc.views.models.%(module_name)s.comment',
        'Comment view of %(name)s'),
    ]

    new_params['extra_django_patterns'] = patterns

    new_params['extra_dynaexclude'] = ['org', 'program', 'score',
                                       'status', 'mentor', 'link_id',
                                       'possible_mentors']

    new_params['create_extra_dynaproperties'] = {
        'content': forms.fields.CharField(required=True,
            widget=widgets.FullTinyMCE(attrs={'rows': 25, 'cols': 100})),
        'scope_path': forms.CharField(widget=forms.HiddenInput,
            required=True),
        'organization': forms.CharField(label='Organization Link ID',
            required=True),
        'clean_abstract': cleaning.clean_content_length('abstract'),
        'clean_content': cleaning.clean_html_content('content'),
        'clean_organization': cleaning.clean_link_id('organization'),
        'clean_additional_info': cleaning.clean_url('additional_info'),
        'clean': cleaning.validate_student_proposal('organization',
            'scope_path', student_logic, org_logic),
        }

    new_params['edit_extra_dynaproperties'] = {
        'organization': forms.CharField(label='Organization Link ID',
            widget=widgets.ReadOnlyInput),
        'link_id': forms.CharField(widget=forms.HiddenInput)
        }

    new_params['comment_template'] = 'soc/student_proposal/comment.html'
    new_params['edit_template'] = 'soc/student_proposal/edit.html'
    new_params['private_template'] = 'soc/student_proposal/private.html'
    new_params['review_template'] = 'soc/student_proposal/review.html'
    new_params['public_template'] = 'soc/student_proposal/public.html'
    new_params['review_after_deadline_template'] = \
        'soc/student_proposal/review_after_deadline.html'

    new_params['public_field_extra'] = lambda entity: {
        "student": entity.scope.name(),
        "organization_name": entity.org.name,
    }
    new_params['public_field_keys'] = [
        "title", "student", "organization_name", "last_modified_on",
    ]
    new_params['public_field_names'] = [
        "Title", "Student", "Organization Name", "Last Modified On",
    ]

    params = dicts.merge(params, new_params)

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

    # create the special form for students
    dynafields = [
        {'name': 'organization',
         'base': forms.CharField,
         'label': 'Organization Link ID',
         'widget': widgets.ReadOnlyInput(),
         'required': False,
         },
        ]

    dynaproperties = params_helper.getDynaFields(dynafields)

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

    self._params['student_create_form'] = student_create_form

    # create the special form for public review
    base_fields = [
        {'name': 'comment',
         'base': forms.CharField,
         'widget': widgets.FullTinyMCE(attrs={'rows': 10, 'cols': 40}),
         'label': 'Comment',
         'required': False,
         'example_text': 'Caution, you will not be able to edit your comment!',
         },
         ]

    dynafields = [field.copy() for field in base_fields]
    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')

    public_review_form = dynaform.newDynaForm(dynamodel=None, 
        dynabase=helper.forms.BaseForm, dynainclude=None, 
        dynaexclude=None, dynaproperties=dynaproperties)
    self._params['public_review_form'] = public_review_form

    # create the special form for mentors when the scoring is locked

    # this fields is used by the on-page JS
    base_fields.append(
        {'name': 'public',
         'base': forms.BooleanField,
         'label': 'Review visible to Student',
         'initial': False,
         'required': False,
         'help_text': 'By ticking this box the score will not be assigned, '
             'and the review will be visible to the student.',
         })

    dynafields = [field.copy() for field in base_fields]
    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')
    locked_review_form = dynaform.newDynaForm(dynamodel=None, 
        dynabase=helper.forms.BaseForm, dynainclude=None, 
        dynaexclude=None, dynaproperties=dynaproperties)
    self._params['locked_review_form'] = locked_review_form

    # create the form for mentors when the scoring is unlocked
    base_fields.append(
        {'name': 'score',
         'base': forms.ChoiceField,
         'label': 'Score',
         'initial': 0,
         'required': False,
         'passthrough': ['initial', 'required', 'choices'],
         'choices': [(-4,'-4'),
                     (-3,'-3'),
                     (-2,'-2'),
                     (-1,'-1'),
                     (0,'No score'),
                     (1,'1'),
                     (2,'2'),
                     (3,'3'),
                     (4,'4')]
        })

    dynafields = [field.copy() for field in base_fields]
    dynaproperties = params_helper.getDynaFields(dynafields)
    dynaproperties['clean_comment'] = cleaning.clean_html_content('comment')
    mentor_review_form = dynaform.newDynaForm(dynamodel=None, 
        dynabase=helper.forms.BaseForm, dynainclude=None, 
        dynaexclude=None, dynaproperties=dynaproperties)
    self._params['mentor_review_form'] = mentor_review_form
    self._show_review_not_appeared_msg = False
Esempio n. 31
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['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)}

    # 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