Add calendar widget support for timeline fields. Fix docstring typo in soc.views.models.timeline module. Add timeline edit template which loads necessary javascript files for datetimepicker widget.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Tue, 20 Jan 2009 20:52:12 +0000
changeset 847 b1077116fe59
parent 846 65daaf006399
child 848 07fd6a603c24
Add calendar widget support for timeline fields. Fix docstring typo in soc.views.models.timeline module. Add timeline edit template which loads necessary javascript files for datetimepicker widget. Patch by: Pawel Solyga Review by: to-be-reviewed
app/soc/templates/soc/timeline/edit.html
app/soc/views/models/timeline.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/timeline/edit.html	Tue Jan 20 20:52:12 2009 +0000
@@ -0,0 +1,33 @@
+{% extends "soc/models/edit.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% block scripts %}
+<script type="text/javascript" src="/jquery/jquery-ui.core.js"></script>
+<script type="text/javascript" src="/jquery/jquery-ui.datetimepicker.js"></script>
+<link rel="stylesheet" type="text/css" media="screen" href="/soc/content/css/ui.datetimepicker.css">
+<script type="text/javascript" charset="utf-8">
+    $(function()
+    {
+		$('.datetime-pick').datetimepicker();
+    });
+</script>
+{% endblock %}
+{% block submit_buttons %}
+<td> 
+ <input style="font-weight: bold" type="submit" value="Save Changes"/></span>
+</td>
+<td>
+ <input type="button" onclick="location.href='/'" value="Cancel"/>
+</td>
+{% endblock %}
\ No newline at end of file
--- a/app/soc/views/models/timeline.py	Tue Jan 20 20:49:49 2009 +0000
+++ b/app/soc/views/models/timeline.py	Tue Jan 20 20:52:12 2009 +0000
@@ -14,16 +14,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""Views for Programs.
+"""Views for Timeline.
 """
 
 __authors__ = [
     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
+    '"Pawel Solyga" <pawel.solyga@gmail.com>',
   ]
 
 
+from google.appengine.ext import db
+
 from django import forms
 
+from gsoc.models import timeline
 from soc.logic import dicts
 from soc.logic.models import program as program_logic
 from soc.views.helper import params as params_helper
@@ -46,15 +50,28 @@
 
     new_params = {}
     new_params['logic'] = soc.logic.models.timeline.logic
-
+    new_params['edit_template'] = 'soc/timeline/edit.html'
     new_params['name'] = "Timeline"
 
     patterns = [(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$',
-                  'soc.views.models.%(module_name)s.edit', "Edit %(name_short)s")]
+                  'soc.views.models.%(module_name)s.edit', 
+                  "Edit %(name_short)s")]
 
     new_params['django_patterns_defaults'] = patterns
 
-    new_params['edit_dynafields']= []
+    new_params['edit_dynafields'] = []
+
+    timeline_properties = timeline.Timeline.properties()
+    form_fields = {}
+    
+    # add class 'datetime-pick' for each DateTimeField
+    # this is used with datetimepicker js widget
+    for key, value in timeline_properties.iteritems():
+      if isinstance(value, db.DateTimeProperty):
+        form_fields[key] = forms.DateTimeField(required=False,
+          widget=forms.TextInput(attrs={'class':'datetime-pick'}))
+    
+    new_params['create_extra_dynafields'] = form_fields
 
     params = dicts.merge(params, new_params)