Permalink
Browse files

AutoAdminDjangoTheme's doc mostly finished.

  • Loading branch information...
1 parent 0153b5b commit 713f082aaa59938f4953bedb0f1c5a1a75ac5e88 @baldowl committed Aug 3, 2008
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/auto_admin_django_theme.rb
@@ -1,16 +1,22 @@
+# The Django-based theme module.
module AutoAdminDjangoTheme
extend AutoAdmin::ThemeHelpers
def self.directory(*subdirs)
File.join(File.dirname(File.dirname(__FILE__)), 'themes', 'django', *subdirs)
end
helper do
+ # Given an AdminHistory instance, it builds the history link which lands
+ # the user right into the edit form for the related administered model
+ # object.
def history_link record
link = "(Unnamed #{human_model(record.model).downcase})"
link = record.object_label unless record.object_label.blank?
link = link_to h(link), :model => record.model, :action => 'edit', :id => record.obj_id unless record.change == 'delete'
link
end
+
+ # Tweaks the CSS class used for the history items.
def history_link_class record
case record.change
when 'add'; 'addlink'
@@ -20,8 +26,12 @@ def history_link_class record
end
end
+ # Nothing special to do to user's data before saving them.
class FormProcessor < AutoAdminSimpleTheme::FormProcessor
end
+
+ # Custom FormBuilder used to assemble the administered model editing form
+ # sewing together the pieces.
class FormBuilder < AutoAdminSimpleTheme::FormBuilder
def fieldset_class(style)
case style
@@ -79,6 +89,9 @@ def wrap_field(field_type, field_name, options)
%(<div class="form-row">#{inner}</div>)
end
end
+
+ # Used for fields which must not be wrapped in the Django-based theme's
+ # divs.
def static_text_without_theme(field, options = {})
v = @object.send(field)
if v == true || v == false
@@ -89,6 +102,8 @@ def static_text_without_theme(field, options = {})
end
end
end
+
+ # Custom FormBuilder used to assemble the administered model list view.
class TableBuilder < AutoAdmin::TableBuilder(FormBuilder)
def table_header(field_type, field_name, options)
klass = ''
@@ -152,4 +167,3 @@ def table_cell(field_type, field_name, options)
end
end
end
-

0 comments on commit 713f082

Please sign in to comment.