当前位置: 首页>>代码示例>>Python>>正文


Python access_checker.isSet函数代码示例

本文整理汇总了Python中soc.views.helper.access_checker.isSet函数的典型用法代码示例。如果您正苦于以下问题:Python isSet函数的具体用法?Python isSet怎么用?Python isSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isSet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handledInviteContext

def handledInviteContext(data):
  """Sends a message that the invite to obtain a role has been handled.

  Args:
    data: a RequestData object
  """

  assert isSet(data.invite)
  assert isSet(data.invited_profile)

  # do not send notifications if the user has opted out
  if not data.invited_profile.notify_invite_handled:
    return {}

  status = data.invite.status
  action = 'resubmitted' if status == 'pending' else status
  edit_link = data.redirect.program().urlOf('edit_gsoc_profile', full=True)

  message_properties = {
      'role_verbose' : data.invite.roleName(),
      'org': data.invite.org.name,
      'action': action,
      'profile_edit_link': edit_link,
      }

  subject = DEF_HANDLED_INVITE_SUBJECT % message_properties

  template = DEF_HANDLED_INVITE_NOTIFICATION_TEMPLATE

  to_email = data.invited_profile.email

  # from user set to None to not leak who rejected it.
  return getContext(data, [to_email], message_properties, subject, template)
开发者ID:adviti,项目名称:melange,代码行数:33,代码来源:notifications.py

示例2: newCommentContext

def newCommentContext(data, comment, to_emails):
  """Sends out a notification to alert the user of a new comment.

  Args:
    data: a RequestData object
  """
  assert isSet(data.proposal)
  assert isSet(data.proposer)

  review_notification_url = data.redirect.comment(comment, full=True)
  edit_link = data.redirect.program().urlOf('edit_gsoc_profile', full=True)

  review_type = 'private' if comment.is_private else 'public'
  reviewed_name = data.proposal.title

  message_properties = {
      'review_notification_url': review_notification_url,
      'reviewer_name': comment.author.name(),
      'reviewed_name': reviewed_name,
      'review_content': comment.content,
      'review_visibility': review_type,
      'proposer_name': data.proposer.name(),
      'org': data.proposal.org.name,
      'profile_edit_link': edit_link,
      }

  # determine the subject
  subject = DEF_NEW_REVIEW_SUBJECT % message_properties

  template = DEF_NEW_REVIEW_NOTIFICATION_TEMPLATE

  if data.proposer.notify_public_comments and not comment.is_private:
    to_emails.append(data.proposer.email)

  return getContext(data, to_emails, message_properties, subject, template)
开发者ID:adviti,项目名称:melange,代码行数:35,代码来源:notifications.py

示例3: isStudentForSurvey

  def isStudentForSurvey(self):
    """Checks if the student can take survey for the project.
    """
    assert access_checker.isSet(self.data.profile)
    assert access_checker.isSet(self.data.project)

    self.isProjectInURLValid()

    project = self.data.project

    # check if the project belongs to the current user and if so he
    # can access the survey
    expected_profile_key = project.parent_key()
    if expected_profile_key != self.data.profile.key():
      raise AccessViolation(DEF_STUDENT_EVAL_DOES_NOT_BELONG_TO_YOU)

    # check if the project is still ongoing
    if project.status in ['invalid', 'withdrawn']:
      raise AccessViolation(DEF_EVAL_NOT_ACCESSIBLE_FOR_PROJECT)

    # check if the project has failed in a previous evaluation
    # TODO(Madhu): This still has a problem that when the project fails
    # in the final evaluation, the users will not be able to access the
    # midterm evaluation show page. Should be fixed.
    if project.status == 'failed' and project.failed_evaluations:
      failed_evals = db.get(project.failed_evaluations)
      fe_keynames = [f.grading_survey_group.grading_survey.key(
          ).id_or_name() for f in failed_evals]
      if self.data.student_evaluation.key().id_or_name() not in fe_keynames:
        raise AccessViolation(DEF_FAILED_PREVIOUS_EVAL % (
            self.data.student_evaluation.short_name.lower()))
开发者ID:adviti,项目名称:melange,代码行数:31,代码来源:access_checker.py

示例4: handledRequestContext

def handledRequestContext(data, status):
  """Sends a message that the request to get a role has been handled.

  Args:
    data: a RequestData object
  """

  assert isSet(data.request_entity)
  assert isSet(data.requester_profile)

  # do not send notifications if the user has opted out
  if not data.requester_profile.notify_request_handled:
    return {}

  edit_link = data.redirect.program().urlOf('edit_gsoc_profile', full=True)

  message_properties = {
      'role_verbose' : data.request_entity.roleName(),
      'org': data.request_entity.org.name,
      'action': status,
      'profile_edit_link': edit_link,
      }

  subject = DEF_HANDLED_REQUEST_SUBJECT % message_properties

  template = DEF_HANDLED_REQUEST_NOTIFICATION_TEMPLATE

  to_email = data.requester_profile.email

  # from user set to None to not leak who rejected it.
  return getContext(data, [to_email], message_properties, subject, template)
开发者ID:adviti,项目名称:melange,代码行数:31,代码来源:notifications.py

示例5: isPossibleMentorForProposal

  def isPossibleMentorForProposal(self):
    """Checks if the user is a possible mentor for the proposal in the data.
    """
    assert isSet(self.profile)
    assert isSet(self.proposal)

    return self.profile.key() in self.proposal.possible_mentors
开发者ID:SRabbelier,项目名称:Melange,代码行数:7,代码来源:request_data.py

示例6: context

    def context(self):
        """See soc.views.template.Template.context for full specification."""
        assert access_checker.isSet(self.data.conversation)
        assert access_checker.isSet(self.data.user)

        query = gciconversation_logic.queryConversationUserForConversationAndUser(
            self.data.conversation.key, ndb.Key.from_old_key(self.data.user.key())
        )
        conv_user_results = query.fetch(1)
        assert conv_user_results

        conv_user = conv_user_results[0]

        self.data.redirect.id()

        url = self.data.redirect.urlOf(url_names.GCI_CONVERSATION_NOTIFICATION_TOGGLE)

        enable_notifications = toggle_button_view.ToggleButtonTemplate(
            self.data,
            "on_off",
            translation.ugettext("Enable Notifications"),
            "notifications-enabled",
            url,
            checked=conv_user.enable_notifications,
            help_text=self.DEF_ENABLE_NOTIFICATIONS_HELP,
            labels={"checked": "Yes", "unchecked": "No"},
        )
        self.toggle_buttons.append(enable_notifications)

        return {"title": translation.ugettext("Conversation Actions"), "toggle_buttons": self.toggle_buttons}
开发者ID:rhyolight,项目名称:nupic.son,代码行数:30,代码来源:conversation.py

示例7: canStudentUpdateProject

  def canStudentUpdateProject(self):
    """Checks if the student can edit the project details."""
    assert access_checker.isSet(self.data.program)
    assert access_checker.isSet(self.data.timeline)

    self.isProjectInURLValid()

    # check if the timeline allows updating project
    self.isProgramVisible()
    self.acceptedStudentsAnnounced()

    # check if the current used is an active student
    self.isActiveStudent()

    # check if the project belongs to the current user
    expected_profile_key = self.data.url_project.parent_key()
    if expected_profile_key != self.data.ndb_profile.key.to_old_key():
      error_msg = access_checker.DEF_ENTITY_DOES_NOT_BELONG_TO_YOU % {
          'name': 'project'
          }
      raise exception.Forbidden(message=error_msg)

    # check if the status allows the project to be updated
    if self.data.url_project.status in ['invalid', 'withdrawn', 'failed']:
      raise exception.Forbidden(
          message=access_checker.DEF_CANNOT_UPDATE_ENTITY % {
              'name': 'project'
              })
开发者ID:rhyolight,项目名称:nupic.son,代码行数:28,代码来源:access_checker.py

示例8: context

  def context(self):
    assert isSet(self.data.program)
    assert isSet(self.data.url_profile)
    assert isSet(self.data.url_user)

    user = self.data.url_user
    profile = self.data.url_profile
    program = self.data.program
    r = self.redirect.profile()

    links = []

    for project in GSoCProject.all().ancestor(profile):
      r.project(project.key().id())
      links.append(r.urlOf('gsoc_project_details', full=True))

    r = self.redirect.profile()

    return {
        'page_name': '%s Profile - %s' % (program.short_name, profile.name()),
        'program_name': program.name,
        'form_top_msg': LoggedInMsg(self.data, apply_link=False),
        'user': profile_show.UserReadOnlyTemplate(user),
        'profile': GSoCProfileReadOnlyTemplate(profile),
        'links': links,
        'css_prefix': GSoCProfileReadOnlyTemplate.Meta.css_prefix,
        'submit_tax_link': r.urlOf('gsoc_tax_form_admin'),
        'submit_enrollment_link': r.urlOf('gsoc_enrollment_form_admin'),
        }
开发者ID:adviti,项目名称:melange,代码行数:29,代码来源:profile_show.py

示例9: getScores

  def getScores(self):
    """Gets all the scores for the proposal.
    """
    assert isSet(self.data.private_comments_visible)
    assert isSet(self.data.proposal)

    if not self.data.private_comments_visible:
      return None

    total = 0
    number = 0
    user_score = 0

    query = db.Query(GSoCScore).ancestor(self.data.proposal)
    for score in query:
      total += score.value
      number += 1

      author_key = GSoCScore.author.get_value_for_datastore(score)
      if author_key == self.data.profile.key():
        user_score = score.value

    return {
        'average': total / number if number else 0,
        'number': number,
        'total': total,
        'user_score': user_score,
        }
开发者ID:SRabbelier,项目名称:Melange,代码行数:28,代码来源:proposal_review.py

示例10: _acceptRequest

    def _acceptRequest(self):
        """Accepts a request.
    """
        assert isSet(self.data.organization)
        assert isSet(self.data.requester_profile)

        request_key = self.data.request_entity.key()
        profile_key = self.data.requester_profile.key()
        organization_key = self.data.organization.key()

        def accept_request_txn():
            request = db.get(request_key)
            profile = db.get(profile_key)

            request.status = "accepted"
            profile.is_mentor = True
            profile.mentor_for.append(organization_key)
            profile.mentor_for = list(set(profile.mentor_for))

            profile.put()
            request.put()

            context = notifications.handledRequestContext(self.data, request.status)
            sub_txn = mailer.getSpawnMailTaskTxn(context, parent=request)
            # TODO(SRabbelier): just call as soon as we make User Request's parent
            db.run_in_transaction(sub_txn)

        accept_request_txn()
开发者ID:adviti,项目名称:melange,代码行数:28,代码来源:request.py

示例11: context

  def context(self):
    assert isSet(self.data.url_user)
    assert isSet(self.data.url_profile)

    # TODO(nathaniel): Eliminate this state-setting call.
    self.data.redirect.profile()

    is_banned = self.data.url_profile.status == 'invalid'

    profile_banned = ToggleButtonTemplate(
        self.data, 'on_off', 'Banned', 'user-banned',
        self.data.redirect.urlOf(self._getActionURLName()),
        checked=is_banned,
        help_text=self._getHelpText(),
        labels={
            'checked': 'Yes',
            'unchecked': 'No'})
    self.toggle_buttons.append(profile_banned)

    context = {
        'title': 'Host Actions',
        'toggle_buttons': self.toggle_buttons,
        }

    return context
开发者ID:rhyolight,项目名称:nupic.son,代码行数:25,代码来源:profile_show.py

示例12: context

  def context(self, data, check, mutator):
    assert isSet(data.program)
    assert isSet(data.timeline)
    assert isSet(data.student_evaluation_record)

    record = data.student_evaluation_record
    student = data.url_ndb_profile

    org_key = project_model.GSoCProject.org.get_value_for_datastore(
        data.url_project)
    org = ndb.Key.from_old_key(org_key).get()

    context = {
        'page_name': 'Student evaluation - %s' % (student.public_name),
        'student': student.public_name,
        'organization': org.name,
        'project': data.url_project.title,
        'css_prefix': GSoCStudentEvaluationReadOnlyTemplate.Meta.css_prefix,
        }

    if record:
      context['record'] = GSoCStudentEvaluationReadOnlyTemplate(record)

    if data.timeline.surveyPeriod(data.student_evaluation):
      if data.role == 'student':
        context['update_link'] = data.redirect.survey_record(
            data.student_evaluation.link_id).urlOf(
            'gsoc_take_student_evaluation')
      else:
        context['submission_msg'] = ugettext(
            'Bug your student to submit the evaluation.')

    return context
开发者ID:rhyolight,项目名称:nupic.son,代码行数:33,代码来源:student_evaluation.py

示例13: context

  def context(self):
    assert isSet(self.data.program)
    assert isSet(self.data.timeline)
    assert isSet(self.data.student_evaluation_record)

    record = self.data.student_evaluation_record
    student = self.data.url_profile

    context = {
        'page_name': 'Student evaluation - %s' % (student.name()),
        'student': student.name(),
        'organization': self.data.project.org.name,
        'project': self.data.project.title,
        'top_msg': LoggedInMsg(self.data, apply_link=False),
        'css_prefix': GSoCStudentEvaluationReadOnlyTemplate.Meta.css_prefix,
        }

    if record:
      context['record'] = GSoCStudentEvaluationReadOnlyTemplate(record)

    if self.data.timeline.surveyPeriod(self.data.student_evaluation):
      if self.data.role == 'student':
        context['update_link'] = self.data.redirect.survey_record(
            self.data.student_evaluation.link_id).urlOf(
            'gsoc_take_student_evaluation')
      else:
        context['submission_msg'] = ugettext(
            'Bug your student to submit the evaluation.')

    return context
开发者ID:adviti,项目名称:melange,代码行数:30,代码来源:student_evaluation.py

示例14: context

    def context(self):
        """Handler to for GSoC Show Request Page HTTP get request.
    """
        assert isSet(self.data.request_entity)
        assert isSet(self.data.can_respond)
        assert isSet(self.data.organization)
        assert isSet(self.data.requester)

        # This code is dupcliated between request and invite
        status = self.data.request_entity.status

        can_accept = can_reject = can_withdraw = can_resubmit = False

        if self.data.can_respond:
            # admin speaking
            if status == "pending":
                can_accept = True
                can_reject = True
            if status == "rejected":
                can_accept = True
        else:
            # requester speaking
            if status == "withdrawn":
                can_resubmit = True
            if status == "pending":
                can_withdraw = True

        show_actions = can_accept or can_reject or can_withdraw or can_resubmit

        org_key = self.data.organization.key()
        status_msg = None

        if self.data.requester_profile.key() == self.data.profile.key():
            if org_key in self.data.requester_profile.org_admin_for:
                status_msg = "You are now an organization administrator for this organization."
            elif org_key in self.data.requester_profile.mentor_for:
                status_msg = "You are now a mentor for this organization."
        else:
            if org_key in self.data.requester_profile.org_admin_for:
                status_msg = "This user is now an organization administrator with your organization."
            elif org_key in self.data.requester_profile.mentor_for:
                status_msg = "This user is now a mentor with your organization."

        return {
            "page_name": "Request to become a mentor",
            "request": self.data.request_entity,
            "org": self.data.organization,
            "actions": self.ACTIONS,
            "status_msg": status_msg,
            "user_name": self.data.requester_profile.name(),
            "user_link_id": self.data.requester.link_id,
            "user_email": accounts.denormalizeAccount(self.data.requester.account).email(),
            "show_actions": show_actions,
            "can_accept": can_accept,
            "can_reject": can_reject,
            "can_withdraw": can_withdraw,
            "can_resubmit": can_resubmit,
        }
开发者ID:adviti,项目名称:melange,代码行数:58,代码来源:request.py

示例15: isPossibleMentorForProposal

  def isPossibleMentorForProposal(self, mentor_profile=None):
    """Checks if the user is a possible mentor for the proposal in the data.
    """
    assert isSet(self.profile)
    assert isSet(self.proposal)

    profile = mentor_profile if mentor_profile else self.profile

    return profile.key() in self.proposal.possible_mentors
开发者ID:adviti,项目名称:melange,代码行数:9,代码来源:request_data.py


注:本文中的soc.views.helper.access_checker.isSet函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。