From 442d66fc02a221ab9e0049eaba8db38373c1727a Mon Sep 17 00:00:00 2001 From: zhangcaiyan Date: Sun, 28 Oct 2012 19:31:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/fenlei.rb | 2 +- app/models/people.rb | 2 +- app/models/zhangben.rb | 2 +- .../devise/registrations/bianji_mima.html.erb | 39 +- app/views/devise/registrations/edit.html.erb | 36 +- app/views/devise/sessions/new.html.erb | 23 +- app/views/fenleis/_form.html.erb | 11 +- app/views/fenleis/index.html.erb | 80 ++-- app/views/home/index.html.erb | 17 +- app/views/partial/_signed_in_header.html.erb | 15 +- app/views/peoples/_form.html.erb | 14 +- app/views/peoples/index.html.erb | 8 +- app/views/zhangbens/_form.html.erb | 17 +- app/views/zhangbens/index.html.erb | 10 +- app/views/zhangmus/new.html.erb | 389 ++++++++++++------ config/routes.rb | 6 +- 16 files changed, 375 insertions(+), 296 deletions(-) diff --git a/app/models/fenlei.rb b/app/models/fenlei.rb index 9a79f5a..922aded 100644 --- a/app/models/fenlei.rb +++ b/app/models/fenlei.rb @@ -5,7 +5,7 @@ class Fenlei < ActiveRecord::Base belongs_to :user acts_as_list scope: [:user_id, :shouzhi] - validates :name, uniqueness: {scope: :user_id}, length: {in: 1..20} + validates :name, presence: true, uniqueness: {scope: :user_id}, length: {maximum: 20} validates :desc, length: {maximum: 1000} symbolize :shouzhi, in: [:zhichu, :shouru], methods: true, scopes: true diff --git a/app/models/people.rb b/app/models/people.rb index 045a91d..b823df0 100644 --- a/app/models/people.rb +++ b/app/models/people.rb @@ -6,6 +6,6 @@ class People < ActiveRecord::Base acts_as_list scope: :user - validates :name, uniqueness: {scope: :user_id}, length: {in: 1..20} + validates :name, presence: true, uniqueness: {scope: :user_id}, length: {maximum: 20} validates :desc, length: {maximum: 1000} end diff --git a/app/models/zhangben.rb b/app/models/zhangben.rb index 63dd6f9..ea39fc8 100644 --- a/app/models/zhangben.rb +++ b/app/models/zhangben.rb @@ -6,7 +6,7 @@ class Zhangben < ActiveRecord::Base acts_as_list scope: :user - validates :name, uniqueness: {scope: :user_id}, length: {in: 1..20} + validates :name, presence: true, uniqueness: {scope: :user_id}, length: {maximum: 20} validates :desc, length: {maximum: 1000} end diff --git a/app/views/devise/registrations/bianji_mima.html.erb b/app/views/devise/registrations/bianji_mima.html.erb index 3f4f519..9af95c7 100644 --- a/app/views/devise/registrations/bianji_mima.html.erb +++ b/app/views/devise/registrations/bianji_mima.html.erb @@ -1,26 +1,25 @@ <%= title "修改密码" %> -<%= render "partial/left_navigation" %> -<% if current_user.username != "1234" %> - <%= flash[:notice] %> - <%= simple_form_for(resource, :url => update_password_path, :html => { :method => :put }) do |f| %> - <%= f.input :current_password, as: :password, input_html: {autocomplete: "off", class: "wenben4"} %> - <%= f.input :password, as: :password, label: "新密码", input_html: {autocomplete: "off", class: "wenben4"} %> - <%= f.input :password_confirmation, as: :password, input_html: {autocomplete: "off", class: "wenben4"} %> -
- <%= f.submit "确认", class: "btn-primary" %> -
- <% end %> +
+
-<% else %> - 您目前登录的是测试账户,所以无法修改密码 -<% end %> + <% if current_user.username != "1234" %> + <%= flash[:notice] %> + <%= simple_form_for(resource, :url => update_password_path, :html => { :method => :put }) do |f| %> + <%= f.input :current_password, as: :password, input_html: {autocomplete: "off", class: "wenben4"} %> + <%= f.input :password, as: :password, label: "新密码", input_html: {autocomplete: "off", class: "wenben4"} %> + <%= f.input :password_confirmation, as: :password, input_html: {autocomplete: "off", class: "wenben4"} %> +
+ <%= f.submit "确认", class: "btn-primary" %> +
+ <% end %> + + <% else %> + 您目前登录的是测试账户,所以无法修改密码 + <% end %> + +
+
- diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 6fd975a..99b3623 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,24 +1,20 @@ <%= title "编辑用户资料" %> -<%= render "partial/left_navigation" %> -<% if current_user.username != "1234" %> - <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "validate_form"}) do |f| %> - <%= f.input :email, readonly: true, input_html: {class: "wenben4"} %> - <%= f.input :username, input_html: {class: "validate[required, maxSize[20], ajax[ajaxUserUsername]] wenben4"} %> - <%= f.input :current_password, input_html: {class: "wenben4", autocomplete: "off"}, hint: "请输入当前密码来更新账户" %> -
- <%= f.button :submit, "更新", class: "btn-primary" %> -
- <% end %> -<% else %> - 您目前登录的是测试账户,所以无法编辑用户信息 -<% end %> - - +
+
+ <% if current_user.username != "1234" %> + <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: "validate_form"}) do |f| %> + <%= f.input :email, readonly: true, input_html: {class: "wenben4"} %> + <%= f.input :username, input_html: {class: "validate[required, maxSize[20], ajax[ajaxUserUsername]] wenben4"} %> + <%= f.input :current_password, input_html: {class: "wenben4", autocomplete: "off"}, hint: "请输入当前密码来更新账户" %> +
+ <%= f.button :submit, "更新", class: "btn-primary" %> +
+ <% end %> + <% else %> + 您目前登录的是测试账户,所以无法编辑用户信息 + <% end %> +
+
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 85ae66d..a4cdd21 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,22 +1,16 @@ <%= title "登陆" %> -
-
- <%= simple_form_for(resource, as: "user", url: session_path(resource_name)) do |f| %> +<%= simple_form_for(resource, as: "user", url: session_path(resource_name)) do |f| %>
  • <%= alert %>
-<% end %> <%= f.input :login, input_html: {class: "wenben1"} %> <%= f.input :password, input_html: {class: "wenben1"} %> <% if devise_mapping.rememberable? -%> -
- - <%= f.check_box :remember_me %> -
+ <%= f.input :remember_me, as: :boolean %> <% end %>
@@ -25,16 +19,8 @@
<% end %> -======= -
- <%= f.button :submit, "登陆", class: "btn-primary" %> - -
- <% end %> -
-
->>>>>>> 59b804a1cf6981db96a3c37bb5c443a7f3706ace + diff --git a/app/views/fenleis/index.html.erb b/app/views/fenleis/index.html.erb index 133107e..a17b0bc 100644 --- a/app/views/fenleis/index.html.erb +++ b/app/views/fenleis/index.html.erb @@ -1,44 +1,43 @@ <% title "类别管理" %> -<%= render "/partial/left_navigation" %> - -
-
- - - - - - - - - - - <% @fenleis.each do |fenlei| %> - - - - - - - <% end %> -
- - <% if params[:search].try(:[], :shouzhi_eq) == "zhichu" %> - 当前为 支出分类,还需要<%= link_to '添加分类', new_fenlei_path %>吗?或者管理<%= link_to "收入分类", fenleis_path(search: {shouzhi_eq: "shouru"}) %>? - <% else %> - 当前为 收入分类,还需要<%= link_to '添加分类', new_fenlei_path %>吗?或者管理<%= link_to "支出分类", fenleis_path(search: {shouzhi_eq: "zhichu"}) %>? - <% end %> - -
默认名称说明操作
- <%= radio_button_tag "fenlei", fenlei.id, fenlei.position == "1" %> - - <%= link_to fenlei.name, edit_fenlei_path(fenlei) %> - <%= fenlei.desc %> - <%= link_to "编辑", edit_fenlei_path(fenlei) %> - <%= link_to "删除", fenlei_path(fenlei), method: :delete, confirm: "确定删除吗?" %> -
-
+
+
+ + + + + + + + + + + + <% @fenleis.each do |fenlei| %> + + + + + + + <% end %> +
+ + <% if params[:search].try(:[], :shouzhi_eq) == "zhichu" %> + 当前为 支出分类,还需要<%= link_to '添加分类', new_fenlei_path %>吗?或者管理<%= link_to "收入分类", fenleis_path(search: {shouzhi_eq: "shouru"}) %>? + <% else %> + 当前为 收入分类,还需要<%= link_to '添加分类', new_fenlei_path %>吗?或者管理<%= link_to "支出分类", fenleis_path(search: {shouzhi_eq: "zhichu"}) %>? + <% end %> + +
默认名称说明操作
+ <%= radio_button_tag "fenlei", fenlei.id, fenlei.position == "1" %> + + <%= link_to fenlei.name, edit_fenlei_path(fenlei) %> + <%= fenlei.desc %> + <%= link_to "编辑", edit_fenlei_path(fenlei) %> + <%= link_to "删除", fenlei_path(fenlei), method: :delete, confirm: "确定删除吗?" %> +
+
@@ -50,9 +49,6 @@ $.get("/fenleis/"+fenlei_id+"/set_default") }) - $("#shezhi").addClass("current") - - $("#fenleiguanli").addClass("current") }) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 354a0fe..772ce4a 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,19 +1,18 @@ <% title "首页" %> -
-
-
-
-