Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Layout tweaks, adding migration for admin user, fixing tests.

  • Loading branch information...
commit efce87e52f3ca631bc6196d0cd262f819afee494 1 parent ea9abb4
@thomasn authored
View
6 app/helpers/common_helper.rb
@@ -49,7 +49,7 @@ def build_form
i += 1
if column.name != 'notes'
if i == 1 && ( params[:table_name] == 'contacts' || params[:table_name] == 'addresses' || params[:table_name] == 'groups' || params[:table_name] == 'dynamic_attributes' || params[:table_name] == 'users' || params[:table_name] == 'activities' )
- result = "<div id=\"col\"><p><label for=\"object_#{column.name}\">#{column.name.humanize}</label>"
+ result = "<div class=\"columnar\"><p><label for=\"object_#{column.name}\">#{column.name.humanize}</label>"
else
result = "<p><label for=\"object_#{column.name}\">#{column.name.humanize}</label>"
end
@@ -64,8 +64,8 @@ def build_form
result += "<br/>\n#{input('object', column.name)}"
end
result +="</p>\n"
- result += "\n</div>\n<div id=\"col\">\n" if i == number_of_columns/2
- result += "</fieldset>" if column.name == 'notes'
+ result += "\n</div>\n<div class=\"columnar\" />\n" if i == number_of_columns/2 # FIXME TN - closing as empty div - check
+ ## FIXME CHECK! result += "</fieldset>" if column.name == 'notes'
result
}.join("\n")
end
View
2  app/models/activity.rb
@@ -13,7 +13,7 @@ class Activity < ActiveRecord::Base
def display_name
result = self.activity_type_id.nil? ? "activity ##{self.id}" : self.activity_type.display_name
- result += ' at ' + self.time.strftime('%d/%m/%y %H:%M') unless self.time.nil?
+ result += ' at ' + self.time.getutc.strftime('%d/%m/%y %H:%M') unless self.time.nil?
result = '[multiple contacts]: ' + result if self.contacts.size > 1
result = self.contacts[0].display_name + ': ' + result if self.contacts.size == 1
result
View
7 app/models/contact.rb
@@ -111,13 +111,16 @@ def self.create_attribute(a, recreate_index = false)
# Sphinx indexing
is_indexed :fields => [ 'first_name', 'last_name', 'email', 'notes' ],
:include => [ {:class_name => 'Address', :field => 'address1'} ]
- create_attributes
+ ## FIXME breaks initial migration with empty DB ## create_attributes
acts_as_taggable
after_create { |c| c.new_dynamic_attribute_values.values.each { |v| v.contact_id = c.id; v.save } }
after_update { |c| c.new_dynamic_attribute_values.values.each { |v| v.save } }
def display_name
- !self.first_name.nil? || !self.last_name.nil? ? "#{self.last_name}, #{self.first_name}".strip : "contact ##{self.id}"
+ fname = self.first_name.blank? ? "--" : self.first_name.strip
+ lname = self.last_name.blank? ? "--" : self.last_name.strip
+
+ self.first_name.nil? && self.last_name.nil? ? "contact ##{self.id}" : "#{lname}, #{fname}"
end
alias_method :old_column_for_attribute, :column_for_attribute
View
5 app/views/common/_new_and_edit.rhtml
@@ -99,12 +99,13 @@ function selectAllOptions() {
<div style="clear:both"></div>
<% end %>
- <br />
+ <!-- TN <br /> -->
<div style="text-align: center; width:100px; margin: 0 auto 0 auto;">
<%= submit_tag (params[:action] == 'new' ? 'Create' : 'Update'), :onclick => "selectAllOptions()" %>
+ <!-- TN: added --> </div>
<% end %>
<br />
<%= link_to 'Show', :action => 'show', :id => @object %> |
<%= link_to 'Back', :action => 'list' %>
</div>
-</div>
+<!-- TN </div> -->
View
2  app/views/layouts/forgetmenot.rhtml
@@ -18,7 +18,7 @@
</head>
<body>
<div>
- <img style="margin:0px; "src="/images/forget-title.jpg" alt="logo" />
+ <img style="margin:0px;" src="/images/forget-title.jpg" alt="logo" />
</div>
<div>
<% if logged_in? -%>
View
14 db/migrate/20090715152826_add_admin_user.rb
@@ -0,0 +1,14 @@
+class AddAdminUser < ActiveRecord::Migration
+ def self.up
+ @user = User.new
+ @user.login = 'admin'
+ @user.email = 'admin@example.com'
+ @user.salt = 'NiCl2'
+ @user.password = @user.password_confirmation = 'admin'
+ @user.save!
+ end
+
+ def self.down
+ @user.find_by_login('admin').delete
+ end
+end
View
161 db/schema.rb
@@ -1,57 +1,64 @@
-# This file is autogenerated. Instead of editing this file, please use the
-# migrations feature of ActiveRecord to incrementally modify your database, and
+# This file is auto-generated from the current state of the database. Instead of editing this file,
+# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your database schema. If you need
+# to create the application database on another system, you should be using db:schema:load, not running
+# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 23) do
+ActiveRecord::Schema.define(:version => 20090715152826) do
create_table "activities", :force => true do |t|
- t.column "activity_type_id", :integer
- t.column "time", :datetime
- t.column "notes", :text
- t.column "user_id", :integer
+ t.integer "activity_type_id"
+ t.datetime "time"
+ t.text "notes"
+ t.integer "user_id"
end
add_index "activities", ["activity_type_id"], :name => "index_activities_on_activity_type_id"
add_index "activities", ["user_id"], :name => "index_activities_on_user_id"
create_table "activities_contacts", :id => false, :force => true do |t|
- t.column "activity_id", :integer
- t.column "contact_id", :integer
+ t.integer "activity_id"
+ t.integer "contact_id"
end
add_index "activities_contacts", ["activity_id"], :name => "index_activities_contacts_on_activity_id"
add_index "activities_contacts", ["contact_id"], :name => "index_activities_contacts_on_contact_id"
create_table "activity_types", :force => true do |t|
- t.column "name", :string
+ t.string "name"
end
create_table "addresses", :force => true do |t|
- t.column "address1", :string
- t.column "address2", :string
- t.column "city", :string
- t.column "state", :string
- t.column "zip", :string
- t.column "country", :string
+ t.string "address1"
+ t.string "address2"
+ t.string "city"
+ t.string "state"
+ t.string "zip"
+ t.string "country"
end
create_table "contacts", :force => true do |t|
- t.column "first_name", :string
- t.column "last_name", :string
- t.column "email", :string
- t.column "phone_number", :string
- t.column "title", :string
- t.column "work_phone", :string
- t.column "mobile_phone", :string
- t.column "home_phone", :string
- t.column "other_phone", :string
- t.column "fax", :string
- t.column "do_not_email", :boolean
- t.column "do_not_phone", :boolean
- t.column "notes", :text
- t.column "address_id", :integer
- t.column "address2_id", :integer
- t.column "lead_source_id", :integer
+ t.string "first_name"
+ t.string "last_name"
+ t.string "email"
+ t.string "phone_number"
+ t.string "title"
+ t.string "work_phone"
+ t.string "mobile_phone"
+ t.string "home_phone"
+ t.string "other_phone"
+ t.string "fax"
+ t.boolean "do_not_email"
+ t.boolean "do_not_phone"
+ t.text "notes"
+ t.integer "address_id"
+ t.integer "address2_id"
+ t.integer "lead_source_id"
end
add_index "contacts", ["address2_id"], :name => "index_contacts_on_address2_id"
@@ -59,59 +66,59 @@
add_index "contacts", ["lead_source_id"], :name => "index_contacts_on_lead_source_id"
create_table "contacts_groups", :id => false, :force => true do |t|
- t.column "contact_id", :integer
- t.column "group_id", :integer
+ t.integer "contact_id"
+ t.integer "group_id"
end
add_index "contacts_groups", ["contact_id"], :name => "index_contacts_groups_on_contact_id"
add_index "contacts_groups", ["group_id"], :name => "index_contacts_groups_on_group_id"
create_table "dynamic_attribute_values", :force => true do |t|
- t.column "dynamic_attribute_id", :integer
- t.column "contact_id", :integer
- t.column "string_value", :string
- t.column "text_value", :text
- t.column "integer_value", :integer
- t.column "decimal_value", :decimal
- t.column "datetime_value", :datetime
- t.column "boolean_value", :boolean
+ t.integer "dynamic_attribute_id"
+ t.integer "contact_id"
+ t.string "string_value"
+ t.text "text_value"
+ t.integer "integer_value"
+ t.decimal "decimal_value"
+ t.datetime "datetime_value"
+ t.boolean "boolean_value"
end
add_index "dynamic_attribute_values", ["contact_id"], :name => "index_dynamic_attribute_values_on_contact_id"
add_index "dynamic_attribute_values", ["dynamic_attribute_id"], :name => "index_dynamic_attribute_values_on_dynamic_attribute_id"
create_table "dynamic_attributes", :force => true do |t|
- t.column "name", :string
- t.column "type_name", :string
+ t.string "name"
+ t.string "type_name"
end
add_index "dynamic_attributes", ["name"], :name => "index_dynamic_attributes_on_name"
create_table "email_messages", :force => true do |t|
- t.column "activity_id", :integer
- t.column "subject", :string
- t.column "body", :text
+ t.integer "activity_id"
+ t.string "subject"
+ t.text "body"
end
create_table "group_types", :force => true do |t|
- t.column "name", :string
+ t.string "name"
end
create_table "groups", :force => true do |t|
- t.column "name", :string
- t.column "account_number", :integer
- t.column "phone", :string
- t.column "fax", :string
- t.column "website", :string
- t.column "notes", :text
- t.column "billing_address_id", :integer
- t.column "shipping_address_id", :integer
- t.column "group_type_id", :integer
- t.column "parent_id", :integer
- t.column "lft", :integer
- t.column "rgt", :integer
- t.column "root_id", :integer
- t.column "depth", :integer
+ t.string "name"
+ t.integer "account_number"
+ t.string "phone"
+ t.string "fax"
+ t.string "website"
+ t.text "notes"
+ t.integer "billing_address_id"
+ t.integer "shipping_address_id"
+ t.integer "group_type_id"
+ t.integer "parent_id"
+ t.integer "lft"
+ t.integer "rgt"
+ t.integer "root_id"
+ t.integer "depth"
end
add_index "groups", ["billing_address_id"], :name => "index_groups_on_billing_address_id"
@@ -123,31 +130,31 @@
add_index "groups", ["shipping_address_id"], :name => "index_groups_on_shipping_address_id"
create_table "lead_sources", :force => true do |t|
- t.column "name", :string
+ t.string "name"
end
create_table "taggings", :force => true do |t|
- t.column "tag_id", :integer
- t.column "taggable_id", :integer
- t.column "taggable_type", :string
- t.column "created_at", :datetime
+ t.integer "tag_id"
+ t.integer "taggable_id"
+ t.string "taggable_type"
+ t.datetime "created_at"
end
create_table "tags", :force => true do |t|
- t.column "name", :string
+ t.string "name"
end
create_table "users", :force => true do |t|
- t.column "login", :string
- t.column "email", :string
- t.column "crypted_password", :string, :limit => 40
- t.column "salt", :string, :limit => 40
- t.column "created_at", :datetime
- t.column "updated_at", :datetime
- t.column "remember_token", :string
- t.column "remember_token_expires_at", :datetime
+ t.string "login"
+ t.string "email"
+ t.string "crypted_password", :limit => 40
+ t.string "salt", :limit => 40
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "remember_token"
+ t.datetime "remember_token_expires_at"
end
- add_index "users", ["login", "crypted_password"], :name => "index_users_on_login_and_crypted_password"
+ add_index "users", ["crypted_password", "login"], :name => "index_users_on_login_and_crypted_password"
end
View
15 public/stylesheets/forgetmenot.css
@@ -180,13 +180,6 @@ fieldset {
float: left;
}
-#col{
-position: relative;
-margin:10px;
-width: 200px;
-float: left;
-}
-
/***********
* CLASS *
@@ -195,3 +188,11 @@ float: left;
.form {
width: 700px;
}
+
+.columnar {
+position: relative;
+margin:10px;
+width: 200px;
+float: left;
+}
+
View
13 test/functional/common_controller_test.rb
@@ -177,6 +177,7 @@ def test_show__activity_type
assert_select 'h2', 'Activities'
assert_select 'a[href^="/activities/show/"]', false
end
+
def test_new__activity
get :new, { :table_name => 'activities' }, { :user => 1 }
@@ -214,6 +215,7 @@ def test_new__activity
assert_select 'input#object_tag_list', false
end
+
def test_new__activity_type
get :new, { :table_name => 'activity_types' }, { :user => 1 }
assert_response :success
@@ -247,14 +249,14 @@ def test_new__activity_type
assert_select 'input#object_tag_list', false
end
-
+
def test_create__activity
count = Activity.count
post :new, { :object => { :notes => 'AAA', :activity_type_id => '2', :contact_ids => ["1", "2"] }, :table_name => 'activities' }, { :user => 1 }
assert_response :redirect
- assert_redirected_to :action => 'list'
+ assert_redirected_to :action => 'new'
assert_equal count + 1, Activity.count
a = Activity.find_by_notes('AAA')
@@ -272,7 +274,7 @@ def test_create__activity_with_empty_associated
post :new, { :object => { :notes => 'AAA' }, :table_name => 'activities' }, { :user => 1 }
assert_response :redirect
- assert_redirected_to :action => 'list'
+ assert_redirected_to :action => 'new'
assert_equal count + 1, Activity.count
a = Activity.find_by_notes('AAA')
@@ -288,7 +290,7 @@ def test_create__activity_type
post :new, { :object => { :name => 'AAA', :activity_ids => ["1", "2"] }, :table_name => 'activity_types' }, { :user => 1 }
assert_response :redirect
- assert_redirected_to :action => 'list'
+ assert_redirected_to :action => 'new'
assert_equal count + 1, ActivityType.count
a = ActivityType.find_by_name('AAA')
@@ -304,7 +306,7 @@ def test_create__activity_type_with_empty_associated
post :new, { :object => { :name => 'AAA', :activity_ids => [] }, :table_name => 'activity_types' }, { :user => 1 }
assert_response :redirect
- assert_redirected_to :action => 'list'
+ assert_redirected_to :action => 'new'
assert_equal count + 1, ActivityType.count
a = ActivityType.find_by_name('AAA')
@@ -635,4 +637,5 @@ def test_new__contact
assert_select 'input#object_tag_list', 1
end
+
end
View
4 test/unit/activity_test.rb
@@ -21,13 +21,13 @@ def test_display_name
assert_equal "[multiple contacts]: #{a.activity_type.display_name} at #{a.time.strftime('%d/%m/%y %H:%M')}", a.display_name
a = Activity.find(activities(:thomas_call_in).id)
- assert_equal "Thomas Nichols: #{a.activity_type.display_name} at #{a.time.strftime('%d/%m/%y %H:%M')}", a.display_name
+ assert_equal "Nichols, Thomas: #{a.activity_type.display_name} at #{a.time.strftime('%d/%m/%y %H:%M')}", a.display_name
a = Activity.create
assert_equal "activity ##{a.id} at #{a.time.strftime('%d/%m/%y %H:%M')}", a.display_name
now = Time.now
a = Activity.create :time => now
- assert_equal "activity ##{a.id} at #{now.strftime('%d/%m/%y %H:%M')}", a.display_name
+ assert_equal "activity ##{a.id} at #{now.getutc.strftime('%d/%m/%y %H:%M')}", a.display_name # TODO use local times
a = Activity.create :activity_type_id => 1
assert_equal "Email in at #{a.time.strftime('%d/%m/%y %H:%M')}", a.display_name
end
View
6 test/unit/contact_test.rb
@@ -22,13 +22,13 @@ def test_truth
end
def test_display_name
- assert_equal contacts(:yura).first_name + ' ' + contacts(:yura).last_name, Contact.find(contacts(:yura).id).display_name
+ assert_equal contacts(:yura).last_name + ', ' + contacts(:yura).first_name, Contact.find(contacts(:yura).id).display_name
c = Contact.create
assert_equal "contact ##{c.id}", c.display_name
c = Contact.create :last_name => 'last_name'
- assert_equal 'last_name', c.display_name
+ assert_equal 'last_name, --', c.display_name
c = Contact.create :first_name => 'first_name'
- assert_equal 'first_name', c.display_name
+ assert_equal '--, first_name', c.display_name
end
def test_habtm_groups
Please sign in to comment.
Something went wrong with that request. Please try again.