app/soc/modules/soc_core/callback.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 12 Jul 2009 00:40:24 +0200
changeset 2605 8b017dad54cf
parent 2597 b003cd9b954c
child 2620 f8b735c73563
permissions -rw-r--r--
Removed several sidebar entries for Surveys which where not properly working.
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
2597
b003cd9b954c Added the Surveys Tasks to the registered URL patterns.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2586
diff changeset
    24
from soc.tasks import surveys as survey_tasks
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    25
from soc.views.models import club
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    26
from soc.views.models import club_app
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    27
from soc.views.models import club_admin
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    28
from soc.views.models import club_member
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    29
from soc.views.models import cron
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    30
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
    31
from soc.views.models import grading_project_survey as grading_survey
2586
283bb903b216 Added GradingSurveyGroup to the sitemap and sidebar.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2582
diff changeset
    32
from soc.views.models import grading_survey_group
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    33
from soc.views.models import host
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    34
from soc.views.models import job
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    35
from soc.views.models import mentor
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    36
from soc.views.models import notification
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    37
from soc.views.models import organization
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    38
from soc.views.models import org_admin
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    39
from soc.views.models import org_app
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    40
from soc.views.models import priority_group
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    41
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
    42
from soc.views.models import project_survey
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    43
from soc.views.models import request
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    44
from soc.views.models import site
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    45
from soc.views.models import sponsor
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    46
from soc.views.models import student
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    47
from soc.views.models import student_project
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    48
from soc.views.models import student_proposal
2436
cbcd87155630 Added Surveys to the sitemap.
Daniel Diniz <ajaksu@gmail.com>
parents: 2358
diff changeset
    49
from soc.views.models import survey
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    50
from soc.views.models import timeline
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    51
from soc.views.models import user
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    52
from soc.views.models import user_self
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    53
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    54
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    55
class Callback(object):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    56
  """Callback object that handles interaction between the core.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    57
  """
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
  API_VERSION = 1
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    60
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    61
  def __init__(self, core):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    62
    """Initializes a new Callback object for the specified core.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    63
    """
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
    self.core = core
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    66
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    67
    # disable clubs
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    68
    self.enable_clubs = False
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    69
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    70
  def registerWithSitemap(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    71
    """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
    72
    """
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
    self.core.requireUniqueService('registerWithSitemap')
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    75
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    76
    if self.enable_clubs:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    77
      self.core.registerSitemapEntry(club.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    78
      self.core.registerSitemapEntry(club_admin.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    79
      self.core.registerSitemapEntry(club_app.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    80
      self.core.registerSitemapEntry(club_member.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    81
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    82
    self.core.registerSitemapEntry(cron.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    83
    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
    84
    self.core.registerSitemapEntry(grading_survey.view.getDjangoURLPatterns())
2586
283bb903b216 Added GradingSurveyGroup to the sitemap and sidebar.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2582
diff changeset
    85
    self.core.registerSitemapEntry(grading_survey_group.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    86
    self.core.registerSitemapEntry(host.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    87
    self.core.registerSitemapEntry(job.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    88
    self.core.registerSitemapEntry(mentor.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    89
    self.core.registerSitemapEntry(notification.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    90
    self.core.registerSitemapEntry(organization.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    91
    self.core.registerSitemapEntry(org_admin.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    92
    self.core.registerSitemapEntry(org_app.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    93
    self.core.registerSitemapEntry(priority_group.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    94
    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
    95
    self.core.registerSitemapEntry(project_survey.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    96
    self.core.registerSitemapEntry(request.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    97
    self.core.registerSitemapEntry(site.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    98
    self.core.registerSitemapEntry(sponsor.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    99
    self.core.registerSitemapEntry(student.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   100
    self.core.registerSitemapEntry(student_project.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   101
    self.core.registerSitemapEntry(student_proposal.view.getDjangoURLPatterns())
2436
cbcd87155630 Added Surveys to the sitemap.
Daniel Diniz <ajaksu@gmail.com>
parents: 2358
diff changeset
   102
    self.core.registerSitemapEntry(survey.view.getDjangoURLPatterns())
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   103
    self.core.registerSitemapEntry(timeline.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   104
    self.core.registerSitemapEntry(user_self.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   105
    self.core.registerSitemapEntry(user.view.getDjangoURLPatterns())
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   106
2597
b003cd9b954c Added the Surveys Tasks to the registered URL patterns.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2586
diff changeset
   107
    # register task URL's
b003cd9b954c Added the Surveys Tasks to the registered URL patterns.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2586
diff changeset
   108
    self.core.registerSitemapEntry(survey_tasks.getDjangoURLPatterns())
b003cd9b954c Added the Surveys Tasks to the registered URL patterns.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2586
diff changeset
   109
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   110
  def registerWithSidebar(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   111
    """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
   112
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   113
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   114
    self.core.requireUniqueService('registerWithSidebar')
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   115
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   116
    if self.enable_clubs:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   117
      self.core.registerSidebarEntry(club.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   118
      self.core.registerSidebarEntry(club.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   119
      self.core.registerSidebarEntry(club_admin.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   120
      self.core.registerSidebarEntry(club_member.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   121
      self.core.registerSidebarEntry(club_app.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   122
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   123
    self.core.registerSidebarEntry(user_self.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   124
    self.core.registerSidebarEntry(site.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   125
    self.core.registerSidebarEntry(user.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   126
    self.core.registerSidebarEntry(sponsor.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   127
    self.core.registerSidebarEntry(sponsor.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   128
    self.core.registerSidebarEntry(host.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   129
    self.core.registerSidebarEntry(request.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   130
    self.core.registerSidebarEntry(program.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   131
    self.core.registerSidebarEntry(program.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   132
    self.core.registerSidebarEntry(student.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   133
    self.core.registerSidebarEntry(student_project.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   134
    self.core.registerSidebarEntry(student_proposal.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   135
    self.core.registerSidebarEntry(organization.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   136
    self.core.registerSidebarEntry(organization.view.getExtraMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   137
    self.core.registerSidebarEntry(org_admin.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   138
    self.core.registerSidebarEntry(mentor.view.getSidebarMenus)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   139
    self.core.registerSidebarEntry(org_app.view.getSidebarMenus)
2586
283bb903b216 Added GradingSurveyGroup to the sitemap and sidebar.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 2582
diff changeset
   140
    self.core.registerSidebarEntry(grading_survey_group.view.getSidebarMenus)