app/soc/views/models/organization.py
author Sverre Rabbelier <srabbelier@gmail.com>
Sat, 06 Dec 2008 14:25:24 +0000
changeset 682 187f4d95fedb
child 690 14e9f484412c
permissions -rw-r--r--
Added organizations Really basic for now, next stop is to have a proper document selector for the Presences. Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Organizations.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
  ]
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
from google.appengine.api import users
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from django import forms
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from soc.logic import dicts
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
from soc.logic import cleaning
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
from soc.views.helper import redirects
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.views.models import group
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
from soc.views.models import program as program_view
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
import soc.models.organization
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
import soc.logic.models.organization
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
class View(group.View):
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
  """View methods for the Organization model.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
  """
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
  def __init__(self, params=None):
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
    """Defines the fields and methods required for the base View class
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
    to provide the user with list, public, create, edit and delete views.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
    Params:
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
      original_params: a dict with params for this View
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
    """
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    new_params = {}
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    new_params['logic'] = soc.logic.models.organization.logic
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    new_params['scope_view'] = program_view
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
    new_params['scope_redirect'] = redirects.getCreateRedirect
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
    new_params['name'] = "Organization"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
    new_params['name_short'] = "Organization"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
    new_params['name_plural'] = "Organizations"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
    new_params['url_name'] = "org"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    new_params['module_name'] = "organization"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
    new_params['create_extra_dynafields'] = {
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
        'scope_path': forms.CharField(widget=forms.HiddenInput,
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
                                   required=True),
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
        'clean_link_id': cleaning.clean_link_id,
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
        }
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    params = dicts.merge(params, new_params)
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
    super(View, self).__init__(params=params)
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
view = View()
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
create = view.create
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
delete = view.delete
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
edit = view.edit
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
list = view.list
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
public = view.public