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