app/soc/modules/ghop/views/models/program.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Thu, 17 Sep 2009 12:50:14 +0530
changeset 2935 0b8b82b6764e
parent 2891 aba681d72b0a
child 2940 ef809d10aaf1
permissions -rw-r--r--
Removed slots and apps_tasks_limit from extra_dynaexclude in params and added a getExtraMenus entry to callback for program. Reviewed by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2891
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
#
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
#
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
#
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
#
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
"""GHOP specific views for Programs.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
"""
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
__authors__ = [
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
    '"Madhusudan.C.S" <madhusudancs@gmail.com>',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
    '"Lennard de Rijk" <ljvderijk@gmail.com>',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
  ]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
import datetime
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
import os
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
from django import forms
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
from django import http
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
from django.utils.translation import ugettext
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
from soc.logic import cleaning
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
from soc.logic import dicts
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
from soc.logic.helper import timeline as timeline_helper
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
from soc.logic.models import host as host_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
from soc.views import out_of_band
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
from soc.views import helper
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
from soc.views.helper import decorators
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
from soc.views.helper import dynaform
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
from soc.views.helper import lists
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
from soc.views.helper import params as params_helper
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    43
from soc.views.helper import redirects
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
from soc.views.helper import widgets
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
from soc.views.models import document as document_view
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
from soc.views.models import program 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
from soc.views.sitemap import sidebar
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    49
import soc.cache.logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    50
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
from soc.modules.ghop.logic.models import program as ghop_program_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
from soc.modules.ghop.logic.models import student as ghop_student_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
from soc.modules.ghop.logic.models import task as ghop_task_logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
from soc.modules.ghop.models import task as ghop_task_model
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
from soc.modules.ghop.views.helper import access as ghop_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
from soc.modules.ghop.views.helper import redirects as ghop_redirects
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
import soc.modules.ghop.logic.models.program
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    62
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    63
class View(program.View):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    64
  """View methods for the GHOP Program model.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    65
  """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    67
  DEF_PARTICIPATING_ORGS_MSG_FMT = ugettext(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    68
      'The following is a list of all the participating organizations under '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    69
      'the programme %(name)s. To know more about each organization and see '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    70
      'the tasks published by them please visit the corresponding links.')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    71
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    72
  DEF_TASK_QUOTA_ALLOCATION_MSG = ugettext(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    73
      "Use this view to assign task quotas.")
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    74
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    75
  DEF_TASK_QUOTA_ERROR_MSG_FMT = ugettext(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    76
      "Task Quota limit for the organizations %s do not contain"
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    77
      " a valid number(>0) and has not been updated.")
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    78
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    79
  def __init__(self, params=None):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    80
    """Defines the fields and methods required for the program View class
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    81
    to provide the user with list, public, create, edit and delete views.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    82
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    83
    Params:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    84
      params: a dict with params for this View
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    85
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    86
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    87
    rights = ghop_access.GHOPChecker(params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    88
    rights['show'] = ['allow']
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    89
    rights['create'] = [('checkSeeded', ['checkHasActiveRoleForScope',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    90
                                         host_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    91
    rights['edit'] = [('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    92
                       [ghop_program_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    93
    rights['delete'] = ['checkIsDeveloper']
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    94
    rights['task_difficulty'] = [('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    95
                                  [ghop_program_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    96
    rights['task_type'] = [('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    97
                            [ghop_program_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    98
    rights['difficulty_tag_edit'] = [('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    99
                                      [ghop_program_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   100
    rights['type_tag_edit'] = [('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   101
                                [ghop_program_logic.logic])]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   102
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   103
    new_params = {}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   104
    new_params['logic'] = soc.modules.ghop.logic.models.program.logic
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   105
    new_params['rights'] = rights
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   106
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   107
    new_params['name'] = "GHOP Program"
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   108
    new_params['module_name'] = "program"
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   109
    new_params['sidebar_grouping'] = 'Programs'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   110
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   111
    new_params['module_package'] = 'soc.modules.ghop.views.models'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   112
    new_params['url_name'] = 'ghop/program'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   113
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   114
    # TODO: this list can be reduced after GSoC has been moved
2935
0b8b82b6764e Removed slots and apps_tasks_limit from extra_dynaexclude in params and added a getExtraMenus entry to callback for program.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2891
diff changeset
   115
    new_params['extra_dynaexclude'] = ['min_slots', 'max_slots',
0b8b82b6764e Removed slots and apps_tasks_limit from extra_dynaexclude in params and added a getExtraMenus entry to callback for program.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 2891
diff changeset
   116
                                       'slot_allocation', 'allocations_visible',
2891
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   117
                                       'task_difficulties', 'task_types',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   118
                                       ]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   119
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   120
    patterns = []
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   121
    patterns += [
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   122
        (r'^%(url_name)s/(?P<access_type>assign_task_quotas)/%(key_fields)s$',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   123
          '%(module_package)s.%(module_name)s.assign_task_quotas',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   124
          'Assign task quota limits'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   125
        (r'^%(url_name)s/(?P<access_type>task_difficulty)/%(key_fields)s$',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   126
         '%(module_package)s.%(module_name)s.task_difficulty_edit',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   127
         'Edit Task Difficulty Tags'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   128
        (r'^%(url_name)s/(?P<access_type>task_type)/%(key_fields)s$',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   129
         '%(module_package)s.%(module_name)s.task_type_edit',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   130
         'Edit Task Type Tags'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   131
        (r'^%(url_name)s/(?P<access_type>difficulty_tag_edit)$',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   132
         '%(module_package)s.%(module_name)s.difficulty_tag_edit',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   133
         'Edit a Difficulty Tag'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   134
        (r'^%(url_name)s/(?P<access_type>type_tag_edit)$',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   135
         '%(module_package)s.%(module_name)s.task_type_tag_edit',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   136
         'Edit a Task Type Tag'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   137
        ]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   138
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   139
    new_params['extra_django_patterns'] = patterns
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   140
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   141
    params = dicts.merge(params, new_params, sub_merge=True)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   142
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   143
    super(View, self).__init__(params=params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   144
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   145
    dynafields = [
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   146
        {'name': 'task_difficulties',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   147
         'base': forms.CharField,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   148
         'label': 'Task Difficulty Levels',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   149
         'widget': widgets.ReadOnlyInput(),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   150
         'required': False,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   151
         'help_text': ugettext('Lists all the difficulty levels that '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   152
                               'can be assigned to a task. Edit them '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   153
                               'from the Program menu on sidebar.'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   154
         },
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   155
         {'name': 'task_types',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   156
         'base': forms.CharField,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   157
         'label': 'Task Type Tags',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   158
         'widget': widgets.ReadOnlyInput(),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   159
         'required': False,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   160
         'help_text': ugettext('Lists all the types a task can be in. '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   161
                               'Edit them from the Program menu on sidebar.'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   162
         },
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   163
        ]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   164
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   165
    dynaproperties = params_helper.getDynaFields(dynafields)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   166
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   167
    edit_form = dynaform.extendDynaForm(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   168
        dynaform=self._params['edit_form'],
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   169
        dynaproperties=dynaproperties)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   170
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   171
    self._params['edit_form'] = edit_form
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   172
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   173
  def _editGet(self, request, entity, form):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   174
    """See base.View._editGet().
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   175
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   176
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   177
    # TODO: can't a simple join operation do this?
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   178
    tds = ghop_task_model.TaskDifficultyTag.get_by_scope(entity)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   179
    if tds:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   180
      td_str = ''
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   181
      for td in tds[:-1]:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   182
        td_str += str(td) + ', '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   183
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   184
      td_str += str(tds[-1])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   185
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   186
      form.fields['task_difficulties'].initial = td_str
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   187
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   188
    tts = ghop_task_model.TaskTypeTag.get_by_scope(entity)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   189
    if tts:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   190
      tt_str = ''
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   191
      for tt in tts[:-1]:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   192
        tt_str += str(tt) + ', '
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   193
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   194
      tt_str += str(tts[-1])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   195
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   196
      form.fields['task_types'].initial = tt_str
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   197
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   198
    return super(View, self)._editGet(request, entity, form)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   199
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   200
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   201
  @decorators.check_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   202
  def assignTaskQuotas(self, request, access_type, page_name=None,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   203
                       params=None, filter=None, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   204
    """View that allows to assign task quotas for accepted GHOP organization.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   205
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   206
    This view allows the program admin to set the task quota limits
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   207
    and change them at any time when the program is active. 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   208
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   209
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   210
    # TODO: Once GAE Task APIs arrive, this view will be managed by them
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   211
    program = ghop_program_logic.logic.getFromKeyFieldsOr404(kwargs)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   212
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   213
    from soc.modules.ghop.views.models import \
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   214
        organization as ghop_organization_view
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   215
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   216
    org_params = ghop_organization_view.view.getParams().copy()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   217
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   218
    context = {}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   219
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   220
    if request.method == 'POST':
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   221
      return self.assignTaskQuotasPost(request, context, org_params, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   222
                                       page_name, params, program,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   223
                                       **kwargs)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   224
    else: # request.method == 'GET'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   225
      return self.assignTaskQuotasGet(request, context, org_params,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   226
                                      page_name, params, program, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   227
                                      **kwargs)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   228
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   229
  def assignTaskQuotasPost(self, request, context, org_params, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   230
                           page_name, params, entity, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   231
    """Handles the POST request for the task quota allocation page.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   232
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   233
    Args:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   234
        entity: the program entity
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   235
        rest: see base.View.public()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   236
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   237
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   238
    ghop_org_logic = org_params['logic']
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   239
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   240
    error_orgs = ''
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   241
    for link_id, task_count in request.POST.items():
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   242
      fields = {
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   243
          'link_id': link_id,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   244
          'scope': entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   245
          'scope_path': entity.key().id_or_name(),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   246
          }
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   247
      key_name = ghop_org_logic.getKeyNameFromFields(fields)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   248
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   249
      try:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   250
        task_count = int(task_count)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   251
        if task_count >= 0:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   252
          fields['task_quota_limit'] = task_count
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   253
          ghop_org_logic.updateOrCreateFromKeyName(fields, key_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   254
        else:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   255
          raise ValueError
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   256
      except ValueError:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   257
        org_entity = ghop_org_logic.getFromKeyName(key_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   258
        error_orgs += org_entity.name + ', ' 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   259
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   260
    if error_orgs:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   261
      context['error_message'] = self.DEF_TASK_QUOTA_ERROR_MSG_FMT % (
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   262
          error_orgs[:-2])    
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   263
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   264
      return self.assignTaskQuotasGet(request, context, org_params,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   265
                                      page_name, params, entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   266
                                      **kwargs) 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   267
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   268
    # redirect to the same page
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   269
    return http.HttpResponseRedirect('')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   270
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   271
  def assignTaskQuotasGet(self, request, context, org_params, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   272
                          page_name, params, entity, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   273
    """Handles the GET request for the task quota allocation page.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   274
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   275
    Args:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   276
        entity: the program entity
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   277
        rest see base.View.public()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   278
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   279
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   280
    org_params['list_template'] = ('modules/ghop/program/'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   281
        'allocation/allocation.html')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   282
    org_params['list_heading'] = ('modules/ghop/program/'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   283
        'allocation/heading.html')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   284
    org_params['list_row'] = 'modules/ghop/program/allocation/row.html'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   285
    org_params['list_pagination'] = 'soc/list/no_pagination.html'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   286
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   287
    description = self.DEF_TASK_QUOTA_ALLOCATION_MSG
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   288
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   289
    filter = {
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   290
        'scope': entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   291
        'status': 'active',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   292
        }
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   293
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   294
    content = self._getAcceptedOrgsList(description, org_params,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   295
                                        filter, False)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   296
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   297
    contents = [content]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   298
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   299
    return self._list(request, org_params, contents, page_name, context)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   300
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   301
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   302
  def getExtraMenus(self, id, user, params=None):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   303
    """See soc.views.models.program.View.getExtraMenus().
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   304
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   305
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   306
    logic = params['logic']
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   307
    rights = params['rights']
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   308
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   309
    # only get all invisible and visible programs
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   310
    fields = {'status': ['invisible', 'visible']}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   311
    entities = logic.getForFields(fields)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   312
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   313
    menus = []
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   314
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   315
    rights.setCurrentUser(id, user)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   316
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   317
    for entity in entities:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   318
      items = []
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   319
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   320
      if entity.status == 'visible':
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   321
        # show the documents for this program, even for not logged in users
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   322
        items += document_view.view.getMenusForScope(entity, params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   323
        items += self._getTimeDependentEntries(entity, params, id, user)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   324
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   325
      try:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   326
        # check if the current user is a host for this program
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   327
        rights.doCachedCheck('checkIsHostForProgram',
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   328
                             {'scope_path': entity.scope_path,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   329
                              'link_id': entity.link_id}, [])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   330
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   331
        if entity.status == 'invisible':
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   332
          # still add the document links so hosts can see how it looks like
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   333
          items += document_view.view.getMenusForScope(entity, params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   334
          items += self._getTimeDependentEntries(entity, params, id, user)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   335
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   336
        items += [(redirects.getReviewOverviewRedirect(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   337
            entity, {'url_name': 'ghop/org_app', 'scope_view': self}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   338
            "Review Organization Applications", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   339
        # add link to edit Program Profile
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   340
        items += [(redirects.getEditRedirect(entity, params),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   341
            'Edit Program Profile', 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   342
        # add link to Assign Task Quota limits
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   343
        items += [(ghop_redirects.getAssignTaskQuotasRedirect(entity, params),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   344
            'Assign Task Quota limits', 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   345
        # add link to edit Program Timeline
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   346
        items += [(redirects.getEditRedirect(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   347
            entity, {'url_name': 'ghop/timeline'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   348
            "Edit Program Timeline", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   349
        # add link to create a new Program Document
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   350
        items += [(redirects.getCreateDocumentRedirect(entity, 'ghop/program'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   351
            "Create a New Document", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   352
        # add link to list all Program Document
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   353
        items += [(redirects.getListDocumentsRedirect(entity, 'ghop/program'),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   354
            "List Documents", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   355
        # add link to edit Task Difficulty Levels
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   356
        items += [(ghop_redirects.getDifficultyEditRedirect(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   357
            entity, {'url_name': 'ghop/program'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   358
            "Edit Task Difficulty Levels", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   359
        # add link to edit Task Type Tags
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   360
        items += [(ghop_redirects.getTaskTypeEditRedirect(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   361
            entity, {'url_name': 'ghop/program'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   362
            "Edit Task Type Tags", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   363
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   364
      except out_of_band.Error:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   365
        pass
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   366
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   367
      items = sidebar.getSidebarMenu(id, user, items, params=params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   368
      if not items:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   369
        continue
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   370
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   371
      menu = {}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   372
      menu['heading'] = entity.short_name
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   373
      menu['items'] = items
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   374
      menu['group'] = 'Programs'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   375
      menus.append(menu)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   376
    
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   377
    return menus
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   378
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   379
  def _getTimeDependentEntries(self, ghop_program_entity, params, id, user):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   380
    """Returns a list with time dependent menu items.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   381
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   382
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   383
    items = []
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   384
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   385
    timeline_entity = ghop_program_entity.timeline
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   386
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   387
    # get the student entity for this user and program
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   388
    filter = {'user': user,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   389
              'scope': ghop_program_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   390
              'status': 'active'}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   391
    student_entity = ghop_student_logic.logic.getForFields(filter, unique=True)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   392
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   393
    if student_entity:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   394
      items += self._getStudentEntries(ghop_program_entity, student_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   395
                                       params, id, user)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   396
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   397
    # get mentor and org_admin entity for this user and program
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   398
    filter = {'user': user,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   399
              'program': ghop_program_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   400
              'status': 'active'}
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   401
    mentor_entity = ghop_mentor_logic.logic.getForFields(filter, unique=True)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   402
    org_admin_entity = ghop_org_admin_logic.logic.getForFields(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   403
        filter, unique=True)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   404
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   405
    if mentor_entity or org_admin_entity:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   406
      items += self._getOrganizationEntries(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   407
          ghop_program_entity, org_admin_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   408
          mentor_entity, params, id, user)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   409
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   410
    if user and not (student_entity or mentor_entity or org_admin_entity):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   411
      if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   412
        # this user does not have a role yet for this program
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   413
        items += [('/ghop/student/apply/%s' % (
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   414
            ghop_program_entity.key().id_or_name()),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   415
            "Register as a Student", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   416
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   417
    if timeline_helper.isAfterEvent(timeline_entity, 'org_signup_start'):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   418
      url = ghop_redirects.getParticipatingOrgsRedirect(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   419
          ghop_program_entity, params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   420
      # add a link to list all the organizations
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   421
      items += [(url, "List participating Organizations", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   422
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   423
    return items
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   424
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   425
  def _getStudentEntries(self, ghop_program_entity, student_entity, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   426
                         params, id, user):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   427
    """Returns a list with menu items for students in a specific program.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   428
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   429
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   430
    items = []
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   431
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   432
    timeline_entity = ghop_program_entity.timeline
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   433
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   434
    if timeline_helper.isAfterEvent(timeline_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   435
                                   'student_signup_start'):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   436
      # add a link to show all projects
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   437
      items += [(redirects.getListProjectsRedirect(ghop_program_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   438
          {'url_name':'ghop/task'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   439
          "List my Tasks", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   440
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   441
    items += [(redirects.getEditRedirect(student_entity, 
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   442
        {'url_name': 'ghop/student'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   443
        "Edit my Student Profile", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   444
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   445
    items += [(redirects.getManageRedirect(student_entity,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   446
        {'url_name':'ghop/student'}),
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   447
        "Resign as a Student", 'any_access')]
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   448
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   449
    return items
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   450
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   451
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   452
  @decorators.check_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   453
  def taskDifficultyEdit(self, request, access_type, page_name=None,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   454
                         params=None, filter=None, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   455
    """View method used to edit Difficulty Level tags.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   456
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   457
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   458
    params = dicts.merge(params, self._params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   459
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   460
    try:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   461
      entity = self._logic.getFromKeyFieldsOr404(kwargs)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   462
    except out_of_band.Error, error:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   463
      return helper.responses.errorResponse(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   464
          error, request, template=params['error_public'])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   465
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   466
    context = helper.responses.getUniversalContext(request)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   467
    helper.responses.useJavaScript(context, params['js_uses_all'])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   468
    context['page_name'] = page_name
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   469
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   470
    context['program_key_name'] = entity.key().name()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   471
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   472
    context['difficulties'] = ghop_task_model.TaskDifficultyTag.get_by_scope(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   473
        entity)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   474
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   475
    params['edit_template'] = 'modules/ghop/program/tag/difficulty.html'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   476
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   477
    return self._constructResponse(request, entity, context, None, params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   478
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   479
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   480
  @decorators.check_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   481
  def difficultyTagEdit(self, request, access_type, page_name=None,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   482
                        params=None, filter=None, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   483
    """View method used to edit a supplied Difficulty level tag.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   484
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   485
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   486
    get_params = request.GET
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   487
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   488
    order = get_params.getlist('order')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   489
    program_key_name = get_params.get('program_key_name')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   490
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   491
    program_entity = ghop_program_logic.logic.getFromKeyName(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   492
        program_key_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   493
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   494
    if order:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   495
      for index, elem in enumerate(order):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   496
        ghop_task_model.TaskDifficultyTag.update_order(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   497
              program_entity, elem, index)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   498
      return http.HttpResponse()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   499
    else:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   500
      tag_data = get_params.getlist('tag_data')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   501
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   502
      tag_name = tag_data[0].strip()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   503
      tag_value = tag_data[1].strip()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   504
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   505
      if tag_name:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   506
        if not tag_value:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   507
          ghop_task_model.TaskDifficultyTag.delete_tag(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   508
              program_entity, tag_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   509
        elif tag_name != tag_value:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   510
          ghop_task_model.TaskDifficultyTag.copy_tag(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   511
              program_entity, tag_name, tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   512
      else:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   513
        ghop_task_model.TaskDifficultyTag.get_or_create(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   514
            program_entity, tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   515
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   516
      return http.HttpResponse(tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   517
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   518
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   519
  @decorators.check_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   520
  def taskTypeEdit(self, request, access_type, page_name=None,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   521
                   params=None, filter=None, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   522
    """View method used to edit Task Type tags.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   523
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   524
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   525
    params = dicts.merge(params, self._params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   526
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   527
    try:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   528
      entity = self._logic.getFromKeyFieldsOr404(kwargs)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   529
    except out_of_band.Error, error:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   530
      return helper.responses.errorResponse(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   531
          error, request, template=params['error_public'])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   532
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   533
    context = helper.responses.getUniversalContext(request)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   534
    helper.responses.useJavaScript(context, params['js_uses_all'])
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   535
    context['page_name'] = page_name
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   536
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   537
    context['program_key_name'] = entity.key().name()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   538
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   539
    context['task_types'] = ghop_task_model.TaskTypeTag.get_by_scope(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   540
        entity)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   541
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   542
    params['edit_template'] = 'modules/ghop/program/tag/task_type.html'
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   543
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   544
    return self._constructResponse(request, entity, context, None, params)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   545
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   546
  @decorators.merge_params
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   547
  @decorators.check_access
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   548
  def taskTypeTagEdit(self, request, access_type, page_name=None,
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   549
                      params=None, filter=None, **kwargs):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   550
    """View method used to edit a supplied Task Type tag.
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   551
    """
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   552
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   553
    get_params = request.GET
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   554
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   555
    order = get_params.getlist('order')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   556
    program_key_name = get_params.get('program_key_name')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   557
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   558
    program_entity = ghop_program_logic.logic.getFromKeyName(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   559
        program_key_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   560
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   561
    if order:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   562
      for index, elem in enumerate(order):
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   563
        ghop_task_model.TaskTypeTag.update_order(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   564
              program_entity, elem, index)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   565
      return http.HttpResponse()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   566
    else:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   567
      tag_data = get_params.getlist('tag_data')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   568
      program_key_name = get_params.get('program_key_name')
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   569
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   570
      tag_name = tag_data[0].strip()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   571
      tag_value = tag_data[1].strip()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   572
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   573
      program_entity = ghop_program_logic.logic.getFromKeyName(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   574
          program_key_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   575
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   576
      if tag_name:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   577
        if not tag_value:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   578
          ghop_task_model.TaskTypeTag.delete_tag(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   579
              program_entity, tag_name)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   580
        elif tag_name != tag_value:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   581
          ghop_task_model.TaskTypeTag.copy_tag(
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   582
              program_entity, tag_name, tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   583
      else:
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   584
        ghop_task_model.TaskTypeTag.get_or_create(program_entity, tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   585
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   586
      return http.HttpResponse(tag_value)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   587
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   588
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   589
view = View()
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   590
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   591
admin = decorators.view(view.admin)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   592
assign_task_quotas = decorators.view(view.assignTaskQuotas)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   593
create = decorators.view(view.create)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   594
delete = decorators.view(view.delete)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   595
edit = decorators.view(view.edit)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   596
list = decorators.view(view.list)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   597
public = decorators.view(view.public)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   598
export = decorators.view(view.export)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   599
home = decorators.view(view.home)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   600
difficulty_tag_edit = decorators.view(view.difficultyTagEdit)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   601
task_type_tag_edit = decorators.view(view.taskTypeTagEdit)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   602
task_difficulty_edit = decorators.view(view.taskDifficultyEdit)
aba681d72b0a Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   603
task_type_edit = decorators.view(view.taskTypeEdit)