app/soc/modules/ghop/views/models/timeline.py
author Mario Ferraro <fadinlight@gmail.com>
Sun, 15 Nov 2009 22:12:20 +0100
changeset 3093 d1be59b6b627
parent 2936 75f9c945ed8a
permissions -rw-r--r--
GMaps related JS changed to use new google namespace. Google is going to change permanently in the future the way to load its services, so better stay safe. Also this commit shows uses of the new melange.js module. Fixes Issue 634.
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.views.helper import access as ghop_access
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
import soc.modules.ghop.logic.models.timeline
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
class View(timeline.View):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
  """View methods for the GHOP Timeline model.
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
  def __init__(self, params=None):
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
    """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
    42
    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
    43
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
    Params:
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
      params: a dict with params for this View
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
515ea474e0a2 Added GHOP Timeline View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
    rights = ghop_access.GHOPChecker(params)
2936
75f9c945ed8a Added program_logic parameter to checkCanEditTimeline access check and corresponding changes in timeline views.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2893
diff changeset
    49
    rights['edit'] = [('checkCanEditTimeline', [ghop_program_logic.logic])]
2890
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)