app/soc/modules/soc_core/callback.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 09 Jul 2009 23:50:21 +0200
changeset 2582 df5939fecaff
parent 2495 0113c2de89d3
child 2586 283bb903b216
permissions -rw-r--r--
Added Surveys to sidebar menu.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     1
# Copyright 2009 the Melange authors.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     2
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     3
# Licensed under the Apache License, Version 2.0 (the "License");
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     4
# you may not use this file except in compliance with the License.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     5
# You may obtain a copy of the License at
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     6
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     7
#     http://www.apache.org/licenses/LICENSE-2.0
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     8
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     9
# Unless required by applicable law or agreed to in writing, software
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    10
# distributed under the License is distributed on an "AS IS" BASIS,
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    12
# See the License for the specific language governing permissions and
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    13
# limitations under the License.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    14
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    15
"""Module containing the core callback.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    16
"""
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    17
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    18
__authors__ = [
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    19
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    20
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    21
  ]
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    22
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    23
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    24
from soc.views.models import club
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    25
from soc.views.models import club_app
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    26
from soc.views.models import club_admin
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    27
from soc.views.models import club_member
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    28
from soc.views.models import cron
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    29
from soc.views.models import document
2495
0113c2de89d3 Enable the ProjectSurvey and GradingProjectSurvey views in the core.
Daniel Diniz <ajaksu@gmail.com>
parents: 2436
diff changeset
    30
from soc.views.models import grading_project_survey as grading_survey
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    31
from soc.views.models import host
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    32
from soc.views.models import job
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    33
from soc.views.models import mentor
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    34
from soc.views.models import notification
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    35
from soc.views.models import organization
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    36
from soc.views.models import org_admin
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    37
from soc.views.models import org_app
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    38
from soc.views.models import priority_group
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    39
from soc.views.models import program
2495
0113c2de89d3 Enable the ProjectSurvey and GradingProjectSurvey views in the core.
Daniel Diniz <ajaksu@gmail.com>
parents: 2436
diff changeset
    40
from soc.views.models import project_survey
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    41
from soc.views.models import request
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    42
from soc.views.models import site
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    43
from soc.views.models import sponsor
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    44
from soc.views.models import student
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    45
from soc.views.models import student_project
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    46
from soc.views.models import student_proposal
2436
cbcd87155630 Added Surveys to the sitemap.
Daniel Diniz <ajaksu@gmail.com>
parents: 2358
diff changeset
    47
from soc.views.models import survey
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    48
from soc.views.models import timeline
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    49
from soc.views.models import user
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    50
from soc.views.models import user_self
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    51
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    52
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    53
class Callback(object):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    54
  """Callback object that handles interaction between the core.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    55
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    56
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    57
  API_VERSION = 1
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    58
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    59
  def __init__(self, core):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    60
    """Initializes a new Callback object for the specified core.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    61
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    62
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    63
    self.core = core
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    64
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    65
    # disable clubs
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    66
    self.enable_clubs = False
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    67
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    68
  def registerWithSitemap(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    69
    """Called by the server when sitemap entries should be registered.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    70
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    71
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    72
    self.core.requireUniqueService('registerWithSitemap')
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    73
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    74
    if self.enable_clubs:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    75
      self.core.registerSitemapEntry(club.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    76
      self.core.registerSitemapEntry(club_admin.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    77
      self.core.registerSitemapEntry(club_app.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    78
      self.core.registerSitemapEntry(club_member.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    79
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    80
    self.core.registerSitemapEntry(cron.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    81
    self.core.registerSitemapEntry(document.view.getDjangoURLPatterns())
2495
0113c2de89d3 Enable the ProjectSurvey and GradingProjectSurvey views in the core.
Daniel Diniz <ajaksu@gmail.com>
parents: 2436
diff changeset
    82
    self.core.registerSitemapEntry(grading_survey.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    83
    self.core.registerSitemapEntry(host.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    84
    self.core.registerSitemapEntry(job.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    85
    self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    86
    self.core.registerSitemapEntry(notification.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    87
    self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    88
    self.core.registerSitemapEntry(org_admin.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    89
    self.core.registerSitemapEntry(org_app.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    90
    self.core.registerSitemapEntry(priority_group.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    91
    self.core.registerSitemapEntry(program.view.getDjangoURLPatterns())
2495
0113c2de89d3 Enable the ProjectSurvey and GradingProjectSurvey views in the core.
Daniel Diniz <ajaksu@gmail.com>
parents: 2436
diff changeset
    92
    self.core.registerSitemapEntry(project_survey.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    93
    self.core.registerSitemapEntry(request.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    94
    self.core.registerSitemapEntry(site.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    95
    self.core.registerSitemapEntry(sponsor.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    96
    self.core.registerSitemapEntry(student.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    97
    self.core.registerSitemapEntry(student_project.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    98
    self.core.registerSitemapEntry(student_proposal.view.getDjangoURLPatterns())
2436
cbcd87155630 Added Surveys to the sitemap.
Daniel Diniz <ajaksu@gmail.com>
parents: 2358
diff changeset
    99
    self.core.registerSitemapEntry(survey.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   100
    self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   101
    self.core.registerSitemapEntry(user_self.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   102
    self.core.registerSitemapEntry(user.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   103
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   104
  def registerWithSidebar(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   105
    """Called by the server when sidebar entries should be registered.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   106
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   107
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   108
    self.core.requireUniqueService('registerWithSidebar')
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   109
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   110
    if self.enable_clubs:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   111
      self.core.registerSidebarEntry(club.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   112
      self.core.registerSidebarEntry(club.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   113
      self.core.registerSidebarEntry(club_admin.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   114
      self.core.registerSidebarEntry(club_member.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   115
      self.core.registerSidebarEntry(club_app.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   116
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   117
    self.core.registerSidebarEntry(user_self.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   118
    self.core.registerSidebarEntry(site.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   119
    self.core.registerSidebarEntry(user.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   120
    self.core.registerSidebarEntry(sponsor.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   121
    self.core.registerSidebarEntry(sponsor.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   122
    self.core.registerSidebarEntry(host.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   123
    self.core.registerSidebarEntry(request.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   124
    self.core.registerSidebarEntry(program.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   125
    self.core.registerSidebarEntry(program.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   126
    self.core.registerSidebarEntry(student.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   127
    self.core.registerSidebarEntry(student_project.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   128
    self.core.registerSidebarEntry(student_proposal.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   129
    self.core.registerSidebarEntry(organization.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   130
    self.core.registerSidebarEntry(organization.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   131
    self.core.registerSidebarEntry(org_admin.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   132
    self.core.registerSidebarEntry(mentor.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   133
    self.core.registerSidebarEntry(org_app.view.getSidebarMenus)
2582
df5939fecaff Added Surveys to sidebar menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2495
diff changeset
   134
    self.core.registerSidebarEntry(survey.view.getSidebarMenus)
df5939fecaff Added Surveys to sidebar menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2495
diff changeset
   135
    self.core.registerSidebarEntry(project_survey.view.getSidebarMenus)
df5939fecaff Added Surveys to sidebar menu.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2495
diff changeset
   136
    self.core.registerSidebarEntry(grading_survey.view.getSidebarMenus)