Improved setting of state attribute.

This commit is contained in:
Martin Edenhofer 2013-01-24 01:37:27 +01:00
parent 83290f4953
commit 272a476b09
2 changed files with 64 additions and 141 deletions

View file

@ -2,7 +2,8 @@ class Setting < ApplicationModel
store :options store :options
store :state store :state
store :state_initial store :state_initial
before_create :set_initial before_create :state_check, :set_initial
before_update :state_check
after_create :delete_cache after_create :delete_cache
after_update :delete_cache after_update :delete_cache
@ -51,4 +52,11 @@ class Setting < ApplicationModel
def set_initial def set_initial
self.state_initial = self.state self.state_initial = self.state
end end
def state_check
if self.state
if !self.state.has_key?(:value)
self.state = { :value => self.state }
end
end
end
end end

View file

@ -21,9 +21,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'Zammad',
:value => 'Zammad',
},
:frontend => true :frontend => true
) )
@ -42,9 +40,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'Example Inc.',
:value => 'Example Inc.',
},
:frontend => true :frontend => true
) )
@ -69,9 +65,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => '10',
:value => '10',
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -89,9 +83,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'zammad.example.com',
:value => 'zammad.example.com',
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -113,9 +105,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'http',
:value => 'http',
},
:frontend => true :frontend => true
) )
@ -140,9 +130,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'DB',
:value => 'DB',
},
:frontend => false :frontend => false
) )
@ -166,9 +154,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => true,
:value => true,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -190,9 +176,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => true,
:value => true,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -214,9 +198,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -238,9 +220,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => true,
:value => true,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -262,9 +242,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -288,9 +266,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => {},
:value => {}
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -312,9 +288,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
@ -339,9 +313,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => {},
:value => {},
},
:frontend => false :frontend => false
) )
@ -364,9 +336,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -390,9 +360,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => {},
:value => {},
},
:frontend => false :frontend => false
) )
@ -415,9 +383,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -441,9 +407,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => {},
:value => {},
},
:frontend => false :frontend => false
) )
@ -473,9 +437,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 6,
:value => 6,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -497,9 +459,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 0,
:value => 0,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -521,9 +481,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 0,
:value => 0,
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -552,9 +510,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 6,
:value => 6,
},
:frontend => true :frontend => true
) )
@ -573,9 +529,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'Ticket#',
:value => 'Ticket#',
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -593,9 +547,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => '',
:value => '',
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -618,9 +570,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'left',
:value => 'left',
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -638,9 +588,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => '110',
:value => '110',
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -658,9 +606,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'RE',
:value => 'RE',
},
:frontend => false :frontend => false
) )
#Setting.create( #Setting.create(
@ -698,9 +644,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'increment',
:value => 'increment',
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -751,11 +695,9 @@ Setting.create_if_not_exists(
], ],
}, },
:state => { :state => {
:value => {
:checksum => false, :checksum => false,
:min_size => 5, :min_size => 5,
}, },
},
:frontend => false :frontend => false
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -778,9 +720,7 @@ Setting.create_if_not_exists(
], ],
}, },
:state => { :state => {
:value => {
:checksum => false, :checksum => false,
}
}, },
:frontend => false :frontend => false
) )
@ -804,9 +744,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => true,
:value => true,
},
:frontend => true :frontend => true
) )
@ -829,9 +767,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => true,
:value => true,
},
:frontend => true :frontend => true
) )
@ -854,9 +790,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'SystemAddressName',
:value => 'SystemAddressName',
},
:frontend => false :frontend => false
) )
@ -875,9 +809,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'via',
:value => 'via',
},
:frontend => false :frontend => false
) )
@ -918,9 +850,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 10,
:value => 10,
},
:frontend => false :frontend => false
) )
@ -945,9 +875,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => ['subject'],
:value => ['subject'],
},
:frontend => false :frontend => false
) )
@ -966,9 +894,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'Notification Master <noreply@#{config.fqdn}>',
:value => 'Notification Master <noreply@#{config.fqdn}>',
},
:frontend => false :frontend => false
) )
@ -987,9 +913,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => '(MAILER-DAEMON|postmaster|abuse)@.+?\..+?',
:value => '(MAILER-DAEMON|postmaster|abuse)@.+?\..+?',
},
:frontend => false :frontend => false
) )
@ -1012,9 +936,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
@ -1037,9 +959,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => false,
:value => false,
},
:frontend => true :frontend => true
) )
@ -1058,9 +978,7 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => 'http://otrs_host/otrs',
:value => 'http://otrs_host/otrs',
},
:frontend => true :frontend => true
) )
Setting.create_if_not_exists( Setting.create_if_not_exists(
@ -1078,13 +996,10 @@ Setting.create_if_not_exists(
}, },
], ],
}, },
:state => { :state => '',
:value => '',
},
:frontend => true :frontend => true
) )
email_address = EmailAddress.create_if_not_exists( email_address = EmailAddress.create_if_not_exists(
:id => 1, :id => 1,
:realname => 'Zammad', :realname => 'Zammad',