app/soc/views/models/organization.py
author Sverre Rabbelier <srabbelier@gmail.com>
Thu, 12 Feb 2009 20:15:20 +0000
changeset 1284 92f7a24d8f42
parent 1283 438dceed3132
child 1303 08433090cff8
permissions -rw-r--r--
Add ToS agreement to mentor application related forms. Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Organizations.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  ]
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from django import forms
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
690
14e9f484412c Fix imports sorting in soc.views.models.organization.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 682
diff changeset
    28
from soc.logic import cleaning
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from soc.logic import dicts
1266
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    30
from soc.logic.models import organization as org_logic
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    31
from soc.logic.models import org_admin as org_admin_logic
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    32
from soc.logic.models import org_app as org_app_logic
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    33
from soc.views.helper import access
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    34
from soc.views.helper import dynaform
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
from soc.views.helper import redirects
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    36
from soc.views.helper import widgets
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
from soc.views.models import group
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
from soc.views.models import program as program_view
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
import soc.models.organization
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
import soc.logic.models.organization
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
class View(group.View):
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
  """View methods for the Organization model.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
  """
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
  def __init__(self, params=None):
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
    """Defines the fields and methods required for the base View class
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    to provide the user with list, public, create, edit and delete views.
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    Params:
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
      original_params: a dict with params for this View
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    """
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    56
    rights = access.Checker(params)
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    57
    rights['create'] = ['checkIsDeveloper']
1266
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    58
    rights['edit'] = [('checkHasActiveRoleForScope', 
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    59
                           [org_admin_logic.logic, 'link_id']),
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    60
                      ('checkIsActive', [org_logic.logic, None])]
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    61
    rights['delete'] = ['checkIsDeveloper']
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    62
    rights['home'] = ['allow']
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    63
    rights['list'] = ['checkIsDeveloper']
1266
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    64
    rights['list_requests'] = [('checkHasActiveRoleForScope', 
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    65
                                [org_admin_logic.logic, 'link_id'])]
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    66
    rights['list_roles'] = [('checkHasActiveRoleForScope', 
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    67
                             [org_admin_logic.logic, 'link_id'])]
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    68
    rights['applicant'] = [('checkIsApplicationAccepted',
e8feadcbc47f Changed the access checks for organization.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1264
diff changeset
    69
                            org_app_logic.logic)]
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    70
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
    new_params = {}
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
    new_params['logic'] = soc.logic.models.organization.logic
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
    new_params['scope_view'] = program_view
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
    new_params['scope_redirect'] = redirects.getCreateRedirect
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
    new_params['name'] = "Organization"
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
    new_params['url_name'] = "org"
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    79
    new_params['sidebar_grouping'] = 'Organizations'
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    81
    new_params['public_template'] = 'soc/organization/public.html'
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    82
    new_params['list_row'] = 'soc/organization/list/row.html'
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    83
    new_params['list_heading'] = 'soc/organization/list/heading.html'
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
    84
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    85
    new_params['application_logic'] = org_app_logic
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    86
    new_params['group_applicant_url'] = True
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
    87
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
    new_params['create_extra_dynafields'] = {
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
        'scope_path': forms.CharField(widget=forms.HiddenInput,
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
                                   required=True),
1221
0130e63704ac Remove extra whitespaces in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1205
diff changeset
    91
        'clean': cleaning.validate_new_group('link_id', 'scope_path',
1205
2e88261aba72 Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1154
diff changeset
    92
            soc.logic.models.organization, org_app_logic)}
2e88261aba72 Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1154
diff changeset
    93
2e88261aba72 Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1154
diff changeset
    94
    # get rid of the clean method
2e88261aba72 Added validate_new_group to cleaning and removed clean_new_club_link_id.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1154
diff changeset
    95
    new_params['edit_extra_dynafields'] = {
1221
0130e63704ac Remove extra whitespaces in soc.views.models.organization module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1205
diff changeset
    96
        'clean': (lambda x: x.cleaned_data)}
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
    params = dicts.merge(params, new_params)
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
    super(View, self).__init__(params=params)
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   102
    # create and store the special form for applicants
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   103
    updated_fields = {
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   104
        'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   105
            required=False),
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   106
        'clean_link_id': cleaning.clean_link_id('link_id')}
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   107
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   108
    applicant_create_form = dynaform.extendDynaForm(
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   109
        dynaform = self._params['create_form'],
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   110
        dynafields = updated_fields)
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   111
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   112
    params['applicant_create_form'] = applicant_create_form
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   113
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   114
1264
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   115
  def _getExtraMenuItems(self, role_description, params=None):
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   116
    """Used to create the specific Organization menu entries.
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   117
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   118
    For args see group.View._getExtraMenuItems().
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   119
    """
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   120
    submenus = []
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   121
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   122
    group_entity = role_description['group']
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   123
    roles = role_description['roles']
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   124
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   125
    if roles.get('org_admin'):
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   126
      # add a link to the management page
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   127
      submenu = (redirects.getListRolesRedirect(group_entity, params),
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   128
          "Manage Admins and Mentors", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   129
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   130
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   131
      # add a link to invite an org admin
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   132
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'org_admin'),
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   133
          "Invite an Org Admin", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   134
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   135
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   136
      # add a link to invite a member
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   137
      submenu = (redirects.getInviteRedirectForRole(group_entity, 'mentor'),
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   138
          "Invite a Mentor", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   139
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   140
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   141
      # add a link to the request page
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   142
      submenu = (redirects.getListRequestsRedirect(group_entity, params), 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   143
          "List Requests and Invites", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   144
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   145
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   146
      # add a link to the edit page
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   147
      submenu = (redirects.getEditRedirect(group_entity, params), 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   148
          "Edit Organization Profile", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   149
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   150
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   151
    if roles.get('org_admin') or roles.get('mentor'):
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   152
      submenu = (redirects.getCreateDocumentRedirect(group_entity, 'org'),
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   153
          "Create a New Document", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   154
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   155
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   156
    if roles.get('org_admin'):
1283
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   157
      # add a link to the resign page
1264
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   158
      submenu = (redirects.getManageRedirect(roles['org_admin'], 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   159
          {'url_name': 'org_admin'}), 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   160
          "Resign as Org Admin", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   161
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   162
1283
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   163
      # add a link to the edit page
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   164
      submenu = (redirects.getEditRedirect(roles['org_admin'],
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   165
          {'url_name': 'org_admin'}),
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   166
          "Edit My Org Admin Profile", 'any_access')
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   167
      submenus.append(submenu)
438dceed3132 Add ToS agreement to org_admin application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1266
diff changeset
   168
1264
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   169
    if roles.get('mentor'):
1284
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   170
      # add a link to the resign page
1264
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   171
      submenu = (redirects.getManageRedirect(roles['mentor'], 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   172
          {'url_name' : 'mentor'}), 
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   173
          "Resign as Mentor", 'any_access')
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   174
      submenus.append(submenu)
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   175
1284
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   176
      # add a link to the edit page
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   177
      submenu = (redirects.getEditRedirect(roles['mentor'],
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   178
          {'url_name': 'mentor'}),
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   179
          "Edit My Org Mentor Profile", 'any_access')
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   180
      submenus.append(submenu)
92f7a24d8f42 Add ToS agreement to mentor application related forms.
Sverre Rabbelier <srabbelier@gmail.com>
parents: 1283
diff changeset
   181
1264
4d46b09f3751 Added organization entity sidebar entries.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1221
diff changeset
   182
    return submenus
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
   183
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   184
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   185
view = View()
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   186
1154
77276e2c46f7 Implement the last step in the org application process.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1126
diff changeset
   187
applicant = view.applicant
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   188
create = view.create
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   189
delete = view.delete
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   190
edit = view.edit
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
   191
home = view.home
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   192
list = view.list
1126
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
   193
list_requests = view.listRequests
4fc86db70a76 Added organization view and templates.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1079
diff changeset
   194
list_roles = view.listRoles
682
187f4d95fedb Added organizations
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   195
public = view.public
858
e79e7a22326f Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents: 799
diff changeset
   196
export = view.export
934
9fcc08971efe Add a 'pick' view to the appropriate views
Sverre Rabbelier <srabbelier@gmail.com>
parents: 858
diff changeset
   197
pick = view.pick