app/soc/modules/ghop/callback.py
author Lennard de Rijk <ljvderijk@gmail.com>
Wed, 09 Sep 2009 22:28:46 +0200
changeset 2896 5a3c5a2f567f
parent 2895 cad75f6ba411
child 2923 2d0b36ef4330
permissions -rw-r--r--
Moved enabling GHOP to settings.py.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     1
# Copyright 2009 the Melange authors.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Licensed under the Apache License, Version 2.0 (the "License");
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     4
# you may not use this file except in compliance with the License.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     5
# You may obtain a copy of the License at
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     6
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     7
# http://www.apache.org/licenses/LICENSE-2.0
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
     9
# Unless required by applicable law or agreed to in writing, software
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    10
# distributed under the License is distributed on an "AS IS" BASIS,
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    12
# See the License for the specific language governing permissions and
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    13
# limitations under the License.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    14
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    15
"""Module containing the GHOP Callback.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    16
"""
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    17
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    18
__authors__ = [
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    19
  '"Madhusudan C.S." <madhusudancs@gmail.com>',
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    20
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    21
  ]
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    22
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    23
from soc.modules.ghop.tasks import task_update
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    24
from soc.modules.ghop.views.models import mentor
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    25
from soc.modules.ghop.views.models import organization
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    26
from soc.modules.ghop.views.models import org_admin
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    27
from soc.modules.ghop.views.models import program
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    28
from soc.modules.ghop.views.models import task
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    29
from soc.modules.ghop.views.models import task_subscription
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    30
from soc.modules.ghop.views.models import timeline
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    31
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    32
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    33
class Callback(object):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    34
  """Callback object that handles interaction between the core.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    35
  """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    36
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    37
  API_VERSION = 1
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    38
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    39
  def __init__(self, core):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    40
    """Initializes a new Callback object for the specified core.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    41
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    42
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    43
    self.core = core
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    44
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    45
  def registerWithSitemap(self):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    46
    """Called by the server when sitemap entries should be registered.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    47
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    48
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    49
    self.core.requireUniqueService('registerWithSitemap')
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    50
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    51
    # register the GHOP Views
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    52
    self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    53
    self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    54
    self.core.registerSitemapEntry(org_admin.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    55
    self.core.registerSitemapEntry(program.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    56
    self.core.registerSitemapEntry(task.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    57
    self.core.registerSitemapEntry(task_subscription.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    58
    self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    59
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    60
    # register GHOP GAE Tasks URL's
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    61
    self.core.registerSitemapEntry(task_update.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    62
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    63
  def registerWithSidebar(self):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    64
    """Called by the server when sidebar entries should be registered.
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    65
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    66
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    67
    # require that we had the chance to register the urls we need with the sitemap
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    68
    self.core.requireUniqueService('registerWithSidebar')
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    69
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    70
    # register the GHOP menu entries
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    71
    self.core.registerSidebarEntry(mentor.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    72
    self.core.registerSidebarEntry(organization.view.getExtraMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    73
    self.core.registerSidebarEntry(organization.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    74
    self.core.registerSidebarEntry(org_admin.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    75
    self.core.registerSidebarEntry(program.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    76
    self.core.registerSidebarEntry(task.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    77
    self.core.registerSidebarEntry(task_subscription.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    78
    self.core.registerSidebarEntry(timeline.view.getSidebarMenus)