FIX: Don't fail silently when updating a record.
This commit is contained in:
parent
44ee388070
commit
bb0b7b61d7
|
@ -65,10 +65,11 @@ class GroupUser < ActiveRecord::Base
|
||||||
|
|
||||||
def grant_trust_level
|
def grant_trust_level
|
||||||
return if group.grant_trust_level.nil?
|
return if group.grant_trust_level.nil?
|
||||||
|
|
||||||
if (user.group_locked_trust_level || 0) < group.grant_trust_level
|
if (user.group_locked_trust_level || 0) < group.grant_trust_level
|
||||||
user.group_locked_trust_level = group.grant_trust_level
|
user.update!(group_locked_trust_level: group.grant_trust_level)
|
||||||
user.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
TrustLevelGranter.grant(group.grant_trust_level, user)
|
TrustLevelGranter.grant(group.grant_trust_level, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,14 +85,10 @@ class GroupUser < ActiveRecord::Base
|
||||||
if highest_level.nil?
|
if highest_level.nil?
|
||||||
# If the user no longer has a group with a trust level,
|
# If the user no longer has a group with a trust level,
|
||||||
# unlock them, start at 0 and consider promotions.
|
# unlock them, start at 0 and consider promotions.
|
||||||
user.group_locked_trust_level = nil
|
user.update!(group_locked_trust_level: nil)
|
||||||
user.save
|
|
||||||
|
|
||||||
Promotion.recalculate(user)
|
Promotion.recalculate(user)
|
||||||
else
|
else
|
||||||
user.group_locked_trust_level = highest_level
|
user.update!(group_locked_trust_level: highest_level)
|
||||||
user.save
|
|
||||||
|
|
||||||
user.change_trust_level!(highest_level)
|
user.change_trust_level!(highest_level)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue