author | Sverre Rabbelier <srabbelier@gmail.com> |
Wed, 07 Jan 2009 21:57:12 +0000 | |
changeset 776 | f86a76f52bf4 |
parent 768 | 002d3141ff99 |
child 778 | bc13cd968946 |
permissions | -rw-r--r-- |
768
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Programs. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
from django import forms |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
from soc.logic import dicts |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
from soc.views.models import base |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
import soc.logic.models.timeline |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
class View(base.View): |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
"""View methods for the Timeline model. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
""" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
def __init__(self, params=None): |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
"""Defines the fields and methods required for the base View class |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
to provide the user with list, public, create, edit and delete views. |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
Params: |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
params: a dict with params for this View |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
""" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
new_params = {} |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
new_params['logic'] = soc.logic.models.timeline.logic |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
new_params['name'] = "Timeline" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
new_params['name_short'] = "Timeline" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
new_params['name_plural'] = "Timelines" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
new_params['url_name'] = "timeline" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
new_params['module_name'] = "timeline" |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
|
776
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
54 |
patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
55 |
'soc.views.models.%(module_name)s.edit', "Edit %(name_short)s")] |
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
56 |
|
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
57 |
new_params['django_patterns_defaults'] = patterns |
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
58 |
|
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
59 |
new_params['edit_dynafields']= [] |
f86a76f52bf4
Started on edit timeline
Sverre Rabbelier <srabbelier@gmail.com>
parents:
768
diff
changeset
|
60 |
|
768
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
params = dicts.merge(params, new_params) |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
super(View, self).__init__(params=params) |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
view = View() |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
|
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
create = view.create |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
delete = view.delete |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
edit = view.edit |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
list = view.list |
002d3141ff99
Added logic and view classes for the Timeline model
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
public = view.public |