app/soc/views/models/priority_group.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sat, 24 Oct 2009 16:23:31 -0700
changeset 3043 187c1709756b
parent 2212 4095892a3c99
permissions -rw-r--r--
GSoC Views
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2208
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Priority Groups.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
  ]
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
from soc.logic import dicts
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from soc.logic.models.priority_group import logic as priority_group_logic
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from soc.views.helper import access
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
from soc.views.helper import decorators
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from soc.views.models import base
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
class View(base.View):
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
  """View methods for the Priority Group model.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
  """
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
  def __init__(self, params=None):
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
    """Defines the fields and methods required for the base View class
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
    to provide the user with list, public, create, edit and delete views.
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
    Params:
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
      params: a dict with params for this View
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
    """
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
    rights = access.Checker(params)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
    new_params = {}
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
    new_params['rights'] = rights
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
    new_params['logic'] = priority_group_logic
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    new_params['name'] = "Priority Group"
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    new_params['no_create_raw'] = True
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
    new_params['no_create_with_scope'] = True
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    new_params['no_create_with_key_fields'] = True
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
    params = dicts.merge(params, new_params)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
    super(View, self).__init__(params=params)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
view = View()
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
delete = decorators.view(view.delete)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
edit = decorators.view(view.edit)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
list = decorators.view(view.list)
1bf4e904d5f5 Add priority groups (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
public = decorators.view(view.public)