name.mustache 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <% unless @read_only
  19. account = @context && (@context.is_a?(Account) ? @context : @context.account)
  20. managed_accounts = @user.associated_root_accounts.active.select{|a| can_do(a, @current_user, :manage_admin_users) }
  21. account ||= managed_accounts.first
  22. root_account = account.root_account if account
  23. end
  24. %>
  25. <% js_bundle :user_name %>
  26. <fieldset id="name_and_email">
  27. <legend>{{#t}}Name and Email{{/t}}</legend>
  28. <table class="profile_table details user_details">
  29. <tr>
  30. <th><%= before_label('full_name', 'Full Name') %></th>
  31. <td class="name"><%=h @user.name %></td>
  32. </tr>
  33. <tr>
  34. <th><%= before_label('display_name', 'Display Name') %></th>
  35. <td class="short_name"><%=h @user.short_name %></td>
  36. </tr>
  37. <tr>
  38. <th><%= before_label('sortable_name', 'Sortable Name') %></th>
  39. <td class="sortable_name"><%=h @user.sortable_name %></td>
  40. </tr>
  41. <% if service_enabled?(:avatars) %>
  42. <tr>
  43. <th><%= before_label('profile_picture', 'Profile Picture') %></th>
  44. <td>
  45. <span class="avatar_image">
  46. <%= avatar @user, url: nil %>
  47. </span>
  48. <% if can_do(@user, @current_user, :remove_avatar) %>
  49. <a href="<%= update_avatar_image_url(@user.id) %>" class="remove_avatar_picture_link">{{#t}}Remove avatar picture{{/t}}</a>
  50. <% elsif !session["reported_#{@user.id}"] %>
  51. <a href="<%= report_avatar_image_url(@user.id) %>" class="report_avatar_picture_link">{{#t}}Report inappropriate picture{{/t}}</a>
  52. <% end %>
  53. </td>
  54. </tr>
  55. <% end %>
  56. <tr>
  57. <th><%= before_label('default_email', 'Default Email') %></th>
  58. <td class="email"><%=h @user.email %></td>
  59. </tr>
  60. <tr>
  61. <th><%= before_label('time_zone', 'Time Zone') %></th>
  62. <td class="time_zone"><%= @user.time_zone.try(:name) || t('none', "None") %></td>
  63. </tr>
  64. <% unless @read_only %>
  65. <%# order important: the can_do(...) check filters out contexts that don't respond to root_account (e.g. User) %>
  66. <% first = true %>
  67. <td class="links" colspan="2" style="text-align: right; font-size: 0.8em; padding-top: 10px;">
  68. <% if @user.grants_right?(@current_user, :rename) %>
  69. <% first = false %>
  70. <a href="#" class="edit_user_link">{{#t}}Edit{{/t}}</a>
  71. <% end %>
  72. <% if @user != @current_user && @user.can_masquerade?(@real_current_user || @current_user, @domain_root_account) %>
  73. <%= "|" unless first %><% first = false %>
  74. <% if @context && !@context.is_a?(Account) && !@context.is_a?(User) %>
  75. <a href="<%= context_url(@context, :context_url, :become_user_id => @user.id) %>"> {{#t}}Act as User{{/t}}</a>
  76. <% else %>
  77. <a href="<%= dashboard_url(:become_user_id => @user.id) %>"> {{#t}}Act as User{{/t}}</a>
  78. <% end %>
  79. <% end %>
  80. <% if @user.grants_right?(@current_user, :merge) %>
  81. <%= "|" unless first %><% first = false %>
  82. <a class="merge_user_link" href="<%= user_admin_merge_url(@user.id) %>">{{#t}}Merge with Another User{{/t}}</a>
  83. <% end %>
  84. <% if ((@context.is_a?(User) || @context.is_a?(Account)) && root_account) && @user.allows_user_to_remove_from_account?(root_account, @current_user) %>
  85. <%= "|" unless first %>
  86. <a href="<%= account_confirm_delete_user_url(root_account.id, @user.id) %>"><%= t('delete_from_account', 'Delete from %{account}', :account => root_account.name) %></a>
  87. <% end %>
  88. </td>
  89. <% end %>
  90. </table>
  91. </fieldset>
  92. <% unless @read_only %>
  93. <div title="<%= t 'titles.edit_user_details', 'Edit User Details' %>" id="edit_student_dialog" style="display: none;">
  94. <p>{{#t}}You can update some of this user's information, but they can change it back if they choose.{{/t}}</p>
  95. <%= form_for @user, :url => user_url(@user),
  96. :html => {:id => "edit_student_form", :class => 'form-dialog form-horizontal'} do |f| %>
  97. <table class="formtable">
  98. <tr>
  99. <td><%= f.blabel :name, :en => "Full Name" %></td>
  100. <td><%= f.text_field :name %></td>
  101. </tr><tr>
  102. <td><%= f.blabel :short_name, :en => "Display Name" %></td>
  103. <td><%= f.text_field :short_name %></td>
  104. </tr><tr>
  105. <td><%= f.blabel :sortable_name, :en => "Sortable Name" %></td>
  106. <td><%= f.text_field :sortable_name %></td>
  107. </tr>
  108. <% if @user.grants_right?(@current_user, :manage_user_details) %>
  109. <tr>
  110. <td><%= f.blabel :time_zone, :en => "Time Zone" %></td>
  111. <td><%= f.time_zone_select :time_zone, I18nTimeZone.us_zones, :model => I18nTimeZone, :default => (@domain_root_account.try(:default_time_zone) || "Mountain Time (US & Canada)") %></td>
  112. </tr><tr>
  113. <td><%= f.blabel :email, :en => "Default Email" %></td>
  114. <td><%= f.email_field :email %></td>
  115. </tr>
  116. <% end %>
  117. </table>
  118. <div class='form-controls'>
  119. <button type="button" class="btn cancel_button">{{#t}}Cancel{{/t}}</button>
  120. <button type="submit" class="btn btn-primary submit_button">{{#t}}Update Details{{/t}}</button>
  121. </div>
  122. <% end %>
  123. </div>
  124. <% end %>