app/soc/logic/models/mentor.py
author Lennard de Rijk <ljvderijk@gmail.com>
Fri, 20 Mar 2009 18:53:37 +0000
changeset 1955 06ed84dbb1ed
parent 1307 091a21cf3627
child 1972 5f1e3b5262cb
permissions -rw-r--r--
Moved canResign check to role logic so subclasses can override. Also changed the variable name in the templates to be more generic. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1121
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
1307
091a21cf3627 Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1121
diff changeset
     3
# Copyright 2009 the Melange authors.
1121
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
#
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
#
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    17
"""Mentor (Model) query functions.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    18
"""
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
  ]
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
from soc.logic.models import role
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    26
from soc.logic.models import organization as org_logic
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
import soc.models.mentor
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
import soc.models.role
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
class Logic(role.Logic):
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    33
  """Logic methods for the Mentor model.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
  """
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    35
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
  def __init__(self, model=soc.models.mentor.Mentor,
1955
06ed84dbb1ed Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
    37
               base_model=soc.models.role.Role, scope_logic=org_logic,
06ed84dbb1ed Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
    38
               disallow_last_resign=False):
1121
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    39
    """Defines the name, key_name and model for this entity.
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
    """
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
    super(Logic, self).__init__(model=model, base_model=base_model,
1955
06ed84dbb1ed Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
    43
                                scope_logic=scope_logic,
06ed84dbb1ed Moved canResign check to role logic so subclasses can override.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1307
diff changeset
    44
                                disallow_last_resign=disallow_last_resign)
1121
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
77c602de9248 Added mentor and org_admin logic.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
logic = Logic()