app/soc/views/models/program.py
author Sverre Rabbelier <srabbelier@gmail.com>
Mon, 26 Jan 2009 23:32:10 +0000
changeset 1007 3b66772d21a5
parent 973 f9c2b32b9e2b
child 1017 6ad4fdb48840
permissions -rw-r--r--
Major refactor of the access module The first step to sanity is a leap into the unknown? Create an object to represent the access checks for each module instead of a bunch of loose functions. Converted all views and params.py to use the new access checker. Main differences: * arguments to a checker can be passed by using a tuple * checkers are referenced by string, rather than directly * the Checker constructor handles merging with child views Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Programs.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
769
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  ]
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from django import forms
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
from soc.logic import dicts
778
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    29
from soc.logic.models import program as program_logic
666
b9b0506efe8d Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 663
diff changeset
    30
from soc.views import helper
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
    31
from soc.views.helper import access
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.views.helper import redirects
778
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    33
from soc.views.helper import widgets
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    34
from soc.views.models import presence
714
3e2ce3d8057a Add missing dots in docstrings, proper sorting of imports and small docstring typo fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 712
diff changeset
    35
from soc.views.models import document as document_view
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
from soc.views.models import sponsor as sponsor_view
705
0ab17e14df95 Move document sidebar entries extraction to document.View
Sverre Rabbelier <srabbelier@gmail.com>
parents: 700
diff changeset
    37
from soc.views.sitemap import sidebar
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
import soc.logic.models.program
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    42
class View(presence.View):
666
b9b0506efe8d Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 663
diff changeset
    43
  """View methods for the Program model.
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
  """
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    46
  def __init__(self, params=None):
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
    """Defines the fields and methods required for the base View class
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
    to provide the user with list, public, create, edit and delete views.
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    Params:
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    51
      params: a dict with params for this View
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
    52
    """
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
    53
1007
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 973
diff changeset
    54
    rights = access.Checker(params)
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 973
diff changeset
    55
    rights['any_access'] = ['allow']
3b66772d21a5 Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 973
diff changeset
    56
    rights['show'] = ['allow']
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    58
    new_params = {}
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    59
    new_params['logic'] = soc.logic.models.program.logic
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
    60
    new_params['rights'] = rights
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
662
0e89b027b140 Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents: 660
diff changeset
    62
    new_params['scope_view'] = sponsor_view
681
48983ecf4665 Cleanups in group and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 680
diff changeset
    63
    new_params['scope_redirect'] = redirects.getCreateRedirect
662
0e89b027b140 Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents: 660
diff changeset
    64
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    65
    new_params['name'] = "Program"
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
    67
    new_params['edit_template'] = 'soc/program/edit.html'
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
    68
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    69
    new_params['extra_dynaexclude'] = ['timeline']
810
208659644a7f Hide 'tos' pull-down selector from Program profile forms.
Todd Larsen <tlarsen@google.com>
parents: 799
diff changeset
    70
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    71
    new_params['create_extra_dynafields'] = {
649
95a41542e693 Finish Program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 647
diff changeset
    72
        'description': forms.fields.CharField(widget=helper.widgets.TinyMCE(
668
77f9a6ea6e67 Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 666
diff changeset
    73
            attrs={'rows':10, 'cols':40})),
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    74
668
77f9a6ea6e67 Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 666
diff changeset
    75
        'scope_path': forms.CharField(widget=forms.HiddenInput, required=True),
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    76
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
    77
        'workflow' : forms.ChoiceField(choices=[('gsoc','Project-based'),
769
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
    78
            ('ghop','Task-based')], required=True),
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
        }
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
778
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    81
    new_params['edit_extra_dynafields'] = {
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    82
        'workflow': forms.CharField(widget=widgets.ReadOnlyInput(),
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    83
                                   required=True),
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    84
        }
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
    85
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    86
    params = dicts.merge(params, new_params)
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
656
a76f1b443ea4 Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 653
diff changeset
    88
    super(View, self).__init__(params=params)
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
    89
769
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
    90
  def _editPost(self, request, entity, fields):
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
    91
    """See base._editPost().
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
    92
    """
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
    93
770
eb2e69312953 Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 769
diff changeset
    94
    if not entity:
eb2e69312953 Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 769
diff changeset
    95
      # there is no existing entity so create a new timeline
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
    96
      fields['timeline'] = self._createTimelineForType(fields)
770
eb2e69312953 Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 769
diff changeset
    97
    else:
eb2e69312953 Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 769
diff changeset
    98
      # use the timeline from the entity
eb2e69312953 Fixed a bug where a new timeline would get created on every edit of an existing program.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 769
diff changeset
    99
      fields['timeline'] = entity.timeline
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   100
901
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   101
    super(View, self)._editPost(request, entity, fields)
d580a057103d Presence is now a 'abstract' View, pull in members from program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   102
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   103
  def _createTimelineForType(self, fields):
771
0b1beae179f5 Typo and style fixes.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 770
diff changeset
   104
    """Creates and stores a timeline model for the given type of program.
769
a0ee643fe832 Added an elementary workflow choosing method to program creation.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 755
diff changeset
   105
    """
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   106
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   107
    workflow = fields['workflow']
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   108
778
bc13cd968946 Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents: 777
diff changeset
   109
    timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow]
777
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   110
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   111
    key_fields = self._logic.getKeyFieldsFromDict(fields)
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   112
    key_name = self._logic.getKeyNameForFields(key_fields)
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   113
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   114
    properties = {'scope_path': key_name}
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   115
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   116
    timeline = timeline_logic.updateOrCreateFromFields(properties, properties)
16dcdb8f3357 Added an 'edit timeline' button to the program edit page
Sverre Rabbelier <srabbelier@gmail.com>
parents: 771
diff changeset
   117
    return timeline
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   118
973
f9c2b32b9e2b Do not pass around request anymore in buildSidebar
Sverre Rabbelier <srabbelier@gmail.com>
parents: 934
diff changeset
   119
  def getExtraMenus(self, params=None):
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   120
    """Returns the extra menu's for this view.
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   121
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   122
    A menu item is generated for each program that is currently
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   123
    running. The public page for each program is added as menu item,
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   124
    as well as all public documents for that program.
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   125
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   126
    Args:
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   127
      params: a dict with params for this View.
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   128
    """
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   129
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   130
    params = dicts.merge(params, self._params)
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   131
    logic = params['logic']
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   132
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   133
    entities = logic.getForLimitAndOffset(1000)
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   134
712
b9e4cc00f30a Some forgotten changes with the access_type commit
Sverre Rabbelier <srabbelier@gmail.com>
parents: 705
diff changeset
   135
    doc_params = document_view.view.getParams()
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   136
    menus = []
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   137
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   138
    for entity in entities:
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   139
      menu = {}
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   140
      menu['heading'] = entity.short_name
705
0ab17e14df95 Move document sidebar entries extraction to document.View
Sverre Rabbelier <srabbelier@gmail.com>
parents: 700
diff changeset
   141
      items = document_view.view.getMenusForScope(entity, params)
973
f9c2b32b9e2b Do not pass around request anymore in buildSidebar
Sverre Rabbelier <srabbelier@gmail.com>
parents: 934
diff changeset
   142
      menu['items'] = sidebar.getSidebarMenu(items, params=doc_params)
700
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   143
      menus.append(menu)
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   144
8baf8367340d Dynamically add sidebar items for programs
Sverre Rabbelier <srabbelier@gmail.com>
parents: 681
diff changeset
   145
    return menus
647
355ac73823a1 Swap order of merged params to fix sponsor select view
Sverre Rabbelier <srabbelier@gmail.com>
parents: 643
diff changeset
   146
643
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
view = View()
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   148
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   149
create = view.create
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   150
delete = view.delete
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   151
edit = view.edit
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   152
list = view.list
b57d538a9dd3 Added programs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   153
public = view.public
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 810
diff changeset
   154
export = view.export
923
5a10f6db154b Hook up the 'home' view for site and program
Sverre Rabbelier <srabbelier@gmail.com>
parents: 901
diff changeset
   155
home = view.home
934
9fcc08971efe Add a 'pick' view to the appropriate views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 923
diff changeset
   156
pick = view.pick