app/soc/logic/models/sponsor.py
author Mario Ferraro <fadinlight@gmail.com>
Sun, 15 Nov 2009 22:12:20 +0100
changeset 3093 d1be59b6b627
parent 2808 0b2d25b1c473
permissions -rw-r--r--
GMaps related JS changed to use new google namespace. Google is going to change permanently in the future the way to load its services, so better stay safe. Also this commit shows uses of the new melange.js module. Fixes Issue 634.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
1308
35b75ffcbb37 Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1307
diff changeset
     3
# Copyright 2008 the Melange authors.
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
318
e8eeccd7ef0f Fix typos in doc string in sponsor.py and settings.py
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 316
diff changeset
    17
"""Sponsor (Model) query functions.
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
429
e50e18936f06 Fixed typo in e-mail address
Sverre Rabbelier <srabbelier@gmail.com>
parents: 410
diff changeset
    21
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
  ]
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
535
9045b8888772 Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents: 530
diff changeset
    25
from soc.logic.models import group
316
9efdc7bc3565 Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 308
diff changeset
    26
481
94834a1e6c01 Attempt to rename User.id to User.account, in preparation for making User be
Todd Larsen <tlarsen@google.com>
parents: 432
diff changeset
    27
import soc.models.group
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
import soc.models.sponsor
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
535
9045b8888772 Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents: 530
diff changeset
    31
class Logic(group.Logic):
499
d22e4fe8e64b Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 481
diff changeset
    32
  """Logic methods for the Sponsor model.
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
  """
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
535
9045b8888772 Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents: 530
diff changeset
    35
  def __init__(self, model=soc.models.sponsor.Sponsor,
9045b8888772 Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents: 530
diff changeset
    36
               base_model=soc.models.group.Group):
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
    """Defines the name, key_name and model for this entity.
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
    """
655
9635cbaa2dcd Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 535
diff changeset
    39
9635cbaa2dcd Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 535
diff changeset
    40
    super(Logic, self).__init__(model=model, base_model=base_model)
410
2af7f84f4fc7 Moved all key_name related things to the logic modules
Sverre Rabbelier <srabbelier@gmail.com>
parents: 368
diff changeset
    41
368
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    42
  def isDeletable(self, entity):
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    43
    """Returns whether the specified Sponsor entity can be deleted.
2808
0b2d25b1c473 Take the safe way when trying to delete a Sponsor.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    44
368
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    45
    Args:
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    46
      entity: an existing Sponsor entity in datastore
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    47
    """
655
9635cbaa2dcd Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 535
diff changeset
    48
368
f90f9b22751a Move TODO about isDeletable Sponsor logic method to sponsor.py module and extend a little bit doc string.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 318
diff changeset
    49
    # TODO(pawel.solyga): Check if Sponsor can be deleted (no Hosts, Programs)
2808
0b2d25b1c473 Take the safe way when trying to delete a Sponsor.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1308
diff changeset
    50
    return False
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
535
9045b8888772 Refactor classes in soc/logic/models to make more use of inheritance. Add
Todd Larsen <tlarsen@google.com>
parents: 530
diff changeset
    52
308
740090cd17c9 Added invididual model logic files
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
logic = Logic()