diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bc4fc85ac..b5a9dc169 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -227,6 +227,16 @@ module ApplicationHelper xls_report.string end + # 用户资料是否完善 + def user_data_complete user + user_extension = UserExtensions.where(:user_id => user.id).first + data = true + if user_extension.gender.nil? || user_extension.school_id.nil? || user.lastname.blank? || (user_extension.identity == 3 && user_extension.school_id.nil?) + data = false + end + return data + end + # 获取用户单位 # 优先获取高校信息,如果改信息不存在则获取occupation def get_occupation_from_user user diff --git a/app/models/user.rb b/app/models/user.rb index 8fb7f36f6..e9aa1dde8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -80,12 +80,12 @@ class User < Principal #每日一报、一事一报、不报 - MAIL_NOTIFICATION_OPTIONS = [ + # MAIL_NOTIFICATION_OPTIONS = [ #['week', :label_user_mail_option_week], # ['day', :label_user_mail_option_day], - ['all', :label_user_mail_option_all], - ['none', :label_user_mail_option_none] - ] + # ['all', :label_user_mail_option_all], + # ['none', :label_user_mail_option_none] + # ] has_many :homework_users has_many :homework_attaches, :through => :homework_users @@ -244,7 +244,7 @@ class User < Principal validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :allow_blank => true validates_length_of :mail, :maximum => MAIL_LENGTH_LIMIT, :allow_nil => true validates_confirmation_of :password, :allow_nil => true - validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true + # validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true validate :validate_password_length # validates_email_realness_of :mail before_create :set_mail_notification diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index b53f35edb..5778949aa 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -101,10 +101,10 @@
- -
- - - <% elsif User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %> - <% if User.current.user_extensions.school_id.nil? %> - - - <% else %> - - + -+ +
+ + + <% elsif User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %> + <% if User.current.user_extensions.school_id.nil? %> + + + <% else %> + + + <% end %> + ++ +
+ + <% elsif User.current.user_extensions.school.nil? %> + + + ++ +
+ + <% else %> + + + ++ +
+ + <% end %> + +您还没有创建属于自己的个人主页。 + <% if user_data_complete @user %> + <%= link_to '新建', new_user_homepage_article_homepage_path(:user_id => @user.id, + :homepage_id => @user.homepage.id), + :onclick=>"my_account_form_submit();", + :target => "_blank", + :class => 'linkBlue' %> <% end %> -
- -
- - <% elsif User.current.user_extensions.school.nil? %> - - - -- -
- - <% else %> - - - -- -
- - <% end %> - -您还没有创建属于自己的个人主页。<%=link_to '新建', new_user_homepage_article_homepage_path(:user_id=> @user.id, :homepage_id => @user.homepage.id),:onclick=>"my_account_form_submit();", :target => "_blank", :class => 'linkBlue' %>
- <% end %> - -