Skip to content
This repository was archived by the owner on Jul 24, 2020. It is now read-only.

Commit 818959c

Browse files
committed
refactor user views
1 parent 27d28f9 commit 818959c

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
<% accepted = (@user.terms_of_service_accepted == true) %>
2-
<% new_user_by_self = !current_user %>
3-
<% new_user_by_admin = ((params[:action] == 'new') && (can? :manage, Reservation)) %>
4-
<% edit_user_by_self = (current_user == @user) %>
5-
<% edit_user_by_admin = (can? :manage, Reservation) %>
1+
<% accepted = @user.terms_of_service_accepted == true %>
62

7-
<% if new_user_by_self %>
8-
<%= f.input :terms_of_service_accepted,
9-
input_html: {type: "checkbox", value: accepted },
10-
label: "I accept the #{link_to("Terms of Service", tos_path, target: '_blank')}" %>
11-
<% elsif new_user_by_admin %>
12-
<%= f.input :created_by_admin, as: :hidden, value: true %>
13-
<%= f.input :terms_of_service_accepted,
14-
input_html: {value: accepted, disabled: true },
15-
label: "User must accept the #{link_to("Terms of Service", tos_path, target: '_blank')} during first checkout." %>
16-
<% elsif edit_user_by_self %>
17-
<%= f.input :terms_of_service_accepted,
18-
input_html: {type: "checkbox", value: accepted },
19-
label: "I accept the #{link_to("Terms of Service", tos_path, target: '_blank')}" %>
20-
<% elsif edit_user_by_admin %>
21-
<%= f.input :terms_of_service_accepted,
22-
input_html: {type: "checkbox", value: accepted, disabled: true },
23-
label: "Has user accepted the #{link_to("Terms of Service", tos_path, target: '_blank')}?" %>
24-
<% end %>
3+
<%= f.input :terms_of_service_accepted,
4+
input_html: {value: accepted, disabled: (cannot? :manage, Reservation)},
5+
label: "#{ (current_user == @user) ? 'I accept' : 'User accepts'} the #{
6+
link_to('Terms of Service', tos_path, target: '_blank')}".html_safe %>
7+
8+
<% if can? :manage, Reservation %>
9+
<%= f.input :created_by_admin, as: :hidden, value: true %>
10+
<% end%>

app/views/users/_form.html.erb

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<%# TODO: Make this a fancy box %>
2727
<%= f.association :requirements, :collection => Requirement.all.map{|req| [req.description,req.id]}, :label => "Requirements user has satisfied"%>
2828
<%= f.input :role, :collection => (can? :appoint, :superuser) ? ['normal', 'checkout', 'admin', 'superuser', 'banned'] : ['normal', 'checkout', 'admin', 'banned'], placeholder: 'normal' %>
29-
<%= f.input :deleted_at, label: "Disabled", :as => :deleted %>
3029
<% end %>
3130

3231
<% if @user %>

0 commit comments

Comments
 (0)