Пример #1
0
  def _getExtraMenuItems(self, role_description, params=None):
    """Used to create the specific Sponsor menu entries.

    For args see group.View._getExtraMenuItems().
    """

    submenus = []

    group_entity = role_description['group']
    roles = role_description['roles']
  
    if roles.get('host'):
      # add a link to create a new program
      submenu = (redirects.getCreateRedirect(group_entity,
          {'url_name': 'program'}),"Create a New Program", 'any_access')
      submenus.append(submenu)

      # add a link to the management page
      submenu = (redirects.getListRolesRedirect(group_entity, params), 
          "Manage Program Administrators", 'any_access')
      submenus.append(submenu)

      # add a link to invite an a host
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'host'), 
          "Invite a Program Administrator", 'any_access')
      submenus.append(submenu)

      # add a link to the request page
      submenu = (redirects.getListRequestsRedirect(group_entity, params), 
          "List Program Administrator Invites", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(group_entity, params), 
          "Edit Program Owner Profile", 'any_access')
      submenus.append(submenu)

      # add a link to resign as a host
      submenu = (redirects.getManageRedirect(roles['host'], 
          {'url_name': 'host'}), 
          "Resign as Program Administrator", 'any_access')
      submenus.append(submenu)

      # add a link to create a new document
      submenu = (redirects.getCreateDocumentRedirect(group_entity, 'sponsor'),
          "Create a New Document", 'any_access')
      submenus.append(submenu)

      # add a link to list all documents
      submenu = (redirects.getListDocumentsRedirect(group_entity, 'sponsor'),
          "List Documents", 'any_access')
      submenus.append(submenu)

    return submenus
Пример #2
0
  def _getExtraMenuItems(self, role_description, params=None):
    """Used to create the specific Sponsor menu entries.

    For args see group.View._getExtraMenuItems().
    """

    submenus = []

    group_entity = role_description['group']
    roles = role_description['roles']
  
    if roles.get('host'):
      # add a link to create a new program
      submenu = (redirects.getCreateRedirect(group_entity,
          {'url_name': 'program'}),"Create a New Program", 'any_access')
      submenus.append(submenu)

      # add a link to the management page
      submenu = (redirects.getListRolesRedirect(group_entity, params), 
          "Manage Program Administrators", 'any_access')
      submenus.append(submenu)

      # add a link to invite an a host
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'host'), 
          "Invite a Program Administrator", 'any_access')
      submenus.append(submenu)

      # add a link to the request page
      submenu = (redirects.getListRequestsRedirect(group_entity, params), 
          "List Program Administrator Invites", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(group_entity, params), 
          "Edit Program Owner Profile", 'any_access')
      submenus.append(submenu)

      # add a link to resign as a host
      submenu = (redirects.getManageRedirect(roles['host'], 
          {'url_name': 'host'}), 
          "Resign as Program Administrator", 'any_access')
      submenus.append(submenu)

      # add a link to create a new document
      submenu = (redirects.getCreateDocumentRedirect(group_entity, 'sponsor'),
          "Create a New Document", 'any_access')
      submenus.append(submenu)

      # add a link to list all documents
      submenu = (redirects.getListDocumentsRedirect(group_entity, 'sponsor'),
          "List Documents", 'any_access')
      submenus.append(submenu)

    return submenus
Пример #3
0
  def manageOverview(self, request, access_type,
             page_name=None, params=None, **kwargs):
    """View that allows Organization Admins to see an overview of 
       their Organization's Student Projects.

    For params see base.View().public()
    """

    from soc.modules.gsoc.logic.models.survey import grading_logic as \
        grading_survey_logic
    from soc.modules.gsoc.logic.models.survey import project_logic as \
        project_survey_logic
    from soc.modules.gsoc.logic.models.survey_record import grading_logic
    from soc.modules.gsoc.logic.models.survey_record import project_logic

    # make sure the organization exists
    org_entity = org_logic.getFromKeyNameOr404(kwargs['scope_path'])
    page_name = '%s %s' % (page_name, org_entity.name)

    mo_params = params.copy()
    mo_params['list_heading'] = params['manage_overview_heading']
    mo_params['list_row'] = params['manage_overview_row']

    #list all active projects
    mo_params['list_description'] = \
        'List of all active %(name_plural)s' % mo_params
    mo_params['public_field_names'] = params['public_field_names'] + [
        "Mentor evaluation", "Student Evaluation"]
    mo_params['public_field_keys'] = params['public_field_keys'] + [
        "mentor_evaluation", "student_evaluation"]
    mo_params['public_row_extra'] = lambda entity, *args: {
        'link': redirects.getManageRedirect(entity, mo_params)
    }
    mo_params['public_field_extra'] = lambda entity, ps, psc, gs, gsc: {
        "student": entity.student.name(),
        "mentor": entity.mentor.name(),
        "mentor_evaluation": "%d/%d" % (
                project_logic.getQueryForFields({'project': entity}).count(),
                psc),
        "student_evaluation": "%d/%d" % (
                grading_logic.getQueryForFields({'project': entity}).count(),
                gsc),
    }

    if request.GET.get('fmt') == 'json':
      return self.getManageOverviewData(request, mo_params, org_entity)

    mo_list = lists.getListGenerator(request, mo_params, idx=0)
    contents = [mo_list]

    # call the _list method from base to display the list
    return self._list(request, mo_params, contents, page_name)
Пример #4
0
  def listRoles(self, request, access_type,
                page_name=None, params=None, **kwargs):
    """Gives an overview of all the roles in a specific group.

    Args:
      request: the standard Django HTTP request object
      access_type : the name of the access type which should be checked
      page_name: the page name displayed in templates as page and header title
      params: a dict with params for this View
      kwargs: the Key Fields for the specified entity
    """

    # set the pagename to include the link_id
    page_name = '%s %s' % (page_name, kwargs['link_id'])

    role_views = params['role_views']

    lists_params = []

    for role_name in sorted(role_views.keys()):
      # create the list parameters
      list_params = role_views[role_name].getParams().copy()

      list_params['public_row_extra'] = lambda entity: {
          'link': redirects.getManageRedirect(entity, list_params)
      }
      list_params['list_description'] = ugettext(
          "An overview of the %s for this %s." % (
          list_params['name_plural'], params['name']))

      lists_params.append(list_params)

    if request.GET.get('fmt') == 'json':
      group_logic = params['logic']
      group_entity = group_logic.getFromKeyFields(kwargs)
      return self.getListRolesData(request, lists_params, group_entity)

    contents = []

    index = 0
    for list_params in lists_params:
      list = list_helper.getListGenerator(request, list_params, idx=index)
      contents.append(list)
      index += 1

    # call the _list method from base.View to show the list
    return self._list(request, params, contents, page_name)
Пример #5
0
    def _getStudentEntries(self, program_entity, student_entity, params, id,
                           user, prefix):
        """Returns a list with menu items for students in a specific program.
    """

        items = []

        if timeline_helper.isBeforeEvent(program_entity.timeline, 'program_end') \
            and student_entity.status == 'active':
            items += [
                (redirects.getEditRedirect(student_entity,
                                           {'url_name': prefix + '/student'}),
                 "Edit my Student Profile", 'any_access')
            ]

            items += [(redirects.getManageRedirect(
                student_entity, {'url_name': prefix + '/student'}),
                       "Resign as a Student", 'any_access')]

        return items
Пример #6
0
    def _getStudentEntries(self, program_entity, student_entity, params, id,
                           user, prefix):
        """Returns a list with menu items for students in a specific program.
    """

        items = []

        timeline_entity = program_entity.timeline

        if timeline_helper.isActivePeriod(timeline_entity, 'student_signup') and \
            student_entity.status == 'active':
            items += [('/gsoc/student_proposal/list_orgs/%s' %
                       (student_entity.key().id_or_name()),
                       "Submit your Student Proposal", 'any_access')]

        if timeline_helper.isAfterEvent(timeline_entity,
                                        'student_signup_start'):
            items += [(redirects.getListSelfRedirect(
                student_entity, {'url_name': prefix + '/student_proposal'}),
                       "List my Student Proposals", 'any_access')]

        if timeline_helper.isAfterEvent(
                timeline_entity, 'accepted_students_announced_deadline'):
            # add a link to show all projects
            items += [(redirects.getListProjectsRedirect(
                program_entity, {'url_name': prefix + '/student'}),
                       "List my Student Projects", 'any_access')]

        if timeline_helper.isBeforeEvent(program_entity.timeline, 'program_end') \
            and student_entity.status == 'active':
            items += [(redirects.getManageRedirect(
                student_entity, {'url_name': prefix + '/student'}),
                       "Resign as a Student", 'any_access')]

        items += super(View,
                       self)._getStudentEntries(program_entity, student_entity,
                                                params, id, user, prefix)

        return items
Пример #7
0
  def _getStudentEntries(self, program_entity, student_entity,
                         params, id, user, prefix):
    """Returns a list with menu items for students in a specific program.
    """

    items = []

    timeline_entity = program_entity.timeline

    if timeline_helper.isActivePeriod(timeline_entity, 'student_signup') and \
        student_entity.status == 'active':
      items += [('/gsoc/student_proposal/list_orgs/%s' % (
          student_entity.key().id_or_name()),
          "Submit your Student Proposal", 'any_access')]

    if timeline_helper.isAfterEvent(timeline_entity, 'student_signup_start'):
      items += [(redirects.getListSelfRedirect(student_entity,
          {'url_name': prefix + '/student_proposal'}),
          "List my Student Proposals", 'any_access')]

    if timeline_helper.isAfterEvent(timeline_entity,
                                   'accepted_students_announced_deadline'):
      # add a link to show all projects
      items += [(redirects.getListProjectsRedirect(program_entity,
          {'url_name': prefix + '/student'}),
          "List my Student Projects", 'any_access')]

    if timeline_helper.isBeforeEvent(program_entity.timeline, 'program_end') \
        and student_entity.status == 'active':
      items += [(redirects.getManageRedirect(student_entity,
          {'url_name': prefix + '/student'}),
          "Resign as a Student", 'any_access')]

    items += super(View, self)._getStudentEntries(program_entity,
        student_entity, params, id, user, prefix)

    return items
Пример #8
0
    def _getExtraMenuItems(self, role_description, params=None):
        """Used to create the specific GCI Organization menu entries.

    For args see soc.views.models.organization.View._getExtraMenuItems().
    """
        submenus = []

        group_entity = role_description["group"]
        roles = role_description["roles"]

        mentor_entity = roles.get("gci_mentor")
        admin_entity = roles.get("gci_org_admin")

        is_active_mentor = mentor_entity and mentor_entity.status == "active"
        is_active_admin = admin_entity and admin_entity.status == "active"

        if admin_entity or mentor_entity:
            # add a link to view all the organization tasks.
            submenu = (
                gci_redirects.getListTasksRedirect(group_entity, {"url_name": "gci/task"}),
                "View all Tasks",
                "any_access",
            )
            submenus.append(submenu)

        if is_active_admin:
            # add a link to create task
            submenu = (
                redirects.getCreateRedirect(group_entity, {"url_name": "gci/task"}),
                "Create a Task",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to bulk create tasks
            submenu = (
                gci_redirects.getBulkCreateRedirect(group_entity, {"url_name": "gci/task"}),
                "Bulk Create Tasks",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to the management page
            submenu = (redirects.getListRolesRedirect(group_entity, params), "Manage Admins and Mentors", "any_access")
            submenus.append(submenu)

            # add a link to invite an org admin
            submenu = (
                redirects.getInviteRedirectForRole(group_entity, "gci/org_admin"),
                "Invite an Admin",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to invite a member
            submenu = (redirects.getInviteRedirectForRole(group_entity, "gci/mentor"), "Invite a Mentor", "any_access")
            submenus.append(submenu)

            # add a link to the request page
            submenu = (
                redirects.getListRequestsRedirect(group_entity, params),
                "List Requests and Invites",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(group_entity, params), "Edit Organization Profile", "any_access")
            submenus.append(submenu)

        if is_active_mentor:
            # add a link to suggest task
            submenu = (
                gci_redirects.getSuggestTaskRedirect(group_entity, {"url_name": "gci/task"}),
                "Suggest a Task",
                "any_access",
            )
            submenus.append(submenu)

        if is_active_admin or is_active_mentor:
            submenu = (
                redirects.getCreateDocumentRedirect(group_entity, "gci_org"),
                "Create a New Document",
                "any_access",
            )
            submenus.append(submenu)

            submenu = (redirects.getListDocumentsRedirect(group_entity, "gci_org"), "List Documents", "any_access")
            submenus.append(submenu)

        if is_active_admin:
            # add a link to the resign page
            submenu = (
                redirects.getManageRedirect(roles["gci_org_admin"], {"url_name": "gci/org_admin"}),
                "Resign as Admin",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (
                redirects.getEditRedirect(roles["gci_org_admin"], {"url_name": "gci/org_admin"}),
                "Edit My Admin Profile",
                "any_access",
            )
            submenus.append(submenu)

        if is_active_mentor:
            # add a link to the resign page
            submenu = (
                redirects.getManageRedirect(roles["gci_mentor"], {"url_name": "gci/mentor"}),
                "Resign as Mentor",
                "any_access",
            )
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (
                redirects.getEditRedirect(roles["gci_mentor"], {"url_name": "gci/mentor"}),
                "Edit My Mentor Profile",
                "any_access",
            )
            submenus.append(submenu)

        return submenus
Пример #9
0
    def _getExtraMenuItems(self, role_description, params=None):
        """Used to create the specific Organization menu entries.

    For args see group.View._getExtraMenuItems().
    """
        submenus = []

        group_entity = role_description['group']
        program_entity = group_entity.scope
        roles = role_description['roles']

        mentor_entity = roles.get('mentor')
        admin_entity = roles.get('org_admin')

        is_active_mentor = mentor_entity and mentor_entity.status == 'active'
        is_active_admin = admin_entity and admin_entity.status == 'active'

        if admin_entity or mentor_entity:
            # add a link to view all the student proposals
            submenu = (redirects.getListProposalsRedirect(
                group_entity,
                params), "View all Student Proposals", 'any_access')
            submenus.append(submenu)

        if admin_entity:
            # add a link to manage student projects after they have been announced
            if timeline_helper.isAfterEvent(
                    program_entity.timeline,
                    'accepted_students_announced_deadline'):
                submenu = (redirects.getManageOverviewRedirect(
                    group_entity, {'url_name': 'gsoc/student_project'}),
                           "Manage Student Projects", 'any_access')
                submenus.append(submenu)

        if is_active_admin:
            # add a link to the management page
            submenu = (redirects.getListRolesRedirect(group_entity, params),
                       "Manage Admins and Mentors", 'any_access')
            submenus.append(submenu)

            # add a link to invite an org admin
            submenu = (redirects.getInviteRedirectForRole(
                group_entity,
                'gsoc/org_admin'), "Invite an Admin", 'any_access')
            submenus.append(submenu)

            # add a link to invite a member
            submenu = (redirects.getInviteRedirectForRole(
                group_entity, 'gsoc/mentor'), "Invite a Mentor", 'any_access')
            submenus.append(submenu)

            # add a link to the request page
            submenu = (redirects.getListRequestsRedirect(group_entity, params),
                       "List Requests and Invites", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(group_entity, params),
                       "Edit Organization Profile", 'any_access')
            submenus.append(submenu)

        if is_active_admin or is_active_mentor:
            submenu = (redirects.getCreateDocumentRedirect(
                group_entity, params['document_prefix']),
                       "Create a New Document", 'any_access')
            submenus.append(submenu)

            submenu = (redirects.getListDocumentsRedirect(
                group_entity,
                params['document_prefix']), "List Documents", 'any_access')
            submenus.append(submenu)

        if is_active_admin:
            # add a link to the resign page
            submenu = (redirects.getManageRedirect(
                roles['org_admin'], {'url_name': 'gsoc/org_admin'}),
                       "Resign as Admin", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(
                roles['org_admin'], {'url_name': 'gsoc/org_admin'}),
                       "Edit My Admin Profile", 'any_access')
            submenus.append(submenu)

        if is_active_mentor:
            # add a link to the resign page
            submenu = (redirects.getManageRedirect(
                roles['mentor'],
                {'url_name': 'gsoc/mentor'}), "Resign as Mentor", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(roles['mentor'],
                                                 {'url_name': 'gsoc/mentor'}),
                       "Edit My Mentor Profile", 'any_access')
            submenus.append(submenu)

        return submenus
Пример #10
0
  def _getExtraMenuItems(self, role_description, params=None):
    """Used to create the specific Organization menu entries.

    For args see group.View._getExtraMenuItems().
    """
    submenus = []

    group_entity = role_description['group']
    program_entity = group_entity.scope
    roles = role_description['roles']

    if roles.get('org_admin') or roles.get('mentor'):
      # add a link to view all the student proposals
      submenu = (redirects.getListProposalsRedirect(group_entity, params),
          "View all Student Proposals", 'any_access')
      submenus.append(submenu)


    if roles.get('org_admin'):
      # add a link to manage student projects after they have been announced
      if timeline_helper.isAfterEvent(program_entity.timeline,
                                     'accepted_students_announced_deadline'):
        submenu = (redirects.getManageOverviewRedirect(group_entity,
            {'url_name': 'student_project'}),
            "Manage Student Projects", 'any_access')
        submenus.append(submenu)

      # add a link to the management page
      submenu = (redirects.getListRolesRedirect(group_entity, params),
          "Manage Admins and Mentors", 'any_access')
      submenus.append(submenu)

      # add a link to invite an org admin
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'org_admin'),
          "Invite an Admin", 'any_access')
      submenus.append(submenu)

      # add a link to invite a member
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'mentor'),
          "Invite a Mentor", 'any_access')
      submenus.append(submenu)

      # add a link to the request page
      submenu = (redirects.getListRequestsRedirect(group_entity, params),
          "List Requests and Invites", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(group_entity, params),
          "Edit Organization Profile", 'any_access')
      submenus.append(submenu)

    if roles.get('org_admin') or roles.get('mentor'):
      submenu = (redirects.getCreateDocumentRedirect(group_entity, 'org'),
          "Create a New Document", 'any_access')
      submenus.append(submenu)

      submenu = (redirects.getListDocumentsRedirect(group_entity, 'org'),
          "List Documents", 'any_access')
      submenus.append(submenu)


    if roles.get('org_admin'):
      # add a link to the resign page
      submenu = (redirects.getManageRedirect(roles['org_admin'],
          {'url_name': 'org_admin'}),
          "Resign as Admin", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(roles['org_admin'],
          {'url_name': 'org_admin'}),
          "Edit My Admin Profile", 'any_access')
      submenus.append(submenu)


    if roles.get('mentor'):
      # add a link to the resign page
      submenu = (redirects.getManageRedirect(roles['mentor'],
          {'url_name' : 'mentor'}),
          "Resign as Mentor", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(roles['mentor'],
          {'url_name': 'mentor'}),
          "Edit My Mentor Profile", 'any_access')
      submenus.append(submenu)

    return submenus
Пример #11
0
    def _getExtraMenuItems(self, role_description, params=None):
        """Used to create the specific club menu entries.

    For args see group.View._getExtraMenuItems().
    """

        submenus = []

        group_entity = role_description['group']
        roles = role_description['roles']

        if roles.get('club_admin'):
            # add a link to the management page
            submenu = (redirects.getListRolesRedirect(group_entity, params),
                       "Manage Admins and Members", 'any_access')
            submenus.append(submenu)

            # add a link to invite an admin
            submenu = (redirects.getInviteRedirectForRole(
                group_entity, 'club_admin'), "Invite an Admin", 'any_access')
            submenus.append(submenu)

            # add a link to invite a member
            submenu = (redirects.getInviteRedirectForRole(
                group_entity, 'club_member'), "Invite a Member", 'any_access')
            submenus.append(submenu)

            # add a link to the request page
            submenu = (redirects.getListRequestsRedirect(group_entity, params),
                       "List Requests and Invites", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(group_entity, params),
                       "Edit Club Profile", 'any_access')
            submenus.append(submenu)

        if roles.get('club_member') or roles.get('club_admin'):
            submenu = (redirects.getCreateDocumentRedirect(
                group_entity, 'club'), "Create a New Document", 'any_access')
            submenus.append(submenu)

            submenu = (redirects.getListDocumentsRedirect(
                group_entity, 'club'), "List Documents", 'any_access')
            submenus.append(submenu)

        if roles.get('club_admin'):
            # add a link to resign as club admin
            submenu = (redirects.getManageRedirect(roles['club_admin'],
                                                   {'url_name': 'club_admin'}),
                       "Resign as Club Admin", 'any_access')
            submenus.append(submenu)

        if roles.get('club_member'):
            # add a link to resign as club member
            submenu = (redirects.getManageRedirect(
                roles['club_member'], {'url_name': 'club_member'}),
                       "Resign as Club Member", 'any_access')
            submenus.append(submenu)

        return submenus
Пример #12
0
  def _getExtraMenuItems(self, role_description, params=None):
    """Used to create the specific club menu entries.

    For args see group.View._getExtraMenuItems().
    """

    submenus = []

    group_entity = role_description['group']
    roles = role_description['roles']
  
    if roles.get('club_admin'):
      # add a link to the management page
      submenu = (redirects.getListRolesRedirect(group_entity, params),
          "Manage Admins and Members", 'any_access')
      submenus.append(submenu)

      # add a link to invite an admin
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'club_admin'),
          "Invite an Admin", 'any_access')
      submenus.append(submenu)

      # add a link to invite a member
      submenu = (redirects.getInviteRedirectForRole(group_entity, 
          'club_member'), "Invite a Member", 'any_access')
      submenus.append(submenu)

      # add a link to the request page
      submenu = (redirects.getListRequestsRedirect(group_entity, params), 
          "List Requests and Invites", 'any_access')
      submenus.append(submenu)

      # add a link to the edit page
      submenu = (redirects.getEditRedirect(group_entity, params), 
          "Edit Club Profile", 'any_access')
      submenus.append(submenu)

    if roles.get('club_member') or roles.get('club_admin'):
      submenu = (redirects.getCreateDocumentRedirect(group_entity, 'club'),
          "Create a New Document", 'any_access')
      submenus.append(submenu)

      submenu = (redirects.getListDocumentsRedirect(group_entity, 'club'),
          "List Documents", 'any_access')
      submenus.append(submenu)

    if roles.get('club_admin'):
      # add a link to resign as club admin
      submenu = (redirects.getManageRedirect(roles['club_admin'], 
          {'url_name': 'club_admin'}), 
          "Resign as Club Admin", 'any_access')
      submenus.append(submenu)

    if roles.get('club_member'):
      # add a link to resign as club member
      submenu = (redirects.getManageRedirect(roles['club_member'], 
          {'url_name' : 'club_member'}), 
          "Resign as Club Member", 'any_access')
      submenus.append(submenu)

    return submenus
Пример #13
0
  def manageOverview(self, request, access_type,
             page_name=None, params=None, **kwargs):
    """View that allows Organization Admins to see an overview of 
       their Organization's Student Projects.

    For params see base.View().public()
    """

    from soc.modules.gsoc.logic.models.survey import grading_logic as \
        grading_survey_logic
    from soc.modules.gsoc.logic.models.survey import project_logic as \
        project_survey_logic
    from soc.modules.gsoc.logic.models.survey_record import grading_logic
    from soc.modules.gsoc.logic.models.survey_record import project_logic

    # make sure the organization exists
    org_entity = org_logic.getFromKeyNameOr404(kwargs['scope_path'])
    page_name = '%s %s' % (page_name, org_entity.name)

    mo_params = params.copy()

    #list all active projects
    mo_params['list_description'] = ugettext(
        'List of all %s for %s, if you are an Org Admin you can click '
        'a project for more actions. Such as reassigning mentors or viewing '
        'results of the evaluations.' %(params['name_plural'], org_entity.name)
        )
    mo_params['public_field_names'] = params['public_field_names'] + [
        'Mentor evaluation', 'Student Evaluation']
    mo_params['public_field_keys'] = params['public_field_keys'] + [
        'mentor_evaluation', 'student_evaluation']

    fields = {'scope': org_entity,
              'status': ['active', 'inactive']}
    org_admin = org_admin_logic.getForFields(fields, unique=True)

    # Org Admins get a link to manage the project, others go to public page
    if org_admin:
      mo_params['public_row_extra'] = lambda entity, *args: {
          'link': redirects.getManageRedirect(entity, mo_params)
      }
    else:
      mo_params['public_row_extra'] = lambda entity, *args: {
          'link': redirects.getPublicRedirect(entity, mo_params)
      }

    mo_params['public_field_prefetch'] = ['student', 'mentor', 'scope']
    mo_params['public_field_extra'] = lambda entity, ps, psc, gs, gsc: {
        'org': entity.scope.name,
        'student': '%s (%s)' % (entity.student.name(), entity.student.email),
        'mentor': entity.mentor.name(),
        'mentor_evaluation': '%d/%d' % (
                grading_logic.getQueryForFields({'project': entity}).count(),
                gsc),
        'student_evaluation': '%d/%d' % (
                project_logic.getQueryForFields({'project': entity}).count(),
                psc),
    }

    if lists.isDataRequest(request):
      return self.getManageOverviewData(request, mo_params, org_entity)

    mo_list = lists.getListGenerator(request, mo_params, idx=0)
    contents = [mo_list]

    # call the _list method from base to display the list
    return self._list(request, mo_params, contents, page_name)
Пример #14
0
 def getter(list_params):
   return lambda entity: {
       'link': redirects.getManageRedirect(entity, list_params)
   }
Пример #15
0
 def getter(list_params):
     return lambda entity: {
         'link': redirects.getManageRedirect(entity, list_params)
     }
Пример #16
0
    def _getExtraMenuItems(self, role_description, params=None):
        """Used to create the specific GCI Organization menu entries.

    For args see soc.views.models.organization.View._getExtraMenuItems().
    """
        submenus = []

        group_entity = role_description['group']
        roles = role_description['roles']

        mentor_entity = roles.get('gci_mentor')
        admin_entity = roles.get('gci_org_admin')

        is_active_mentor = mentor_entity and mentor_entity.status == 'active'
        is_active_admin = admin_entity and admin_entity.status == 'active'

        if admin_entity or mentor_entity:
            # add a link to view all the organization tasks.
            submenu = (gci_redirects.getListTasksRedirect(
                group_entity,
                {'url_name': 'gci/task'}), "View all Tasks", 'any_access')
            submenus.append(submenu)

        if is_active_admin:
            # add a link to create task
            submenu = (redirects.getCreateRedirect(group_entity,
                                                   {'url_name': 'gci/task'}),
                       "Create a Task", 'any_access')
            submenus.append(submenu)

            # add a link to bulk create tasks
            submenu = (gci_redirects.getBulkCreateRedirect(
                group_entity,
                {'url_name': 'gci/task'}), "Bulk Create Tasks", 'any_access')
            submenus.append(submenu)

            # add a link to the management page
            submenu = (redirects.getListRolesRedirect(group_entity, params),
                       "Manage Admins and Mentors", 'any_access')
            submenus.append(submenu)

            # add a link to invite an org admin
            submenu = (redirects.getInviteRedirectForRole(
                group_entity,
                'gci/org_admin'), "Invite an Admin", 'any_access')
            submenus.append(submenu)

            # add a link to invite a member
            submenu = (redirects.getInviteRedirectForRole(
                group_entity, 'gci/mentor'), "Invite a Mentor", 'any_access')
            submenus.append(submenu)

            # add a link to the request page
            submenu = (redirects.getListRequestsRedirect(group_entity, params),
                       "List Requests and Invites", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(group_entity, params),
                       "Edit Organization Profile", 'any_access')
            submenus.append(submenu)

        if is_active_mentor:
            # add a link to suggest task
            submenu = (gci_redirects.getSuggestTaskRedirect(
                group_entity,
                {'url_name': 'gci/task'}), "Suggest a Task", 'any_access')
            submenus.append(submenu)

        if is_active_admin or is_active_mentor:
            submenu = (redirects.getCreateDocumentRedirect(
                group_entity,
                'gci_org'), "Create a New Document", 'any_access')
            submenus.append(submenu)

            submenu = (redirects.getListDocumentsRedirect(
                group_entity, 'gci_org'), "List Documents", 'any_access')
            submenus.append(submenu)

        if is_active_admin:
            # add a link to the resign page
            submenu = (redirects.getManageRedirect(
                roles['gci_org_admin'], {'url_name': 'gci/org_admin'}),
                       "Resign as Admin", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(
                roles['gci_org_admin'], {'url_name': 'gci/org_admin'}),
                       "Edit My Admin Profile", 'any_access')
            submenus.append(submenu)

        if is_active_mentor:
            # add a link to the resign page
            submenu = (redirects.getManageRedirect(roles['gci_mentor'],
                                                   {'url_name': 'gci/mentor'}),
                       "Resign as Mentor", 'any_access')
            submenus.append(submenu)

            # add a link to the edit page
            submenu = (redirects.getEditRedirect(roles['gci_mentor'],
                                                 {'url_name': 'gci/mentor'}),
                       "Edit My Mentor Profile", 'any_access')
            submenus.append(submenu)

        return submenus
Пример #17
0
    def manageOverview(self,
                       request,
                       access_type,
                       page_name=None,
                       params=None,
                       **kwargs):
        """View that allows Organization Admins to see an overview of 
       their Organization's Student Projects.

    For params see base.View().public()
    """

        from soc.modules.gsoc.logic.models.survey import grading_logic as \
            grading_survey_logic
        from soc.modules.gsoc.logic.models.survey import project_logic as \
            project_survey_logic
        from soc.modules.gsoc.logic.models.survey_record import grading_logic
        from soc.modules.gsoc.logic.models.survey_record import project_logic

        # make sure the organization exists
        org_entity = org_logic.getFromKeyNameOr404(kwargs['scope_path'])
        page_name = '%s %s' % (page_name, org_entity.name)

        mo_params = params.copy()

        #list all active projects
        mo_params['list_description'] = ugettext(
            'List of all %s for %s, if you are an Org Admin you can click '
            'a project for more actions. Such as reassigning mentors or viewing '
            'results of the evaluations.' %
            (params['name_plural'], org_entity.name))
        mo_params['public_field_names'] = params['public_field_names'] + [
            'Mentor evaluation', 'Student Evaluation'
        ]
        mo_params['public_field_keys'] = params['public_field_keys'] + [
            'mentor_evaluation', 'student_evaluation'
        ]

        fields = {'scope': org_entity, 'status': ['active', 'inactive']}
        org_admin = org_admin_logic.getForFields(fields, unique=True)

        # Org Admins get a link to manage the project, others go to public page
        if org_admin:
            mo_params['public_row_extra'] = lambda entity, *args: {
                'link': redirects.getManageRedirect(entity, mo_params)
            }
        else:
            mo_params['public_row_extra'] = lambda entity, *args: {
                'link': redirects.getPublicRedirect(entity, mo_params)
            }

        mo_params['public_field_prefetch'] = ['student', 'mentor', 'scope']
        mo_params['public_field_extra'] = lambda entity, ps, psc, gs, gsc: {
            'org':
            entity.scope.name,
            'student':
            '%s (%s)' % (entity.student.name(), entity.student.email),
            'mentor':
            entity.mentor.name(),
            'mentor_evaluation':
            '%d/%d' % (grading_logic.getQueryForFields({
                'project': entity
            }).count(), gsc),
            'student_evaluation':
            '%d/%d' % (project_logic.getQueryForFields({
                'project': entity
            }).count(), psc),
        }

        if lists.isDataRequest(request):
            return self.getManageOverviewData(request, mo_params, org_entity)

        mo_list = lists.getListGenerator(request, mo_params, idx=0)
        contents = [mo_list]

        # call the _list method from base to display the list
        return self._list(request, mo_params, contents, page_name)