12 # distributed under the License is distributed on an "AS IS" BASIS, |
12 # distributed under the License is distributed on an "AS IS" BASIS, |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 # See the License for the specific language governing permissions and |
14 # See the License for the specific language governing permissions and |
15 # limitations under the License. |
15 # limitations under the License. |
16 |
16 |
17 """Views for Programs. |
17 """Views for Timeline. |
18 """ |
18 """ |
19 |
19 |
20 __authors__ = [ |
20 __authors__ = [ |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
22 ] |
23 ] |
23 |
24 |
24 |
25 |
|
26 from google.appengine.ext import db |
|
27 |
25 from django import forms |
28 from django import forms |
26 |
29 |
|
30 from gsoc.models import timeline |
27 from soc.logic import dicts |
31 from soc.logic import dicts |
28 from soc.logic.models import program as program_logic |
32 from soc.logic.models import program as program_logic |
29 from soc.views.helper import params as params_helper |
33 from soc.views.helper import params as params_helper |
30 from soc.views.models import base |
34 from soc.views.models import base |
31 |
35 |
44 params: a dict with params for this View |
48 params: a dict with params for this View |
45 """ |
49 """ |
46 |
50 |
47 new_params = {} |
51 new_params = {} |
48 new_params['logic'] = soc.logic.models.timeline.logic |
52 new_params['logic'] = soc.logic.models.timeline.logic |
49 |
53 new_params['edit_template'] = 'soc/timeline/edit.html' |
50 new_params['name'] = "Timeline" |
54 new_params['name'] = "Timeline" |
51 |
55 |
52 patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
56 patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
53 'soc.views.models.%(module_name)s.edit', "Edit %(name_short)s")] |
57 'soc.views.models.%(module_name)s.edit', |
|
58 "Edit %(name_short)s")] |
54 |
59 |
55 new_params['django_patterns_defaults'] = patterns |
60 new_params['django_patterns_defaults'] = patterns |
56 |
61 |
57 new_params['edit_dynafields']= [] |
62 new_params['edit_dynafields'] = [] |
|
63 |
|
64 timeline_properties = timeline.Timeline.properties() |
|
65 form_fields = {} |
|
66 |
|
67 # add class 'datetime-pick' for each DateTimeField |
|
68 # this is used with datetimepicker js widget |
|
69 for key, value in timeline_properties.iteritems(): |
|
70 if isinstance(value, db.DateTimeProperty): |
|
71 form_fields[key] = forms.DateTimeField(required=False, |
|
72 widget=forms.TextInput(attrs={'class':'datetime-pick'})) |
|
73 |
|
74 new_params['create_extra_dynafields'] = form_fields |
58 |
75 |
59 params = dicts.merge(params, new_params) |
76 params = dicts.merge(params, new_params) |
60 |
77 |
61 super(View, self).__init__(params=params) |
78 super(View, self).__init__(params=params) |
62 |
79 |