Permalink
Browse files

Added templates for 'funny' widgets here: django/conf/admin_templates…

…/widget

Added a follow argument to manipulators. This allows you to exclude/include fields and related objects ( recursively), defaulting to current behaviour, meaning that forms can modify a subset of fields. This should fix #445. Fixed update generic view to use this (will change others soon).  Merged to trunk r772. 



git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 1c9cf48 commit 555502e208656b2a6cb8aa4cf11acdf5a0374285 @rjwittams rjwittams committed Oct 4, 2005
@@ -0,0 +1,4 @@
+<p class="datetime">
+ Date: {{ bound_field.form_fields.0 }}<br />
+ Time: {{ bound_field.form_fields.1 }}
+</p>
@@ -0,0 +1 @@
+{% output_all bound_field.form_fields %}
@@ -0,0 +1,4 @@
+{% if bound_field.original_value %}
+Currently: <a href="{{ bound_field.original_url }}" > {{ bound_field.original_value }} </a><br />
+Change: {% output_all bound_field.form_fields %}
+{% else %} {% output_all bound_field.form_fields %} {% endif %}
@@ -0,0 +1,7 @@
+{% output_all bound_field.form_fields %}
+{% if bound_field.raw_id_admin %}
+ <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/" class="related-lookup" id="lookup_{{bound_field.element_id}}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>
+{% else %}
+{% if bound_field.needs_add_label %}
+ <a href="../../../{{ bound_field.field.rel.to.app_label }}/{{ bound_field.field.rel.to.module_name }}/add/" class="add-another" id="add_{{ bound_field.element_id}}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a>
+{% endif %} {% endif %}
@@ -0,0 +1 @@
+{% include "widget/foreign" %}

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -639,11 +639,14 @@ def get_manipulator_field_objs(self):
return [formfields.IntegerField]
def get_db_prep_save(self,value):
- if value == '':
- return None
- else:
- return int(value)
-
+ try:
+ if value == '' or None:
+ return None
+ else:
+ return int(value)
+ except Exception, e:
+ print "name: %s val: %s" % (self.name, value)
+
def flatten_data(self, obj = None):
if not obj:
# In required many-to-one fields with only one available choice,
@@ -68,7 +68,7 @@ def create_object(request, app_label, module_name, template_name=None,
def update_object(request, app_label, module_name, object_id=None, slug=None,
slug_field=None, template_name=None, template_loader=template_loader,
extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None,
- login_required=False):
+ login_required=False, follow=None):
"""
Generic object-update function.
@@ -98,13 +98,13 @@ def update_object(request, app_label, module_name, object_id=None, slug=None,
except ObjectDoesNotExist:
raise Http404("%s.%s does not exist for %s" % (app_label, module_name, lookup_kwargs))
- manipulator = mod.ChangeManipulator(object.id)
+ manipulator = mod.ChangeManipulator(object.id, follow=follow)
if request.POST:
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
+ manipulator.do_html2python(new_data)
if not errors:
- manipulator.do_html2python(new_data)
manipulator.save(new_data)
if not request.user.is_anonymous():
@@ -120,7 +120,7 @@ def update_object(request, app_label, module_name, object_id=None, slug=None,
else:
errors = {}
# This makes sure the form acurate represents the fields of the place.
- new_data = object.__dict__
+ new_data = manipulator.flatten_data()
form = formfields.FormWrapper(manipulator, new_data, errors)
if not template_name:
View
@@ -7,7 +7,7 @@ This is made possible by the excellent, open-source ReportLab_ Python PDF
library.
The advantage of generating PDF files dynamically is that you can create
-customzed PDFs for different purposes -- say, for different users or different
+customized PDFs for different purposes -- say, for different users or different
pieces of content.
For example, Django was used at kusports.com to generate customized,
@@ -267,7 +267,7 @@ every template automatic access to the current time, use something like this::
from django.core.template import Context
import datetime
- class TimeContext(template.Context):
+ class TimeContext(Context):
def __init__(self, *args, **kwargs):
Context.__init__(self, *args, **kwargs)
self['current_time'] = datetime.datetime.now()

0 comments on commit 555502e

Please sign in to comment.