<commit_before># Copyright 2012 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

""" This module contains a model used to represent a connection between
a user and an organization.
"""
from django.utils.translation import ugettext
from google.appengine.ext import db
from soc.models.organization import Organization
from soc.models.profile import Profile


# Constants to represent the different states that users and org admins
# may select for a connection. Users may select either ROLE or NO_ROLE,
# meaning that they will accept whatever role the org admin assigns them.
# Org Admins may choose the first three, either declining to accept a
# role or selecting one. It is up to the org admins to leave messages
# on the connection to differentiate between a declined connection and
# one that has just not been answered.
ORG_ADMIN_ROLE = 'org_admin'
MENTOR_ROLE = 'mentor'
NO_ROLE = 'no_role'
ROLE = 'role'

VERBOSE_ROLE_NAMES = {
    NO_ROLE: ugettext('No Role'),
    ROLE: ugettext('Role'),
    MENTOR_ROLE: ugettext('Mentor'),
    ORG_ADMIN_ROLE: ugettext('Organization Administrator')
    }

# Response tuples that encapsulate the available roles that users and org
# admins may respond with in their respective ShowConnection views.
USER_RESPONSES = ((NO_ROLE, 'No Role'), (ROLE, 'Role'))
ORG_RESPONSES = (
  (NO_ROLE, 'No Role'),
  (MENTOR_ROLE, 'Mentor'),
  (ORG_ADMIN_ROLE, 'Org Admin')
  )


class Connection(db.Model):
  """Connection model.

  This model is intended to be used to represent a connection between a user
  and an organization. Each initiated connection specifies a role which
  the organization has granted to the user and a role which the user requests
  from the organization. These two properties put together determine what
  type of role the user has for the organization at this moment.

  The class also defines a number of convenience methods to clean up
  a lot of the logic in the connection module for determining valid actions.

  Parent: soc.models.profile.Profile
  """

  #: The User's state with respect to a given role.
  user_role = db.StringProperty(default=NO_ROLE,
      choices=(NO_ROLE, ROLE))

  #: The Org's state with respect to a given role.
  org_role = db.StringProperty(default=NO_ROLE,
      choices=(NO_ROLE, MENTOR_ROLE, ORG_ADMIN_ROLE))

  #: The organization entity involved in the connection for which a user
  #: may gain heightened privileges.
  organization = db.ReferenceProperty(Organization,
      collection_name='user_connections')

  #: Property for the ShowConnection pages to keep track of the time that the
  #: connection was initiated.
  created_on = db.DateTimeProperty(auto_now_add=True)

  #: Property for the ShowConnection pages to keep a record of the last time
  #: that either the org or user modified the connection.
  last_modified = db.DateTimeProperty(auto_now=True)

  #: Property indicating that a member of the organization has seen
  #: the latest changes made by the user.
  seen_by_org = db.BooleanProperty()

  #: Property indicating that the user has seen the latest changes made
  #: by a member of the organization.
  seen_by_user = db.BooleanProperty()

  def userRequestedRole(self):
    """Indicate whether or not a user has requested to be promoted to a
    role for an organization.

    Returns:
      True if the user has opted for a role.
    """
    return self.user_role == ROLE

  def orgOfferedMentorRole(self):
    """Indicate whether or not the organization has offered a mentor role.

    Returns:
      True if the organization has opted for a mentor role.
    """
    return self.org_role == MENTOR_ROLE

  def orgOfferedOrgAdminRole(self):
    """Indicate whether or not the organization has offered an organization
    administrator role.

    Returns:
      True if the organization has opted for an organization
      administrator role.
    """
    return self.org_role == ORG_ADMIN_ROLE

  @staticmethod
  def allFields():
    """Returns a list of all names of fields in this model.
    """
    return ['user_role', 'org_role', 'organization', 'created_on']

  def keyName(self):
    """Returns a string which uniquely represents the entity.
    """
    return '/'.join([self.parent_key().name(), str(self.key().id())])

  def getRole(self):
    """Returns the assigned role from the org admin's perspective because it
    offers more information than the user's role.
    """
    if self.org_role == MENTOR_ROLE:
      return 'Mentor'
    elif self.org_role == ORG_ADMIN_ROLE:
      return 'Org Admin'
    else:
      return 'No Role'

<commit_msg>Add recently added fields to exclude.<commit_after># Copyright 2012 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

""" This module contains a model used to represent a connection between
a user and an organization.
"""
from django.utils.translation import ugettext
from google.appengine.ext import db
from soc.models.organization import Organization
from soc.models.profile import Profile


# Constants to represent the different states that users and org admins
# may select for a connection. Users may select either ROLE or NO_ROLE,
# meaning that they will accept whatever role the org admin assigns them.
# Org Admins may choose the first three, either declining to accept a
# role or selecting one. It is up to the org admins to leave messages
# on the connection to differentiate between a declined connection and
# one that has just not been answered.
ORG_ADMIN_ROLE = 'org_admin'
MENTOR_ROLE = 'mentor'
NO_ROLE = 'no_role'
ROLE = 'role'

VERBOSE_ROLE_NAMES = {
    NO_ROLE: ugettext('No Role'),
    ROLE: ugettext('Role'),
    MENTOR_ROLE: ugettext('Mentor'),
    ORG_ADMIN_ROLE: ugettext('Organization Administrator')
    }

# Response tuples that encapsulate the available roles that users and org
# admins may respond with in their respective ShowConnection views.
USER_RESPONSES = ((NO_ROLE, 'No Role'), (ROLE, 'Role'))
ORG_RESPONSES = (
  (NO_ROLE, 'No Role'),
  (MENTOR_ROLE, 'Mentor'),
  (ORG_ADMIN_ROLE, 'Org Admin')
  )


class Connection(db.Model):
  """Connection model.

  This model is intended to be used to represent a connection between a user
  and an organization. Each initiated connection specifies a role which
  the organization has granted to the user and a role which the user requests
  from the organization. These two properties put together determine what
  type of role the user has for the organization at this moment.

  The class also defines a number of convenience methods to clean up
  a lot of the logic in the connection module for determining valid actions.

  Parent: soc.models.profile.Profile
  """

  #: The User's state with respect to a given role.
  user_role = db.StringProperty(default=NO_ROLE,
      choices=(NO_ROLE, ROLE))

  #: The Org's state with respect to a given role.
  org_role = db.StringProperty(default=NO_ROLE,
      choices=(NO_ROLE, MENTOR_ROLE, ORG_ADMIN_ROLE))

  #: The organization entity involved in the connection for which a user
  #: may gain heightened privileges.
  organization = db.ReferenceProperty(Organization,
      collection_name='user_connections')

  #: Property for the ShowConnection pages to keep track of the time that the
  #: connection was initiated.
  created_on = db.DateTimeProperty(auto_now_add=True)

  #: Property for the ShowConnection pages to keep a record of the last time
  #: that either the org or user modified the connection.
  last_modified = db.DateTimeProperty(auto_now=True)

  #: Property indicating that a member of the organization has seen
  #: the latest changes made by the user.
  seen_by_org = db.BooleanProperty()

  #: Property indicating that the user has seen the latest changes made
  #: by a member of the organization.
  seen_by_user = db.BooleanProperty()

  def userRequestedRole(self):
    """Indicate whether or not a user has requested to be promoted to a
    role for an organization.

    Returns:
      True if the user has opted for a role.
    """
    return self.user_role == ROLE

  def orgOfferedMentorRole(self):
    """Indicate whether or not the organization has offered a mentor role.

    Returns:
      True if the organization has opted for a mentor role.
    """
    return self.org_role == MENTOR_ROLE

  def orgOfferedOrgAdminRole(self):
    """Indicate whether or not the organization has offered an organization
    administrator role.

    Returns:
      True if the organization has opted for an organization
      administrator role.
    """
    return self.org_role == ORG_ADMIN_ROLE

  @staticmethod
  def allFields():
    """Returns a list of all names of fields in this model.
    """
    return ['user_role', 'org_role', 'organization', 'created_on',
        'seen_by_org', 'seen_by_user']

  def keyName(self):
    """Returns a string which uniquely represents the entity.
    """
    return '/'.join([self.parent_key().name(), str(self.key().id())])

  def getRole(self):
    """Returns the assigned role from the org admin's perspective because it
    offers more information than the user's role.
    """
    if self.org_role == MENTOR_ROLE:
      return 'Mentor'
    elif self.org_role == ORG_ADMIN_ROLE:
      return 'Org Admin'
    else:
      return 'No Role'


{'fraction_non_alphanumeric': 0.07330405075646657, 'fraction_numerical': 0.0015617374328940946, 'mean_word_length': 3.8536238749407863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1188040', 'n_tokens_mistral': 2924, 'n_tokens_neox': 2798, 'n_words': 1245}