tweaks to new can_upload_free flag #2469

This commit is contained in:
r888888888
2015-10-15 16:23:18 -07:00
parent 6480864718
commit 5a853bcedb
6 changed files with 38 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ form.simple_form {
div.input.boolean {
label {
display: inline;
margin-left: 0.5em;
vertical-align: middle;
}
}

View File

@@ -9,7 +9,11 @@ module Admin
def update
@user = User.find(params[:id])
@user.promote_to!(params[:user][:level])
@user.promote_to!(
params[:user][:level],
:can_approve_posts => params[:user][:can_approve_posts],
:can_upload_free => params[:user][:can_upload_free]
)
redirect_to edit_admin_user_path(@user), :notice => "User updated"
end
end

View File

@@ -79,6 +79,7 @@ module ApplicationHelper
def link_to_user(user, options = {})
user_class = user.level_class
user_class = user_class + " user-post-approver" if user.can_approve_posts?
user_class = user_class + " user-post-uploader" if user.can_upload_free?
user_class = user_class + " with-style" if CurrentUser.user.style_usernames?
if options[:raw_name]
name = user.name
@@ -96,7 +97,7 @@ module ApplicationHelper
html << " [" + link_to("+", new_user_feedback_path(:user_feedback => {:category => "positive", :user_id => user.id})) + "]"
unless user.is_gold?
html << " [" + link_to("invite", new_moderator_invitation_path(:invitation => {:name => user.name}, :flag => "can_upload_free")) + "]"
html << " [" + link_to("invite", new_moderator_invitation_path(:invitation => {:name => user.name, :can_upload_free => "1"})) + "]"
end
else
html << " [" + link_to("&ndash;".html_safe, new_user_feedback_path(:user_feedback => {:category => "negative", :user_id => user.id})) + "]"

View File

@@ -12,6 +12,8 @@ class UserPromotion
validate
user.level = new_level
user.can_approve_posts = options[:can_approve_posts]
user.can_upload_free = options[:can_upload_free]
user.inviter_id = promoter.id
create_transaction_log_item
@@ -55,7 +57,7 @@ private
end
def create_dmail
if user.level >= user.level_was
if user.level >= user.level_was || user.bit_prefs_changed?
create_promotion_dmail
else
create_demotion_dmail
@@ -63,10 +65,22 @@ private
end
def create_promotion_dmail
approval_text = if user.can_approve_posts?
"You can approve posts."
else
""
end
upload_text = if user.can_upload_free?
"You can upload posts without limit."
else
""
end
Dmail.create_split(
:to_id => user.id,
:title => "You have been promoted",
:body => "You have been promoted to a #{user.level_string} level account."
:body => "You have been promoted to a #{user.level_string} level account. #{approval_text} #{upload_text}"
)
end
@@ -74,7 +88,7 @@ private
Dmail.create_split(
:to_id => user.id,
:title => "You have been demoted",
:body => "You have been demoted to a #{user.level_string} level account."
:body => "You have been demoted to a #{user.level_string} level account. #{approval_text} #{upload_text}"
)
end
end

View File

@@ -32,6 +32,10 @@ class UserPresenter
permissions << "approve posts"
end
if user.can_upload_free?
permissions << "unrestricted uploads"
end
permissions.join(", ")
end

View File

@@ -10,6 +10,16 @@
<%= user_level_select(:user, :level) %>
</div>
<div class="input boolean optional">
<label for="user_can_upload_free" class="optional">Unrestricted Uploads</label>
<%= check_box(:user, :can_upload_free) %>
</div>
<div class="input boolean optional">
<label for="user_can_approve_posts" class="optional">Approve Posts</label>
<%= check_box(:user, :can_approve_posts) %>
</div>
<%= submit_tag "Update" %>
<% end %>
</div>