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

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

        new_params = {}
        new_params['extra_dynaexclude'] = ['tos']

        new_params['edit_extra_dynaproperties'] = {
            'tos_link_id':
            widgets.ReferenceField(
                reference_url='document',
                filter=['scope_path'],
                required=False,
                filter_fields={'prefix': params['document_prefix']},
                label=ugettext('Terms of Service Document link ID'),
                help_text=soc.models.work.Work.link_id.help_text),
            'clean':
            cleaning.clean_refs(params, ['home_link_id', 'tos_link_id']),
        }

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

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

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

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

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

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

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

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

    patterns = []

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

    new_params['extra_django_patterns'] = patterns

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

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

    super(View, self).__init__(params=params)
Exemplo n.º 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['any_access'] = ['allow']
        rights['show'] = ['allow']
        rights['create'] = [('checkSeeded',
                             ['checkHasRoleForScope', host_logic.logic])]
        rights['edit'] = ['checkIsHostForProgram']
        rights['delete'] = ['checkIsDeveloper']
        rights['accepted_orgs'] = [('checkIsAfterEvent', [
            'accepted_organization_announced_deadline', '__all__',
            program_logic.logic
        ])]

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

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

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

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

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

        new_params['extra_django_patterns'] = patterns

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

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

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

        new_params = {}

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

        result = {}

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

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

        new_params['edit_extra_dynaproperties'] = result

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

        new_params['references'] = document_references

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

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

        super(View, self).__init__(params=params)
Exemplo n.º 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.GSoCChecker(params)
        rights['any_access'] = ['allow']
        rights['show'] = ['allow']
        rights['create'] = ['checkIsDeveloper']
        rights['edit'] = [('checkHasRoleForKeyFieldsAsScope', org_admin_logic),
                          ('checkGroupIsActiveForLinkId', org_logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['home'] = ['allow']
        rights['public_list'] = ['allow']
        rights['applicant'] = [('checkIsOrgAppAccepted', org_app_logic)]
        rights['apply_mentor'] = ['checkIsUser']
        rights['list_requests'] = [('checkHasRoleForKeyFieldsAsScope',
                                    org_admin_logic)]
        rights['list_roles'] = [('checkHasRoleForKeyFieldsAsScope',
                                 org_admin_logic)]
        rights['list_proposals'] = [
            ('checkHasAny', [[('checkHasRoleForKeyFieldsAsScope',
                               [org_admin_logic, ['active', 'inactive']]),
                              ('checkHasRoleForKeyFieldsAsScope',
                               [mentor_logic, ['active', 'inactive']])]])
        ]

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

        new_params['scope_view'] = program_view

        new_params['name'] = "GSoC Organization"
        new_params['module_name'] = "organization"
        new_params['sidebar_grouping'] = 'Organizations'

        new_params['module_package'] = 'soc.modules.gsoc.views.models'
        new_params['url_name'] = 'gsoc/org'
        new_params['document_prefix'] = 'gsoc_org'

        new_params['mentor_role_name'] = 'gsoc_mentor'
        new_params['mentor_url_name'] = 'gsoc/mentor'
        new_params['org_admin_role_name'] = 'gsoc_org_admin'

        patterns = []

        patterns += [
            (r'^org_tags/(?P<access_type>pick)$',
             '%(module_package)s.%(module_name)s.pick_suggested_tags',
             "Pick a list of suggested tags."),
        ]

        new_params['extra_django_patterns'] = patterns

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

        new_params['create_extra_dynaproperties'] = {
            'tags':
            widgets.ReferenceField(
                required=False,
                reference_url='org_tags',
                label=ugettext('Tags'),
                help_text=ugettext("A list of comma seperated tags"),
                example_text="e.g. python, django, appengine",
                filter=['scope_path'],
                group="1. Public Info"),
            'clean_tags':
            gsoc_cleaning.cleanTagsList('tags', gsoc_cleaning.COMMA_SEPARATOR),
            'contrib_template':
            forms.fields.CharField(widget=helper.widgets.FullTinyMCE(
                attrs={
                    'rows': 25,
                    'cols': 100
                })),
            'clean_contrib_template':
            cleaning.clean_html_content('contrib_template'),
            'clean_facebook':
            cleaning.clean_url('facebook'),
            'clean_twitter':
            cleaning.clean_url('twitter'),
            'clean_blog':
            cleaning.clean_url('blog'),
        }

        new_params['org_app_logic'] = org_app_logic

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

        super(View, self).__init__(params)

        self._params['public_field_keys'].append('tags')
        self._params['public_field_names'].append("Tags")
        self._params['public_field_extra'] = lambda entity: {
            'ideas': lists.urlize(entity.ideas, 'Click Here'),
            'tags': entity.tags_string(entity.org_tag),
        }
        self._params['select_field_extra'] = self._params['public_field_extra']
Exemplo n.º 5
0
  def __init__(self, params=None):
    """Defines the fields and methods required for the base View class
    to provide the user with list, public, create, edit and delete views.

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

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

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

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

    new_params['sidebar_developer'] = []

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

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

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

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

    patterns = []

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

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

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

    new_params['extra_django_patterns'] = patterns

    params = dicts.merge(params, new_params)

    super(View, self).__init__(params=params)
Exemplo n.º 6
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