Combined Mastodon username and instance fields into one field.

This commit is contained in:
Logan Fick
2017-10-15 17:07:51 -04:00
parent b07830fc7a
commit e0ca823245
2 changed files with 4 additions and 10 deletions

View File

@@ -137,9 +137,9 @@ class UsersController < ApplicationController
def update def update
if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?)
if mod? if mod?
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :mastodon, :mastodon_instance, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :mastodon, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark])
else else
userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :mastodon, :mastodon_instance, :about, :header_scroll, :utc_time, :dark]) userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :mastodon, :about, :header_scroll, :utc_time, :dark])
end end
if userdata[:role] if userdata[:role]
role = Role.get(userdata[:role]) role = Role.get(userdata[:role])
@@ -153,10 +153,6 @@ class UsersController < ApplicationController
if userdata[:badge] if userdata[:badge]
userdata[:badge] = Badge.get(userdata[:badge]) userdata[:badge] = Badge.get(userdata[:badge])
end end
unless userdata[:mastodon].blank?
userdata[:mastodon] = "#{userdata[:mastodon].gsub("@", "")}#{("@" + userdata[:mastodon_instance].gsub("@", "")) unless userdata[:mastodon_instance].blank?}"
end
userdata.delete(:mastodon_instance)
if @user.youtube != userdata[:youtube] if @user.youtube != userdata[:youtube]
youtube = get_youtube(userdata[:youtube]) youtube = get_youtube(userdata[:youtube])
userdata[:youtube] = youtube[:channel] userdata[:youtube] = youtube[:channel]

View File

@@ -56,10 +56,8 @@
</tr> </tr>
<tr> <tr>
<td>Mastodon</td> <td>Mastodon</td>
<td style="display:inline;padding:0px"> <td>
<% mstdn_array = @user.mastodon.split("@") if @user.mastodon %> <%= f.text_field :mastodon, placeholder: "Mastodon username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)) %>
<%= f.text_field :mastodon, value: (mstdn_array[0] if mstdn_array), placeholder: "Mastodon username", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%;float:left;margin-right:2%" %>
<%= f.text_field :mastodon_instance, value: (mstdn_array[1] if mstdn_array), placeholder: "Mastodon instance", disabled: !(@user.is?(current_user) && confirmed? || (mod? && current_user.role >= @user.role)), style: "width:49%" %>
</td> </td>
</tr> </tr>
<tr> <tr>