app/soc/views/models/org_app.py
changeset 1151 3116b927f4b9
child 1182 5bea281505f4
equal deleted inserted replaced
1150:7ec111a4d0f1 1151:3116b927f4b9
       
     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 Organization App profiles.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21     '"Lennard de Rijk" <ljvderijk@gmail.com>',
       
    22   ]
       
    23 
       
    24 
       
    25 from django import forms
       
    26 
       
    27 from soc.logic import dicts
       
    28 from soc.logic.models import org_app as org_app_logic
       
    29 from soc.views.helper import access
       
    30 from soc.views.models import group_app
       
    31 
       
    32 import soc.logic.dicts
       
    33 
       
    34 
       
    35 class View(group_app.View):
       
    36   """View methods for the Organization Application model.
       
    37   """
       
    38 
       
    39   def __init__(self, params=None):
       
    40     """Defines the fields and methods required for the base View class
       
    41     to provide the user with list, public, create, edit and delete views.
       
    42 
       
    43     Params:
       
    44       params: a dict with params for this View
       
    45     """
       
    46 
       
    47     #TODO(ljvderijk) do the right rights check
       
    48     rights = access.Checker(params)
       
    49     rights['create'] = ['checkIsDeveloper']
       
    50     rights['delete'] = [('checkIsMyApplication', org_app_logic)]
       
    51     rights['edit'] = [('checkIsMyApplication', org_app_logic)]
       
    52     rights['list'] = ['checkIsDeveloper']
       
    53     rights['public'] = [('checkIsMyApplication', org_app_logic)]
       
    54     rights['review'] = ['checkIsDeveloper']
       
    55 
       
    56     new_params = {}
       
    57 
       
    58     new_params['rights'] = rights
       
    59     new_params['logic'] = org_app_logic.logic
       
    60 
       
    61     new_params['sidebar_grouping'] = 'Organization'
       
    62 
       
    63     new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
       
    64         'created_on', 'last_modified_on']
       
    65     # TODO(ljvderijk) add cleaning method to ensure uniqueness
       
    66     new_params['create_extra_dynafields'] = {
       
    67             'scope_path': forms.fields.CharField(widget=forms.HiddenInput,
       
    68                                              required=True)}
       
    69 
       
    70     new_params['name'] = "Organization Application"
       
    71     new_params['name_plural'] = "Organization Applications"
       
    72     new_params['name_short'] = "Org App"
       
    73     new_params['url_name'] = "org_app"
       
    74     new_params['group_url_name'] = 'org'
       
    75 
       
    76     new_params['review_template'] = 'soc/org_app/review.html'
       
    77 
       
    78     params = dicts.merge(params, new_params)
       
    79 
       
    80     super(View, self).__init__(params=params)
       
    81 
       
    82 
       
    83 view = View()
       
    84 
       
    85 create = view.create
       
    86 delete = view.delete
       
    87 edit = view.edit
       
    88 list = view.list
       
    89 public = view.public
       
    90 export = view.export
       
    91 review = view.review
       
    92 review_overview = view.reviewOverview
       
    93