app/soc/modules/gsoc/callback.py
author Mario Ferraro <fadinlight@gmail.com>
Sun, 15 Nov 2009 22:12:20 +0100
changeset 3093 d1be59b6b627
parent 3043 187c1709756b
permissions -rw-r--r--
GMaps related JS changed to use new google namespace. Google is going to change permanently in the future the way to load its services, so better stay safe. Also this commit shows uses of the new melange.js module. Fixes Issue 634.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3043
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
# Copyright 2009 the Melange authors.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Licensed under the Apache License, Version 2.0 (the "License");
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
# you may not use this file except in compliance with the License.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# You may obtain a copy of the License at
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
#
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# http://www.apache.org/licenses/LICENSE-2.0
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
# Unless required by applicable law or agreed to in writing, software
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
# distributed under the License is distributed on an "AS IS" BASIS,
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# See the License for the specific language governing permissions and
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# limitations under the License.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
"""Module containing the GSoC Callback.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
"""
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
__authors__ = [
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
  ]
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
from soc.modules.gsoc.views.models import mentor
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
from soc.modules.gsoc.views.models import org_admin
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
from soc.modules.gsoc.views.models import organization
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
from soc.modules.gsoc.views.models import program
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
from soc.modules.gsoc.views.models import student
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from soc.modules.gsoc.views.models import timeline
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
class Callback(object):
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
  """Callback object that handles interaction between the core.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
  """
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
  API_VERSION = 1
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
  def __init__(self, core):
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
    """Initializes a new Callback object for the specified core.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
    """
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
    self.core = core
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
  def registerWithSitemap(self):
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
    """Called by the server when sitemap entries should be registered.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
    """
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
    self.core.requireUniqueService('registerWithSitemap')
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
    # register the GSoC Views
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
    self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    self.core.registerSitemapEntry(org_admin.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    self.core.registerSitemapEntry(program.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
    self.core.registerSitemapEntry(student.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
  def registerWithSidebar(self):
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
    """Called by the server when sidebar entries should be registered.
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
    """
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
    # require that we had the chance to register the urls we need with the sitemap
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    self.core.requireUniqueService('registerWithSidebar')
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
    # register the GHOP menu entries
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
    self.core.registerSidebarEntry(mentor.view.getSidebarMenus)
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
    self.core.registerSidebarEntry(org_admin.view.getSidebarMenus)
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
    self.core.registerSidebarEntry(organization.view.getSidebarMenus)
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
    self.core.registerSidebarEntry(program.view.getSidebarMenus)
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
    self.core.registerSidebarEntry(student.view.getSidebarMenus)
187c1709756b GSoC Views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    self.core.registerSidebarEntry(timeline.view.getSidebarMenus)