app/soc/views/models/org_app.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 01 Feb 2009 16:09:43 +0000
changeset 1151 3116b927f4b9
child 1182 5bea281505f4
permissions -rw-r--r--
Added org_app view and templates. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1151
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
#
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
#
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    17
"""Views for Organization App profiles.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    18
"""
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
  ]
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
from django import forms
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    26
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
from soc.logic import dicts
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
from soc.logic.models import org_app as org_app_logic
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
from soc.views.helper import access
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
from soc.views.models import group_app
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
import soc.logic.dicts
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    33
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    35
class View(group_app.View):
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    36
  """View methods for the Organization Application model.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    37
  """
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    38
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    39
  def __init__(self, params=None):
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
    """Defines the fields and methods required for the base View class
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    41
    to provide the user with list, public, create, edit and delete views.
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    43
    Params:
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
      params: a dict with params for this View
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
    """
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    46
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
    #TODO(ljvderijk) do the right rights check
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
    rights = access.Checker(params)
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    49
    rights['create'] = ['checkIsDeveloper']
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    50
    rights['delete'] = [('checkIsMyApplication', org_app_logic)]
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    51
    rights['edit'] = [('checkIsMyApplication', org_app_logic)]
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    52
    rights['list'] = ['checkIsDeveloper']
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    53
    rights['public'] = [('checkIsMyApplication', org_app_logic)]
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    54
    rights['review'] = ['checkIsDeveloper']
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    55
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    56
    new_params = {}
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    57
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    58
    new_params['rights'] = rights
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    59
    new_params['logic'] = org_app_logic.logic
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    60
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    61
    new_params['sidebar_grouping'] = 'Organization'
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    62
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    63
    new_params['extra_dynaexclude'] = ['applicant', 'backup_admin', 'status',
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    64
        'created_on', 'last_modified_on']
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    65
    # TODO(ljvderijk) add cleaning method to ensure uniqueness
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    66
    new_params['create_extra_dynafields'] = {
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    67
            'scope_path': forms.fields.CharField(widget=forms.HiddenInput,
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    68
                                             required=True)}
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    69
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    70
    new_params['name'] = "Organization Application"
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    71
    new_params['name_plural'] = "Organization Applications"
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    72
    new_params['name_short'] = "Org App"
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    73
    new_params['url_name'] = "org_app"
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    74
    new_params['group_url_name'] = 'org'
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    75
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    76
    new_params['review_template'] = 'soc/org_app/review.html'
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    77
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    78
    params = dicts.merge(params, new_params)
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    79
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    80
    super(View, self).__init__(params=params)
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    81
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    82
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    83
view = View()
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    84
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    85
create = view.create
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    86
delete = view.delete
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    87
edit = view.edit
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    88
list = view.list
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    89
public = view.public
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    90
export = view.export
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    91
review = view.review
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    92
review_overview = view.reviewOverview
3116b927f4b9 Added org_app view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    93