Permalink
Browse files

Merged to trunk r1152

git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1154 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
2 parents a4961a9 + 28bce49 commit dbaf9c6f8d4c17013238958a9b2f3f8d7bcbb665 @rjwittams rjwittams committed Nov 10, 2005
@@ -57,7 +57,7 @@
{% else %}
<ul class="actionlist">
{% for entry in admin_log %}
- <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if not entry.is_deletion %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{{ entry.get_content_type.name|capfirst }}</span></li>
+ <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">{% if not entry.is_deletion %}<a href="{{ entry.get_admin_url }}">{% endif %}{{ entry.object_repr|escape }}{% if not entry.is_deletion %}</a>{% endif %}<br /><span class="mini quiet">{{ entry.get_content_type.name|capfirst }}</span></li>
{% endfor %}
</ul>
{% endif %}
@@ -113,7 +113,7 @@ def choices(self, cl):
'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
'display': _('All') }
for val in self.lookup_choices:
- pk_val = getattr(val, self.field.rel.to.pk.column)
+ pk_val = getattr(val, self.field.rel.to.pk.attname)
yield { 'selected': self.lookup_val == str(pk_val),
'query_string': cl.get_query_string( {self.lookup_kwarg: pk_val}),
'display' : val }
@@ -547,7 +547,7 @@ def render_change_form(opts, manipulator, app_label, context, add=False, change=
context_instance=context)
def log_add_message(user, opts,manipulator,new_object):
- pk_value = getattr(new_object, opts.pk.column)
+ pk_value = getattr(new_object, opts.pk.attname)
log.log_action(user.id, opts.get_content_type_id(), pk_value, str(new_object), log.ADDITION)
def add_stage(request, app_label, module_name, show_delete=False, form_url='', post_url='../', post_url_continue='../%s/', object_id_override=None):
@@ -566,7 +566,7 @@ def add_stage(request, app_label, module_name, show_delete=False, form_url='', p
new_object = manipulator.save(new_data)
log_add_message(request.user, opts,manipulator,new_object)
msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name':opts.verbose_name, 'obj':new_object}
- pk_value = getattr(new_object,opts.pk.column)
+ pk_value = getattr(new_object,opts.pk.attname)
# Here, we distinguish between different save types by checking for
# the presence of keys in request.POST.
if request.POST.has_key("_continue"):
@@ -644,7 +644,7 @@ def change_stage(request, app_label, module_name, object_id):
new_object = manipulator.save(new_data)
log_change_message(request.user,opts,manipulator,new_object)
msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj':new_object}
- pk_value = getattr(new_object,opts.pk.column)
+ pk_value = getattr(new_object,opts.pk.attname)
if request.POST.has_key("_continue"):
request.user.add_message(msg + ' ' + _("You may edit it again below."))
if request.REQUEST.has_key('_popup'):
@@ -738,7 +738,7 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
# Display a link to the admin page.
nh(deleted_objects, current_depth, ['%s: <a href="../../../../%s/%s/%s/">%s</a>' % \
(capfirst(related.opts.verbose_name), related.opts.app_label, related.opts.module_name,
- getattr(sub_obj, related.opts.pk.column), sub_obj), []])
+ getattr(sub_obj, related.opts.pk.attname), sub_obj), []])
_get_deleted_objects(deleted_objects, perms_needed, user, sub_obj, related.opts, current_depth+2)
else:
has_related_objs = False
@@ -309,6 +309,7 @@ def convert_post_data(self, new_data):
new_data.setlist(name, [])
def get_id(self):
+ "Returns the HTML 'id' attribute for this form field."
return FORM_FIELD_ID_PREFIX + self.field_name
####################
# GENERIC WIDGETS #
@@ -408,10 +409,10 @@ def __init__(self, field_name, choices=[], size=1, is_required=False, validator_
self.member_name = member_name
def render(self, data):
- str_data = str(data) # normalize to string
output = ['<select id="%s" class="v%s%s" name="%s" size="%s">' % \
- (self.get_id(), self.__class__.__name__,
+ (self.get_id(), self.__class__.__name__,
self.is_required and ' required' or '', self.field_name, self.size)]
+ str_data = str(data) # normalize to string
for value, display_name in self.choices:
selected_html = ''
if str(value) == str_data:
@@ -593,8 +594,7 @@ def isNonEmptyFile(self, field_data, all_data):
def render(self, data):
return '<input type="file" id="%s" class="v%s" name="%s" />' % \
- (self.get_id(), self.__class__.__name__,
- self.field_name)
+ (self.get_id(), self.__class__.__name__, self.field_name)
def html2python(data):
if data is None:
@@ -108,7 +108,23 @@ def get_sql_delete(mod):
cursor = db.db.cursor()
except:
cursor = None
+
+ # Determine whether the admin log table exists. It only exists if the
+ # person has installed the admin app.
+ try:
+ if cursor is not None:
+ # Check whether the table exists.
+ cursor.execute("SELECT 1 FROM django_admin_log LIMIT 1")
+ except:
+ # The table doesn't exist, so it doesn't need to be dropped.
+ db.db.rollback()
+ admin_log_exists = False
+ else:
+ admin_log_exists = True
+
output = []
+
+ # Output DROP TABLE statements for standard application tables.
for klass in mod._MODELS:
try:
if cursor is not None:
@@ -119,6 +135,8 @@ def get_sql_delete(mod):
db.db.rollback()
else:
output.append("DROP TABLE %s;" % klass._meta.db_table)
+
+ # Output DROP TABLE statements for many-to-many tables.
for klass in mod._MODELS:
opts = klass._meta
for f in opts.many_to_many:
@@ -140,8 +158,9 @@ def get_sql_delete(mod):
# Delete from the admin log.
if cursor is not None:
cursor.execute("SELECT id FROM content_types WHERE package = %s", [app_label])
- for row in cursor.fetchall():
- output.append("DELETE FROM django_admin_log WHERE content_type_id = %s;" % row[0])
+ if admin_log_exists:
+ for row in cursor.fetchall():
+ output.append("DELETE FROM django_admin_log WHERE content_type_id = %s;" % row[0])
# Close database connection explicitly, in case this output is being piped
# directly into a database client, to avoid locking issues.
Oops, something went wrong.

0 comments on commit dbaf9c6

Please sign in to comment.