Example #1
0
  def edit(self, request, access_type,
           page_name=None, params=None, seed=None, **kwargs):
    """If the POST contains (action, Withdraw) the proposal in kwargs
       will be marked as invalid.

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

    # check if request.POST contains action
    post_dict = request.POST
    if 'action' in post_dict and post_dict['action'] == 'Withdraw':
      # withdraw this proposal
      filter = {'scope_path': kwargs['scope_path'],
                'link_id': kwargs['link_id']}

      proposal_logic = params['logic']
      student_proposal_entity = proposal_logic.getForFields(filter, unique=True)
      reviewer = student_proposal_entity.scope

      # update the entity mark it as invalid
      proposal_logic.updateEntityProperties(student_proposal_entity,
          {'status': 'invalid'})

      # redirect to the program's homepage
      redirect_url = redirects.getHomeRedirect(student_proposal_entity.program,
          {'url_name': 'program'})

      comment = "Student withdrew proposal."
      self._createReviewFor(student_proposal_entity, reviewer, comment)
      return http.HttpResponseRedirect(redirect_url)

    return super(View, self).edit(request=request, access_type=access_type,
           page_name=page_name, params=params, seed=seed, **kwargs)
  def edit(self, request, access_type,
           page_name=None, params=None, seed=None, **kwargs):
    """If the POST contains (action, Withdraw) the proposal in kwargs
       will be marked as invalid.

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

    # check if request.POST contains action
    post_dict = request.POST
    if 'action' in post_dict and post_dict['action'] == 'Withdraw':
      # withdraw this proposal
      filter = {'scope_path': kwargs['scope_path'],
                'link_id': kwargs['link_id']}

      proposal_logic = params['logic']
      student_proposal_entity = proposal_logic.getForFields(filter, unique=True)

      # update the entity mark it as invalid
      proposal_logic.updateEntityProperties(student_proposal_entity,
          {'status': 'invalid'})

      # redirect to the program's homepage
      redirect_url = redirects.getHomeRedirect(student_proposal_entity.program,
          {'url_name': 'program'})

      comment = "Student withdrew proposal."
      self._createReviewFor(student_proposal_entity, comment)
      return http.HttpResponseRedirect(redirect_url)

    return super(View, self).edit(request=request, access_type=access_type,
           page_name=page_name, params=params, seed=seed, **kwargs)
Example #3
0
  def getMenusForScope(self, entity, params):
    """Returns the featured menu items for one specific entity.

    A link to the home page of the specified entity is also included.

    Args:
      entity: the entity for which the entry should be constructed
      params: a dict with params for this View.
    """

    filter = {
        'prefix' : params['document_prefix'],
        'scope_path': entity.key().id_or_name(),
        'is_featured': True,
        }

    entities = self._logic.getForFields(filter)

    submenus = []

    # add a link to the home page
    submenu = (redirects.getHomeRedirect(entity, params), 'Home', 'allow')
    submenus.append(submenu)

    # add a link to all featured documents
    for entity in entities:
      #TODO only if a document is readable it might be added
      submenu = (redirects.getPublicRedirect(entity, self._params),
                 entity.short_name, 'show')
      submenus.append(submenu)

    return submenus
Example #4
0
    def getMenusForScope(self, entity, params):
        """Returns the featured menu items for one specific entity.

    A link to the home page of the specified entity is also included.

    Args:
      entity: the entity for which the entry should be constructed
      params: a dict with params for this View.
    """

        filter = {
            'prefix': params['document_prefix'],
            'scope_path': entity.key().id_or_name(),
            'is_featured': True,
        }

        entities = self._logic.getForFields(filter)

        submenus = []

        # add a link to the home page
        submenu = (redirects.getHomeRedirect(entity, params), 'Home', 'allow')
        submenus.append(submenu)

        # add a link to all featured documents
        for entity in entities:
            #TODO only if a document is readable it might be added
            submenu = (redirects.getPublicRedirect(entity, self._params),
                       entity.short_name, 'show')
            submenus.append(submenu)

        return submenus
Example #5
0
    def _getOrgsWithAcceptedApps(self, request, program_entity, params):
        """
    """

        fmt = {'name': program_entity.name}
        description = self.DEF_ACCEPTED_ORGS_MSG_FMT % fmt

        filter = {
            'status': 'accepted',
            'scope': program_entity,
        }

        from soc.views.models import org_app as org_app_view
        aa_params = org_app_view.view.getParams().copy(
        )  # accepted applications

        # define the list redirect action to show the notification
        del aa_params['list_key_order']
        aa_params['public_row_extra'] = lambda entity: {
            'link': redirects.getHomeRedirect(entity, aa_params)
        }
        aa_params['list_description'] = description
        # TODO(LIST)
        aa_list = lists.getListContent(request,
                                       aa_params,
                                       filter,
                                       idx=0,
                                       need_content=True)

        return aa_list
Example #6
0
    def acceptedOrgs(self, request, page_name, params, program_entity,
                     org_view, org_app_view):
        """See base.View.list.
    """

        logic = params['logic']

        list_params = org_view.getParams().copy()
        list_params['list_msg'] = program_entity.accepted_orgs_msg

        fmt = {'name': program_entity.name}

        org_app_params = org_app_view.getParams()

        # try to retrieve an accepted record
        org_app_logic = org_app_params['logic']
        org_app = org_app_logic.getForProgram(program_entity)

        aa_params = org_app_params['record_list_params'].copy(
        )  # accepted applications
        aa_params['public_row_extra'] = lambda entity: {}
        description = self.DEF_ACCEPTED_ORGS_MSG_FMT % fmt
        aa_params['list_description'] = description
        aa_params['public_conf_extra'] = {
            "rowNum": -1,
            "rowList": [],
        }

        description = self.DEF_CREATED_ORGS_MSG_FMT % fmt
        ap_params = org_view.getParams().copy()
        ap_params['list_description'] = description
        ap_params['public_row_extra'] = lambda entity: {
            'link': redirects.getHomeRedirect(entity, ap_params),
        }
        ap_params['public_conf_extra'] = {
            "rowNum": -1,
            "rowList": [],
        }

        if lists.isDataRequest(request):
            return self.getAcceptedOrgsData(request, aa_params, ap_params,
                                            org_app_logic, program_entity)

        contents = []
        order = ['name']

        ap_list = lists.getListGenerator(request,
                                         ap_params,
                                         order=order,
                                         idx=0)
        contents.append(ap_list)

        aa_list = lists.getListGenerator(request,
                                         aa_params,
                                         order=order,
                                         idx=1)
        contents.append(aa_list)

        return self._list(request, list_params, contents, page_name)
Example #7
0
  def acceptedOrgs(self, request, page_name, params, program_entity,
                   org_view, org_app_view):
    """See base.View.list.
    """

    logic = params['logic']

    list_params = org_view.getParams().copy()
    list_params['list_msg'] = program_entity.accepted_orgs_msg

    fmt = {'name': program_entity.name}

    org_app_params = org_app_view.getParams()

    # try to retrieve an accepted record
    org_app_logic = org_app_params['logic']
    org_app = org_app_logic.getForProgram(program_entity)

    aa_params = org_app_params['record_list_params'].copy() # accepted applications
    aa_params['public_row_extra'] = lambda entity: {}
    description = self.DEF_ACCEPTED_ORGS_MSG_FMT % fmt
    aa_params['list_description'] = description
    aa_params['public_conf_extra'] = {
        "rowNum": -1,
        "rowList": [],
    }

    description = self.DEF_CREATED_ORGS_MSG_FMT % fmt
    ap_params = org_view.getParams().copy()
    ap_params['list_description'] = description
    ap_params['public_row_extra'] = lambda entity: {
        'link': redirects.getHomeRedirect(entity, ap_params),
    }
    ap_params['public_conf_extra'] = {
        "rowNum": -1,
        "rowList": [],
    }

    if lists.isDataRequest(request):
      return self.getAcceptedOrgsData(
          request, aa_params, ap_params, org_app_logic, program_entity)

    contents = []
    order = ['name']

    ap_list = lists.getListGenerator(request, ap_params, order=order, idx=0)
    contents.append(ap_list)

    aa_list = lists.getListGenerator(request, aa_params, order=order, idx=1)
    contents.append(aa_list)

    return self._list(request, list_params, contents, page_name)