Changeset 765
- Timestamp:
- 10/02/05 12:55:03 (3 years ago)
- Files:
-
- django/branches/new-admin/django/core/defaulttags.py (modified) (1 diff)
- django/branches/new-admin/django/core/meta/__init__.py (modified) (2 diffs)
- django/branches/new-admin/django/templatetags/admin_modify.py (modified) (5 diffs)
- django/branches/new-admin/docs/outputting_pdf.txt (copied) (copied from django/trunk/docs/outputting_pdf.txt)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/core/defaulttags.py
r741 r765 229 229 230 230 class IncludeNode(template.Node): 231 def __init__(self, template_path ):231 def __init__(self, template_path_var): 232 232 self.template_path_var = template_path_var 233 233 234 234 def render(self, context): 235 235 try: 236 template_path = template.resolve(self.template_path_var, context) 236 template_path = template.resolve_variable(self.template_path_var, context) 237 print "IncludeNode rendering %s" % template_path 237 238 t = template_loader.get_template(template_path) 238 239 return t.render(context) 239 except: 240 except Exception, e: 241 print e 240 242 return '' # Fail silently for invalid included templates. 241 243 django/branches/new-admin/django/core/meta/__init__.py
r748 r765 1036 1036 this_id = getattr(self, self._meta.pk.column) 1037 1037 cursor = db.db.cursor() 1038 cursor.execute("DELETE FROM %s WHERE %s_id = %%s" % (m2m_table, rel.object_name.lower()), [this_id]) 1039 sql = "INSERT INTO %s (%s_id, %s_id) VALUES (%%s, %%s)" % (m2m_table, rel.object_name.lower(), rel_opts.object_name.lower()) 1040 cursor.executemany(sql, [(this_id, i) for i in id_list]) 1038 delete_stmt = "DELETE FROM %s WHERE %s_id = %%s" % (m2m_table, rel.object_name.lower()) 1039 cursor.execute(delete_stmt, [this_id]) 1040 insert_stmt = "INSERT INTO %s (%s, %s) VALUES (%%s, %%s)" % (m2m_table, rel.pk.column, rel_opts.pk.column) 1041 cursor.executemany(insert_stmt, [(this_id, i) for i in id_list]) 1041 1042 db.db.commit() 1042 1043 … … 1489 1490 return man 1490 1491 1491 def manipulator_init(opts, add, change, self, obj_key=None ):1492 def manipulator_init(opts, add, change, self, obj_key=None, follow=None): 1492 1493 if change: 1493 1494 assert obj_key is not None, "ChangeManipulator.__init__() must be passed obj_key parameter." django/branches/new-admin/django/templatetags/admin_modify.py
r741 r765 8 8 from django.views.admin.main import AdminBoundField 9 9 import re 10 11 word_re = re.compile('[A-Z][a-z]+') 12 13 def class_name_to_underscored(name): 14 return '_'.join([ s.lower() for s in word_re.findall(name)[:-1] ]) 15 10 16 11 17 class IncludeAdminScriptNode(template.Node): … … 44 50 context.pop() 45 51 return output; 46 # t = ['<div class="submit-row">']47 48 # if not is_popup:49 # if has_delete_permission and (change or show_delete):50 # t.append('<p class="float-left"><a href="delete/" class="deletelink">Delete</a></p>')51 # if change and save_as:52 # t.append('<input type="submit" value="Save as new" name="_saveasnew" %s/>' % onclick_attrib)53 # if (not save_as or add):54 # t.append('<input type="submit" value="Save and add another" name="_addanother" %s/>' % onclick_attrib)55 # t.append('<input type="submit" value="Save and continue editing" name="_continue" %s/>' % onclick_attrib )56 # t.append('<input type="submit" value="Save" class="default" %s/>' % onclick_attrib)57 # t.append('</div>\n')58 59 # return ''.join(t)60 61 62 63 52 64 53 class AdminFieldBoundNode(template.Node): … … 104 93 105 94 def render(self, context): 95 106 96 bound_field = template.resolve_variable(self.bound_field_var, context) 107 97 add = context['add'] … … 110 100 context.push() 111 101 context['bound_field'] = bound_field 112 t = template_loader.get_template("admin_field_widget") 113 output = t.render(context) 102 klass = bound_field.field.__class__ 103 t = None 104 while klass: 105 try: 106 field_class_name = klass.__name__ 107 template_name = "widget/%s" % \ 108 class_name_to_underscored(field_class_name) 109 110 t = template_loader.get_template(template_name) 111 break 112 except template.TemplateDoesNotExist: 113 klass = (len(klass.__bases__) > 0) and klass.__bases__[0] or None 114 115 if t == None: 116 t = template_loader.get_template("widget/default") 117 118 output = t.render(context) 114 119 context.pop() 115 116 120 return output 117 118 119 121 120 122 class FieldWrapper(object): … … 260 262 ] 261 263 262 word = re.compile('[A-Z][a-z]+') 264 263 265 def register_one_arg_tag(node): 264 tag_name = '_'.join([ s.lower() for s in word.findall(node.__name__)[:-1] ])266 tag_name = class_name_to_underscored(node.__name__) 265 267 parse_func = curry(do_one_arg_tag, node) 266 268 template.register_tag(tag_name, parse_func)
