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