app/soc/views/models/grading_project_survey.py
changeset 2448 325e08ee9d25
child 2452 4abc27894b61
equal deleted inserted replaced
2447:dae6715a2f19 2448:325e08ee9d25
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2009 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """Views for GradingProjectSurveys.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21   '"Lennard de Rijk" <ljvderijk@gmail.com>',
       
    22   ]
       
    23 
       
    24 
       
    25 from soc.logic import dicts
       
    26 from soc.logic.models.survey import grading_logic as grading_survey_logic
       
    27 from soc.views.models import project_survey
       
    28 
       
    29 
       
    30 class View(project_survey.View):
       
    31   """View methods for the GradingProjectSurvey model.
       
    32   """
       
    33 
       
    34   def __init__(self, params=None):
       
    35     """Defines the fields and methods required for the base View class
       
    36     to provide the user with list, public, create, edit and delete views.
       
    37 
       
    38     Params:
       
    39       params: a dict with params for this View
       
    40     """
       
    41 
       
    42     rights = access.Checker(params)
       
    43     rights['any_access'] = ['allow']
       
    44     rights['show'] = [('checkIsSurveyReadable', grading_survey_logic)]
       
    45     rights['create'] = ['checkIsUser']
       
    46     rights['edit'] = [('checkIsSurveyWritable', grading_survey_logic)]
       
    47     rights['delete'] = [('checkIsSurveyWritable', grading_survey_logic)]
       
    48     rights['list'] = ['checkDocumentList']
       
    49     rights['pick'] = ['checkDocumentPick']
       
    50 
       
    51     new_params = {}
       
    52     new_params['logic'] = grading_survey_logic
       
    53     new_params['rights'] = rights
       
    54 
       
    55     new_params['name'] = "Grading Project Survey"
       
    56 
       
    57     params = dicts.merge(params, new_params)
       
    58 
       
    59     super(View, self).__init__(params=params)
       
    60 
       
    61 
       
    62 view = View()
       
    63 
       
    64 admin = decorators.view(view.admin)
       
    65 create = decorators.view(view.create)
       
    66 edit = decorators.view(view.edit)
       
    67 delete = decorators.view(view.delete)
       
    68 list = decorators.view(view.list)
       
    69 public = decorators.view(view.public)
       
    70 export = decorators.view(view.export)
       
    71 pick = decorators.view(view.pick)
       
    72 activate = decorators.view(view.activate)
       
    73 results = decorators.view(view.viewResults)
       
    74 json = decorators.view(view.exportSerialized)