app/soc/logic/models/program.py
author Sverre Rabbelier <srabbelier@gmail.com>
Fri, 12 Dec 2008 00:34:12 +0000
changeset 721 6f1d29857072
parent 671 2c02178037ff
child 769 a0ee643fe832
permissions -rw-r--r--
Added a filter method to dicts The best way to explain this is probably with an example: >>> split({'foo':'bar', 'bar':['one', 'two'], 'baz': ['three', 'four']}) [{'bar': 'one', 'foo': 'bar', 'baz': 'three'}, {'bar': 'two', 'foo': 'bar', 'baz': 'three'}, {'bar': 'one', 'foo': 'bar', 'baz': 'four'}, {'bar': 'two', 'foo': 'bar', 'baz': 'four'}] Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    17
"""Program (Model) query functions.
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
  ]
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    25
from soc.logic.models import base
671
2c02178037ff Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents: 667
diff changeset
    26
from soc.logic.models import sponsor as sponsor_logic
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    27
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    28
import soc.models.program
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    29
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    30
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    31
class Logic(base.Logic):
667
f96095df1433 Some more import sorting fixes and docstring typos in program modules and soc.views.helper.redirects module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 655
diff changeset
    32
  """Logic methods for the Program model
611
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
  """
2ec30182e5f1 Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
671
2c02178037ff Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents: 667
diff changeset
    35
  def __init__(self, model=soc.models.program.Program, 
2c02178037ff Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents: 667
diff changeset
    36
               base_model=None, scope_logic=sponsor_logic):
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    37
    """Defines the name, key_name and model for this entity.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    38
    """
655
9635cbaa2dcd Cleanups to the logic module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 643
diff changeset
    39
671
2c02178037ff Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents: 667
diff changeset
    40
    super(Logic, self).__init__(model=model, base_model=base_model,
2c02178037ff Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents: 667
diff changeset
    41
                                scope_logic=scope_logic)
620
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    42
e74e0b74625f Put the redirects in the views/helper/redirects.py module.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 611
diff changeset
    43
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 639
diff changeset
    44
logic = Logic()