app/soc/views/models/job.py
author Daniel Diniz <ajaksu@gmail.com>
Thu, 09 Jul 2009 10:39:30 +0200
changeset 2576 7a1138f8a0e2
parent 2212 4095892a3c99
permissions -rw-r--r--
Removed results list from Survey edit. Some changes to the Survey Result page have also been made, however the results viewer and the CSV export are not working properly in that View. Reviewd by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2209
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for Jobs.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
  ]
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
from django import forms
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from soc.logic import dicts
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
from soc.logic.models.job import logic as job_logic
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
from soc.views.helper import access
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
from soc.views.helper import decorators
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
from soc.views.helper import widgets
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.views.models import base
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
class View(base.View):
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
  """View methods for the Job model.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
  """
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
  def __init__(self, params=None):
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
    """Defines the fields and methods required for the base View class
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
    to provide the user with list, public, create, edit and delete views.
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
    Params:
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
      params: a dict with params for this View
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
    """
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
    rights = access.Checker(params)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
    new_params = {}
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
    new_params['rights'] = rights
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    new_params['logic'] = job_logic
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
    new_params['name'] = "Job"
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
    new_params['no_create_raw'] = True
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
    new_params['no_create_with_scope'] = True
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
    new_params['no_create_with_key_fields'] = True
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
    new_params['extra_dynaexclude'] = ['key_data', 'text_data']
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    new_params['edit_dynaproperties'] = {
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
      'task': forms.CharField(widget=widgets.PlainTextWidget()),
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
      }
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
    params = dicts.merge(params, new_params)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
    super(View, self).__init__(params=params)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
view = View()
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
delete = decorators.view(view.delete)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
edit = decorators.view(view.edit)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
list = decorators.view(view.list)
989c7c945d5f Add jobs (model, logic, and view)
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
public = decorators.view(view.public)