Esempio n. 1
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the task_subscription.

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

        rights = ghop_access.GHOPChecker(params)
        rights['subscribe'] = ['checkIsUser']

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

        new_params['name'] = "Task Subscription"
        new_params['module_name'] = "task_subscription"

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

        patterns = []
        patterns += [
            (r'^%(url_name)s/(?P<access_type>subscribe)$',
             '%(module_package)s.%(module_name)s.subscribe',
             'Subscribe to the %(name)s'),
        ]

        new_params['extra_django_patterns'] = patterns

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

        super(View, self).__init__(params=params)
Esempio n. 2
0
    def __init__(self, params=None):
        """Defines the fields and methods required for the mentor 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['create'] = ['checkIsDeveloper']
        rights['edit'] = [('checkIsMyActiveRole', ghop_mentor_logic.logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['invite'] = [('checkHasRoleForScope',
                             ghop_org_admin_logic.logic)]
        rights['accept_invite'] = [
            ('checkIsMyRequestWithStatus', [['group_accepted']]),
            ('checkIsNotStudentForProgramOfOrgInRequest',
             [ghop_org_logic.logic, ghop_student_logic.logic])
        ]
        rights['request'] = [
            ('checkIsNotStudentForProgramOfOrg',
             [ghop_org_logic.logic, ghop_student_logic.logic]),
            ('checkCanMakeRequestToGroup', ghop_org_logic.logic)
        ]
        rights['process_request'] = [('checkCanProcessRequest',
                                      [[ghop_org_admin_logic.logic]])]
        rights['manage'] = [
            ('checkIsAllowedToManageRole',
             [ghop_mentor_logic.logic, ghop_org_admin_logic.logic])
        ]

        new_params = {}
        new_params['logic'] = soc.modules.ghop.logic.models.mentor.logic
        new_params['group_logic'] = ghop_org_logic.logic
        new_params['group_view'] = ghop_org_view.view
        new_params['rights'] = rights

        new_params['scope_view'] = ghop_org_view

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

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

        new_params['role'] = 'ghop/mentor'

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

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

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

        patterns = []
        patterns += [
            (r'^%(url_name)s/(?P<access_type>list_student_tasks)/%(scope)s$',
             '%(module_package)s.%(module_name)s.list_student_tasks',
             'List Student tasks')
        ]

        rights = ghop_access.GHOPChecker(params)
        rights['edit'] = [('checkIsMyActiveRole', ghop_student_logic.logic)]
        rights['apply'] = [
            'checkIsUser',
            ('checkIsActivePeriod',
             ['student_signup', 'scope_path', ghop_program_logic.logic]),
            ('checkIsNotParticipatingInProgramInScope', [
                ghop_program_logic.logic, ghop_student_logic.logic,
                ghop_org_admin_logic.logic, ghop_mentor_logic.logic
            ]), 'checkCanApply'
        ]
        rights['manage'] = [('checkIsMyActiveRole', ghop_student_logic.logic)]
        rights['list_student_tasks'] = ['checkCanOpenTaskList']

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

        new_params['group_logic'] = ghop_program_logic.logic
        new_params['group_view'] = ghop_program_view.view

        new_params['scope_view'] = ghop_program_view

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

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

        new_params['extra_django_patterns'] = patterns

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

        super(View, self).__init__(params=params)
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.GHOPChecker(params)
        rights['any_access'] = ['allow']
        rights['show'] = ['checkIsDeveloper']
        rights['create'] = [('checkIsHostForProgramInScope', program_logic)]
        rights['edit'] = [('checkIsHostForProgramInScope', program_logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['list'] = ['checkIsDeveloper']
        rights['list_self'] = ['checkIsUser']
        rights['record'] = [('checkHasAny', [[('checkIsMyOrgAppRecord', []),
                                              ('checkIsSurveyReadable',
                                               [org_app_logic])]])]
        rights['results'] = [('checkIsHostForProgramInScope', program_logic)]
        rights['take'] = [
            'checkOrgAppRecordIfPresent',
            ('checkIsActivePeriod',
             ['org_signup', 'scope_path', program_logic]),
            ('checkIsNotStudentForProgramInScope',
             [program_logic, student_logic])
        ]

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

        new_params['scope_view'] = program_view

        new_params['name'] = "GHOP Org Application Survey"
        new_params['url_name'] = 'ghop/org_app'
        new_params['module_package'] = 'soc.modules.ghop.views.models'
        new_params['module_name'] = 'org_app_survey'

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

        super(View, self).__init__(params=params)
Esempio n. 5
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['edit'] = [('checkCanEditTimeline', [ghop_program_logic.logic])]

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

        new_params['name'] = "GHOP Timeline"
        new_params['module_name'] = "timeline"

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

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

        super(View, self).__init__(params=params)
Esempio n. 6
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. 7
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['create'] = ['checkIsDeveloper']
        rights['edit'] = [(
            'checkHasRoleForKeyFieldsAsScope',
            ghop_org_admin_logic.logic,
        ), ('checkGroupIsActiveForLinkId', ghop_org_logic.logic)]
        rights['delete'] = ['checkIsDeveloper']
        rights['home'] = ['allow']
        rights['public_list'] = ['allow']
        rights['apply_mentor'] = ['checkIsUser']
        rights['list_requests'] = [('checkHasRoleForKeyFieldsAsScope',
                                    ghop_org_admin_logic.logic)]
        rights['list_roles'] = [('checkHasRoleForKeyFieldsAsScope',
                                 ghop_org_admin_logic.logic)]

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

        new_params['scope_view'] = ghop_program_view

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

        new_params['public_template'] = 'modules/ghop/organization/public.html'
        new_params['list_row'] = 'modules/ghop/organization/list/row.html'
        new_params[
            'list_heading'] = 'modules/ghop/organization/list/heading.html'
        new_params['home_template'] = 'modules/ghop/organization/home.html'

        new_params['module_package'] = 'soc.modules.ghop.views.models'
        new_params['url_name'] = 'ghop/org'
        new_params['document_prefix'] = 'ghop_org'

        new_params['extra_dynaexclude'] = [
            'slots', 'slots_calculated', 'nr_applications', 'nr_mentors',
            'slots_desired', 'ideas', 'task_quota_limit'
        ]

        new_params['mentor_role_name'] = 'ghop_mentor'
        new_params['mentor_url_name'] = 'ghop/mentor'

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

        new_params['public_field_extra'] = lambda entity: {
            "open_tasks":
            str(
                len(
                    ghop_task_logic.logic.getForFields({
                        'scope':
                        entity,
                        'status': ['Open', 'Reopened']
                    }))),
            "claimed_tasks":
            str(
                len(
                    ghop_task_logic.logic.getForFields({
                        'scope':
                        entity,
                        'status': [
                            'ClaimRequested', 'Claimed', 'ActionNeeded',
                            'NeedsReview', 'NeedsWork'
                        ],
                    }))),
            "closed_tasks":
            str(
                len(
                    ghop_task_logic.logic.getForFields({
                        'scope':
                        entity,
                        'status': ['AwaitingRegistration', 'Closed'],
                    }))),
            "home_page":
            lists.urlize(entity.home_page),
        }
        new_params['public_field_keys'] = [
            "name",
            "task_quota_limit",
            "open_tasks",
            "claimed_tasks",
            "closed_tasks",
            "home_page",
        ]
        new_params['public_field_names'] = [
            "Name",
            "Tasks Quota",
            "Open Tasks",
            "Claimed Tasks",
            "Closed Tasks",
            "Home Page",
        ]

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

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