app/soc/modules/ghop/views/models/timeline.py
author Lennard de Rijk <ljvderijk@gmail.com>
Mon, 14 Sep 2009 19:58:43 +0200
changeset 2919 cb677410c0f1
parent 2893 1adc6a815c71
child 2936 75f9c945ed8a
permissions -rw-r--r--
Using the new checkIsMyActiveRole check where necessary.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2890
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
#
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
#
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
"""GHOP specific views for Timeline.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
"""
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
__authors__ = [
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
    '"Madhusudan.C.S" <madhusudancs@gmail.com>',
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
  ]
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
from soc.logic import dicts
2893
1adc6a815c71 Several style and import fixes regarding the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2890
diff changeset
    27
from soc.views.helper import decorators
1adc6a815c71 Several style and import fixes regarding the GHOP module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2890
diff changeset
    28
from soc.views.models import timeline
2890
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
from soc.modules.ghop.logic.models import program as ghop_program_logic
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
from soc.modules.ghop.logic.models import timeline as ghop_timeline_logic
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
from soc.modules.ghop.views.helper import access as ghop_access
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
import soc.modules.ghop.logic.models.timeline
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
class View(timeline.View):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
  """View methods for the GHOP Timeline model.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
  """
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
  def __init__(self, params=None):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
    """Defines the fields and methods required for the program View class
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    43
    to provide the user with list, public, create, edit and delete views.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
    Params:
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
      params: a dict with params for this View
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
    """
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    49
    rights = ghop_access.GHOPChecker(params)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    50
    rights['edit'] = [('checkCanEditTimeline',
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
                       [ghop_program_logic.logic, ghop_timeline_logic.logic])]
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
    new_params = {}
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
    new_params['logic'] = soc.modules.ghop.logic.models.timeline.logic
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
    new_params['rights'] = rights
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
    new_params['name'] = "GHOP Timeline"
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
    new_params['module_name'] = "timeline"
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
    new_params['module_package'] = 'soc.modules.ghop.views.models'
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
    new_params['url_name'] = 'ghop/timeline'
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    62
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    63
    params = dicts.merge(params, new_params, sub_merge=True)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    64
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    65
    super(View, self).__init__(params=params)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    67
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    68
view = View()
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    69
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    70
edit = decorators.view(view.edit)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    71
public = decorators.view(view.public)