app/soc/modules/ghop/callback.py
author Lennard de Rijk <ljvderijk@gmail.com>
Wed, 09 Sep 2009 21:14:22 +0200
changeset 2895 cad75f6ba411
parent 2787 8408741aee63
child 2896 5a3c5a2f567f
permissions -rw-r--r--
Added the GHOP modules to the callback. The ENABLE_MODULE has been added to ensure that the current build does not suffer from any weird artefacts that might occur due to the presence of this module. Of course in time it will be removed. Thanks Madhusudan for getting us this far ^_^. Minor CSS and image patches should follow shortly.
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
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    39
  # TODO: set this to True if you want to enable the GHOP module
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    40
  ENABLE_MODULE = False
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    41
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    42
  def __init__(self, core):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    43
    """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
    44
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    45
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    46
    self.core = core
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
  def registerWithSitemap(self):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    49
    """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
    50
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    51
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    52
    self.core.requireUniqueService('registerWithSitemap')
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    53
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    54
    if not self.ENABLE_MODULE:
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    55
      return
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    56
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    57
    # register the GHOP Views
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    58
    self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    59
    self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    60
    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
    61
    self.core.registerSitemapEntry(program.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    62
    self.core.registerSitemapEntry(task.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    63
    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
    64
    self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    65
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    66
    # register GHOP GAE Tasks URL's
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    67
    self.core.registerSitemapEntry(task_update.getDjangoURLPatterns())
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    68
2397
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    69
  def registerWithSidebar(self):
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    70
    """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
    71
    """
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    72
d943fa182fae Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff changeset
    73
    # 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
    74
    self.core.requireUniqueService('registerWithSidebar')
2895
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    75
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    76
    if not self.ENABLE_MODULE:
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    77
      return
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    78
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    79
    # register the GHOP menu entries
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    80
    self.core.registerSidebarEntry(mentor.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    81
    self.core.registerSidebarEntry(organization.view.getExtraMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    82
    self.core.registerSidebarEntry(organization.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    83
    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
    84
    self.core.registerSidebarEntry(program.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    85
    self.core.registerSidebarEntry(task.view.getSidebarMenus)
cad75f6ba411 Added the GHOP modules to the callback.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2787
diff changeset
    86
    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
    87
    self.core.registerSidebarEntry(timeline.view.getSidebarMenus)