Esempio n. 1
0
  def context(self):
    """Handler to for GSoC Organization Home page HTTP get request.
    """
    current_timeline = self.getCurrentTimeline(
        self.data.program_timeline, self.data.org_app)

    assert isSet(self.data.organization)
    organization = self.data.organization

    context = {
        'page_name': '%s - Homepage' % organization.short_name,
        'organization': organization,
        'contact': Contact(self.data),
        'tags': organization.tags_string(organization.org_tag),
        'apply': Apply(self.data, current_timeline),
    }

    ideas = organization.ideas

    if organization.ideas:
      context['ideas_link'] = ideas
      context['ideas_link_trimmed'] = url_helper.trim_url_to(ideas, 50)

    if self.data.orgAdminFor(organization):
      r = self.redirect
      r.organization(organization)
      context['edit_link'] =  r.urlOf('edit_gsoc_org_profile')
      context['invite_admin_link'] = r.invite('org_admin').urlOf('gsoc_invite')
      context['invite_mentor_link'] = r.invite('mentor').urlOf('gsoc_invite')

      if (self.data.program.allocations_visible and
          self.data.timeline.beforeStudentsAnnounced()):
        context['slot_transfer_link'] = r.organization(organization).urlOf(
            'gsoc_slot_transfer')

    if self.data.timeline.studentsAnnounced():
      context['students_announced'] = True

      context['project_list'] = ProjectList(self.request, self.data)

      # TODO: Map needs to be rewritten to work with new mentors property
      # obtain a json object that contains the organization home page map data
      #context['org_map_data'] = self._getJSONMapData()

    return context
Esempio n. 2
0
    def context(self):
        assert isSet(self.data.public_comments_visible)
        assert isSet(self.data.private_comments_visible)
        assert isSet(self.data.url_profile)
        assert isSet(self.data.url_user)
        assert isSet(self.data.proposal)

        context = {}

        user_role = None

        scores = self.getScores()

        # TODO: check if the scoring is not disabled
        score_action = reverse("score_gsoc_proposal", kwargs=self.data.kwargs)

        # get all the comments for the the proposal
        public_comments, private_comments = self.getComments()

        # TODO: check if it is possible to post a comment
        comment_action = reverse("comment_gsoc_proposal", kwargs=self.data.kwargs)

        if self.data.private_comments_visible:
            form = PrivateCommentForm(self.data.POST or None)
            if self.data.orgAdminFor(self.data.proposal.org):
                user_role = "org_admin"
            else:
                user_role = "mentor"

        else:
            form = CommentForm(self.data.POST or None)

        comment_box = {"action": comment_action, "form": form}

        # to keep the blocks as simple as possible, the if branches have
        # been broken down into several if blocks
        user_is_proposer = self.data.user and (self.data.user.key() == self.data.url_user.key())
        if user_is_proposer:
            user_role = "proposer"

            # we will check if the student is allowed to modify the proposal
            # after the student proposal deadline
            is_editable = self.data.timeline.afterStudentSignupEnd() and self.data.proposal.is_editable_post_deadline
            if self.data.timeline.studentSignup() or is_editable:
                context["update_link"] = self.data.redirect.id().urlOf("update_gsoc_proposal")

        possible_mentors = db.get(self.data.proposal.possible_mentors)
        possible_mentors = self.sanitizePossibleMentors(possible_mentors)
        possible_mentors_names = ", ".join([m.name() for m in possible_mentors])

        scoring_visible = self.data.private_comments_visible and (not self.data.proposal_org.scoring_disabled)

        if self.data.orgAdminFor(self.data.proposal_org):
            scoring_visible = True

        duplicate = None
        if self.data.program.duplicates_visible and self.data.orgAdminFor(self.data.proposal_org):
            q = GSoCProposalDuplicate.all()
            q.filter("duplicates", self.data.proposal)
            q.filter("is_duplicate", True)
            dup_entity = q.get()
            duplicate = Duplicate(self.data, dup_entity) if dup_entity else None

        additional_info = self.data.proposal.additional_info

        if user_role:
            context["user_actions"] = UserActions(self.data, user_role)

        context.update(
            {
                "additional_info": url_helper.trim_url_to(additional_info, 50),
                "additional_info_link": additional_info,
                "comment_box": comment_box,
                "duplicate": duplicate,
                "max_score": self.data.proposal_org.max_score,
                "mentor": self.data.proposal.mentor,
                "page_name": self.data.proposal.title,
                "possible_mentors": possible_mentors_names,
                "private_comments": private_comments,
                "private_comments_visible": self.data.private_comments_visible,
                "proposal": self.data.proposal,
                "public_comments": public_comments,
                "public_comments_visible": self.data.public_comments_visible,
                "score_action": score_action,
                "scores": scores,
                "scoring_visible": scoring_visible,
                "student_email": self.data.url_profile.email,
                "student_name": self.data.url_profile.name(),
                "proposal_ignored": self.data.proposal.status == "ignored",
                "user_role": user_role,
            }
        )

        return context
Esempio n. 3
0
    def context(self, data, check, mutator):
        context = {}

        user_role = None

        scores = self.getScores(data)

        # TODO: check if the scoring is not disabled
        score_action = reverse('score_gsoc_proposal', kwargs=data.kwargs)

        # get all the comments for the the proposal
        public_comments, private_comments = self.getComments(data)

        # TODO: check if it is possible to post a comment
        comment_action = reverse('comment_gsoc_proposal', kwargs=data.kwargs)

        if _getApplyingCommentType(data) == PRIVATE_COMMENTS:

            # only mentors and org admins can see that the proposal is ignored
            # TODO(daniel): replace status literals with constants
            context['proposal_ignored'] = data.url_proposal.status == 'ignored'

            form = PrivateCommentForm(data=data.POST or None)
            org_key = proposal_model.GSoCProposal.org.get_value_for_datastore(
                data.url_proposal)
            if data.orgAdminFor(org_key):
                user_role = 'org_admin'
            else:
                user_role = 'mentor'

        else:
            form = CommentForm(data=data.POST or None)

        comment_box = {
            'action': comment_action,
            'form': form,
        }

        # to keep the blocks as simple as possible, the if branches have
        # been broken down into several if blocks
        user_is_proposer = (data.user
                            and (data.ndb_user.key == data.url_ndb_user.key()))
        if user_is_proposer:
            user_role = 'proposer'

            # we will check if the student is allowed to modify the proposal
            # after the student proposal deadline
            is_editable = data.timeline.afterStudentSignupEnd() and \
                data.url_proposal.is_editable_post_deadline
            if data.timeline.studentSignup() or is_editable:
                context['update_link'] = links.LINKER.userId(
                    data.url_ndb_profile.key(),
                    data.url_proposal.key().id(), 'update_gsoc_proposal')

        possible_mentors = ndb.get_multi(
            map(ndb.Key.from_old_key, data.url_proposal.possible_mentors))
        possible_mentors = self.sanitizePossibleMentors(data, possible_mentors)
        possible_mentors_names = ', '.join(
            [m.public_name for m in possible_mentors])

        org_key = proposal_model.GSoCProposal.org.get_value_for_datastore(
            data.url_proposal)
        org = ndb.Key.from_old_key(org_key).get()
        scoring_visible = _getApplyingCommentType(
            data) == PRIVATE_COMMENTS and (org.scoring_enabled)

        if data.orgAdminFor(org_key):
            scoring_visible = True

        duplicate = None
        if (data.program.duplicates_visible and data.orgAdminFor(org_key)):
            q = GSoCProposalDuplicate.all()
            q.filter('duplicates', data.url_proposal)
            q.filter('is_duplicate', True)
            dup_entity = q.get()
            duplicate = Duplicate(data, dup_entity) if dup_entity else None

        additional_info = data.url_proposal.additional_info

        if user_role:
            context['user_actions'] = UserActions(data, user_role)

        mentor_key = proposal_model.GSoCProposal.mentor.get_value_for_datastore(
            data.url_proposal)
        mentor = ndb.Key.from_old_key(mentor_key).get() if mentor_key else None
        context.update({
            'additional_info':
            url_helper.trim_url_to(additional_info, 50),
            'additional_info_link':
            additional_info,
            'comment_box':
            comment_box,
            'duplicate':
            duplicate,
            'max_score':
            org.max_score,
            'mentor':
            mentor,
            'page_name':
            data.url_proposal.title,
            'possible_mentors':
            possible_mentors_names,
            'private_comments':
            private_comments,
            'private_comments_visible':
            _getApplyingCommentType(data) == PRIVATE_COMMENTS,
            'proposal':
            data.url_proposal,
            'public_comments':
            public_comments,
            'public_comments_visible':
            _getApplyingCommentType(data) == PRIVATE_COMMENTS
            or _getApplyingCommentType(data) == PUBLIC_COMMENTS,
            'score_action':
            score_action,
            'scores':
            scores,
            'scoring_visible':
            scoring_visible,
            'student_email':
            data.url_ndb_profile.contact.email,
            'student_name':
            data.url_ndb_profile.public_name,
            'user_role':
            user_role,
        })

        return context
Esempio n. 4
0
  def context(self, data, check, mutator):
    context = {}

    user_role = None

    scores = self.getScores(data)

    # TODO: check if the scoring is not disabled
    score_action = reverse('score_gsoc_proposal', kwargs=data.kwargs)

    # get all the comments for the the proposal
    public_comments, private_comments = self.getComments(data)

    # TODO: check if it is possible to post a comment
    comment_action = reverse('comment_gsoc_proposal', kwargs=data.kwargs)

    if _getApplyingCommentType(data) == PRIVATE_COMMENTS:

      # only mentors and org admins can see that the proposal is ignored
      # TODO(daniel): replace status literals with constants
      context['proposal_ignored'] = data.url_proposal.status == 'ignored'

      form = PrivateCommentForm(data=data.POST or None)
      org_key = proposal_model.GSoCProposal.org.get_value_for_datastore(
          data.url_proposal)
      if data.orgAdminFor(org_key):
        user_role = 'org_admin'
      else:
        user_role = 'mentor'

    else:
      form = CommentForm(data=data.POST or None)

    comment_box = {
        'action': comment_action,
        'form': form,
    }

    # to keep the blocks as simple as possible, the if branches have
    # been broken down into several if blocks
    user_is_proposer = (
        data.user and (data.ndb_user.key == data.url_ndb_user.key()))
    if user_is_proposer:
      user_role = 'proposer'

      # we will check if the student is allowed to modify the proposal
      # after the student proposal deadline
      is_editable = data.timeline.afterStudentSignupEnd() and \
          data.url_proposal.is_editable_post_deadline
      if data.timeline.studentSignup() or is_editable:
        context['update_link'] = links.LINKER.userId(
            data.url_ndb_profile.key(), data.url_proposal.key().id(),
            'update_gsoc_proposal')

    possible_mentors = ndb.get_multi(
        map(ndb.Key.from_old_key, data.url_proposal.possible_mentors))
    possible_mentors = self.sanitizePossibleMentors(data, possible_mentors)
    possible_mentors_names = ', '.join([
        m.public_name for m in possible_mentors])

    org_key = proposal_model.GSoCProposal.org.get_value_for_datastore(
        data.url_proposal)
    org = ndb.Key.from_old_key(org_key).get()
    scoring_visible = _getApplyingCommentType(data) == PRIVATE_COMMENTS and (
        org.scoring_enabled)

    if data.orgAdminFor(org_key):
      scoring_visible = True

    duplicate = None
    if (data.program.duplicates_visible and
        data.orgAdminFor(org_key)):
      q = GSoCProposalDuplicate.all()
      q.filter('duplicates', data.url_proposal)
      q.filter('is_duplicate', True)
      dup_entity = q.get()
      duplicate = Duplicate(data, dup_entity) if dup_entity else None

    additional_info = data.url_proposal.additional_info

    if user_role:
      context['user_actions'] = UserActions(data, user_role)

    mentor_key = proposal_model.GSoCProposal.mentor.get_value_for_datastore(
        data.url_proposal)
    mentor = ndb.Key.from_old_key(mentor_key).get() if mentor_key else None
    context.update({
        'additional_info': url_helper.trim_url_to(additional_info, 50),
        'additional_info_link': additional_info,
        'comment_box': comment_box,
        'duplicate': duplicate,
        'max_score': org.max_score,
        'mentor': mentor,
        'page_name': data.url_proposal.title,
        'possible_mentors': possible_mentors_names,
        'private_comments': private_comments,
        'private_comments_visible':
             _getApplyingCommentType(data) == PRIVATE_COMMENTS,
        'proposal': data.url_proposal,
        'public_comments': public_comments,
        'public_comments_visible':
            _getApplyingCommentType(data) == PRIVATE_COMMENTS or
            _getApplyingCommentType(data) == PUBLIC_COMMENTS,
        'score_action': score_action,
        'scores': scores,
        'scoring_visible': scoring_visible,
        'student_email': data.url_ndb_profile.contact.email,
        'student_name': data.url_ndb_profile.public_name,
        'user_role': user_role,
        })

    return context