|
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 Jobs. |
|
18 """ |
|
19 |
|
20 __authors__ = [ |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 ] |
|
23 |
|
24 |
|
25 from django import forms |
|
26 |
|
27 from soc.logic import cleaning |
|
28 from soc.logic import dicts |
|
29 from soc.logic.models.job import logic as job_logic |
|
30 from soc.views.helper import access |
|
31 from soc.views.helper import decorators |
|
32 from soc.views.helper import dynaform |
|
33 from soc.views.helper import widgets |
|
34 from soc.views.models import base |
|
35 |
|
36 |
|
37 class View(base.View): |
|
38 """View methods for the Job model. |
|
39 """ |
|
40 |
|
41 def __init__(self, params=None): |
|
42 """Defines the fields and methods required for the base View class |
|
43 to provide the user with list, public, create, edit and delete views. |
|
44 |
|
45 Params: |
|
46 params: a dict with params for this View |
|
47 """ |
|
48 |
|
49 rights = access.Checker(params) |
|
50 |
|
51 new_params = {} |
|
52 new_params['rights'] = rights |
|
53 new_params['logic'] = job_logic |
|
54 |
|
55 new_params['name'] = "Job" |
|
56 |
|
57 new_params['no_create_raw'] = True |
|
58 new_params['no_create_with_scope'] = True |
|
59 new_params['no_create_with_key_fields'] = True |
|
60 |
|
61 new_params['extra_dynaexclude'] = ['key_data', 'text_data'] |
|
62 |
|
63 new_params['edit_dynaproperties'] = { |
|
64 'task': forms.CharField(widget=widgets.PlainTextWidget()), |
|
65 } |
|
66 |
|
67 params = dicts.merge(params, new_params) |
|
68 |
|
69 super(View, self).__init__(params=params) |
|
70 |
|
71 |
|
72 view = View() |
|
73 |
|
74 delete = decorators.view(view.delete) |
|
75 edit = decorators.view(view.edit) |
|
76 list = decorators.view(view.list) |
|
77 public = decorators.view(view.public) |