app/soc/modules/ghop/views/models/timeline.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 08 Sep 2009 21:11:23 +0200
changeset 2890 515ea474e0a2
child 2893 1adc6a815c71
permissions -rw-r--r--
Added GHOP Timeline View. Reviewed by: to-be-reviewed
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
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
    29
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
    30
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
    31
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
import soc.modules.ghop.logic.models.timeline
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
class View(timeline.View):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
  """View methods for the GHOP Timeline model.
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
  """
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
  def __init__(self, params=None):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
    """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
    41
    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
    42
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    43
    Params:
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
      params: a dict with params for this View
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
    """
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
    rights = ghop_access.GHOPChecker(params)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
    rights['edit'] = [('checkCanEditTimeline',
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    49
                       [ghop_program_logic.logic, ghop_timeline_logic.logic])]
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    50
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
    new_params = {}
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
    new_params['logic'] = soc.modules.ghop.logic.models.timeline.logic
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
    new_params['rights'] = rights
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
    new_params['name'] = "GHOP Timeline"
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
    new_params['module_name'] = "timeline"
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
    new_params['module_package'] = 'soc.modules.ghop.views.models'
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
    new_params['url_name'] = 'ghop/timeline'
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
    params = dicts.merge(params, new_params, sub_merge=True)
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
    super(View, self).__init__(params=params)
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
view = View()
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
edit = decorators.view(view.edit)
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    69
public = decorators.view(view.public)