def check_user_profile
profile_config = Rails.configuration.user_profile_form_fields
- if request.method.downcase != 'get' || params[:partials]
+ if request.method.downcase != 'get' || params[:partial] ||
+ params[:tab_pane] || params[:action_method] ||
+ params[:action] == 'setup_popup'
return true
end
user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
current_user_profile = user_prefs[:profile] if user_prefs
- profile_config.andand.each do |entry|
+ profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
if entry['required']
if !current_user_profile || !current_user_profile[entry['key'].to_sym]
missing_required_profile = true
end
def update_profile
- user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
-
profile_keys = []
profile_config = Rails.configuration.user_profile_form_fields
profile_config.andand.each do |entry|
end
end
- # Inform server to send mail if this is the first time profile is being created and notification is configured
- profile_notification_address = Rails.configuration.user_profile_notification_address
- current_user_profile = user_prefs[:profile] if user_prefs
- if !current_user_profile && profile_notification_address
- updated_profile[:send_profile_notification_email] = profile_notification_address
+ if updated_profile.size > 0
+ # Inform server to send mail if this is the first time profile is being created and notification is configured
+ profile_notification_address = Rails.configuration.user_profile_notification_address
+ user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
+ current_user_profile = user_prefs[:profile] if user_prefs
+ if !current_user_profile && profile_notification_address
+ updated_profile[:send_profile_notification_email] = profile_notification_address
+ end
+
+ current_user.update_profile updated_profile
end
- current_user.update_profile updated_profile
respond_to do |format|
format.js {render inline: "location.reload();"}
end
-<%
+<%
profile_config = Rails.configuration.user_profile_form_fields
this_user = User.limit(1).where(uuid: current_user.uuid).first
user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
current_user_profile = user_prefs[:profile] if user_prefs
+ show_save_button = false
%>
+
<div>
<div class="panel panel-default">
<div class="panel-heading">
<div>
<% profile_message = 'You can manage your profile using this page. Any feilds in red are required and missing.
Please fill in those fields before you can accesse Arvados Workbench.'
- profile_config.andand.each do |entry|
+ profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
if entry['message']
profile_message = entry['message']
break
</div>
</div>
- <% profile_config.andand.each do |entry| %>
+ <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
<% if entry['key'] %>
<%
+ show_save_button = true
label = entry['required'] ? '* ' : ''
label += entry['form_field_title']
value = current_user_profile[entry['key'].to_sym] if current_user_profile
<% end %>
<% end %>
- <div class="form-group">
- <div class="col-sm-offset-3 col-sm-9">
- <button type="submit" class="btn btn-primary">Save profile</button>
+ <% if show_save_button %>
+ <div class="form-group">
+ <div class="col-sm-offset-3 col-sm-9">
+ <button type="submit" class="btn btn-primary">Save profile</button>
+ </div>
</div>
- </div>
+ <% end %>
<% end %>
</div>
</div>